Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gpio variants #42

Merged
merged 1 commit into from
Jul 17, 2020
Merged

Use gpio variants #42

merged 1 commit into from
Jul 17, 2020

Conversation

Sh3Rm4n
Copy link
Member

@Sh3Rm4n Sh3Rm4n commented Dec 22, 2019

This PR upgrades to variant methods for the gpio module.

Doing this I had to extend the macro invocations significantly.
Also, I found no elegant way to apply this to the downgradable pins, as the pin register field access is determined via
"runtime".

rust-embedded/svd2rust#400 could help with that.

Also, for the stm32f3x8 and stm32f373 series, this can not be applied right now, as they are missing a gpio documentation.

stm32-rs/stm32-rs#321 will add these.

@Sh3Rm4n Sh3Rm4n force-pushed the gpio-variant branch 4 times, most recently from f2c8bf6 to 0bc070b Compare March 7, 2020 16:01
@Sh3Rm4n Sh3Rm4n marked this pull request as ready for review March 7, 2020 16:42
@Sh3Rm4n
Copy link
Member Author

Sh3Rm4n commented Mar 7, 2020

Now that stm32f3 v0.10 is released, this builds for all stm3f3xx targets again.

This blows up the macros in the gpio module to a large extent, but the code itself should be simplified.

I would keep it like that for now. When the field array support is released under a new svd2rust version and stm32f3 will use it in the next release, this code could be simplified a lot.

When this happens, i will open a follow up PR.

@Sh3Rm4n Sh3Rm4n requested a review from dfrankland March 7, 2020 16:51
@Sh3Rm4n Sh3Rm4n mentioned this pull request Mar 10, 2020
@teskje teskje requested review from teskje and removed request for dfrankland July 14, 2020 17:43
@teskje
Copy link
Collaborator

teskje commented Jul 14, 2020

Hey @Sh3Rm4n, could you rebase to resolve the conflicts?

src/gpio.rs Outdated Show resolved Hide resolved
src/gpio.rs Outdated Show resolved Hide resolved
src/gpio.rs Outdated Show resolved Hide resolved
src/gpio.rs Outdated Show resolved Hide resolved
src/gpio.rs Outdated Show resolved Hide resolved
src/gpio.rs Outdated Show resolved Hide resolved
stm32f3 provides methods, with which we can access each variant
of a register. No more bit-shifts and -masks are needed.

This also removes a lot off `unsafe` calls, which where needed before
to access a whole register without any bound guards for fields and
flags.

This makes the macro section quite more verbose, because there is
no method with an array index access-point. So we have to be explicit
for every method name we add. `moder0`, `moder1`, ...
@teskje teskje merged commit 753d61c into stm32-rs:master Jul 17, 2020
@teskje
Copy link
Collaborator

teskje commented Jul 17, 2020

Looks good, thanks!

teskje added a commit to teskje/stm32f3xx-hal that referenced this pull request Jul 17, 2020
This commit:
 - Makes the order of InputPin impls consistent
 - Impls InputPin only for Output<OpenDrain>, not the generic
   Output<MODE>
 - Adjusts the register access in accordance with the recently merged
   GPIO refactoring (stm32-rs#42)
 - Makes rustfmt happy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants