-
Notifications
You must be signed in to change notification settings - Fork 105
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
Implement IoPin #256
Implement IoPin #256
Conversation
src/gpio.rs
Outdated
Ok(self) | ||
} | ||
fn into_output_pin(mut self, state: PinState) -> Result<Self, Self::Error> { | ||
self.set_state(state)?; |
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.
I see here the problem that if setting the state fails, the pin is dropped.
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.
That is something I did not think about. I mostly copied all the implementations from stm32-rs/stm32f4xx-hal where they use into_push_pull_output_in_state
which would solve this I think.
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.
The set_low
and set_high
methods implemented here are infallible (use the Never
type as an error), so set_state
would also be infallible.
Maybe we should implement our own infallible set_state
(as stm32f4xx-hal does) and use that?
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.
I'd not seen the IoPin
trait yet, but it's certainly interesting.
This PR should also bump the embedded-hal
version in Cargo.toml
to 0.2.6, since 0.2.{4,5} would no longer be supported.
Should the other outdated dependencies also be updated? |
No, the issue is that with this change the crate would no longer compile with If there's a good solution to avoid ever returning |
Would that really be necessary though? |
Hmm, yes there is the |
Somewhat unrelated, is there a reason for using |
Looks good! My best guess is that |
bors r+ |
Implements the IoPin trait from embedded-hal.