-
Notifications
You must be signed in to change notification settings - Fork 69
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
Do not require registers to be passed to GPIO configuration functions #213
base: master
Are you sure you want to change the base?
Conversation
For anyone curious like me, the generated assembly looks like this (building the Old Version (231c959)
New Version (6aba91b)
With a critical-sectionJust for fun I also added a critical section to the function (the version from the master branch) to see how this would look in comparison (not a full implementation of the concept):
The source diffdiff --git a/src/gpio.rs b/src/gpio.rs
index 0cfdac95e670..d15c5b9eeeaa 100644
--- a/src/gpio.rs
+++ b/src/gpio.rs
@@ -395,14 +395,17 @@ where
}
/// Configures the pin to operate as a push-pull output pin
+ #[inline(never)]
pub fn into_push_pull_output(
self,
moder: &mut Gpio::MODER,
otyper: &mut Gpio::OTYPER,
) -> Pin<Gpio, Index, Output<PushPull>> {
- moder.output(self.index.index());
- otyper.push_pull(self.index.index());
- self.into_mode()
+ cortex_m::interrupt::free(|_cs| {
+ moder.output(self.index.index());
+ otyper.push_pull(self.index.index());
+ self.into_mode()
+ })
}
/// Configures the pin to operate as an open-drain output pin I hope this provides some insight into how the different approaches compare. It would be interesting to calculate the WCET as well (for the code where that is possible). |
They were a bit of chatting around how to test this, before applying these ergonomic improvements overall in the embedded-hal meeting ~ a month ago: https://matrix.to/#/!BHcierreUuwCMxVqOf:matrix.org/$J63pKvA9WeSSGtQZQkqFKH-xzk0gXfjEJIIDEAvjRmU?via=matrix.org&via=privacytools.io&via=mozilla.org I have not given it much thought since then, but maybe someone has some ideas. I want to push #212 a bit forward, to have a better reference point. Maybe I'll find some time this week to add a few more (hopefully all relevant gpio tests). |
#212 is now merged and v0.7.0 is released. This would introduce a major, but really wanted change. I would be more confident, that we write some tests for this change, so that we can be more confident, that this is really working (and also atomic and concurrency safe) |
97c5591
to
4141fd1
Compare
Updated to prepare generated assembly
|
I haven't looked into this PR in a while, but it seems this is a huge improvement on ergonomics. Also, I have not followed up on any benchmark proposal, we should do before merging this, but in any case, let's push this forward, when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. I like that the patch has more removed lines than added lines 😁
Have you tested it with the current test set (reminds me, that I could do it myself as running the code now is easier than ever)!
And do you have an idea how to stress test it? Or did you do it yourself already? :)
Hey, this is conflicting with #316 with will probably will introduce much work on this PR again. I just wanted to ask if you have time to adjust to these changes. I'm willing to pick this up if I find time myself if that's okay for you :) |
5bc5697
to
380f622
Compare
ref: #37