-
Notifications
You must be signed in to change notification settings - Fork 235
Add InputPin trait #36
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
Conversation
Hm, I thought I mentioned somewhere that this would be sorely missing but I can't find where. 😄 Much appreciated! |
I'm also looking for a way to read the state of a GPIO pin :) Is anything blocking this PR? |
Thanks, @thejpster @homunkulus r+ I read some comments on IRC I think there's some confusion about the role of the HAL traits. You don't need an InputPin trait to provide input pin functionality. It's totally fine to provide functionality using inherent methods like this: impl<MODE> PA0<Input<MODE>> {
pub fn is_low(&self) -> bool { /* .. */ }
pub fn is_high(&self) -> bool { /* .. */ }
} In fact, I prefer this form because then you don't need to import a trait to be able to use the method (thankfully, we have preludes). The main reason you'll want to provide the functionality through a trait is to be able to use it for generic programming, i.e. as a bound in some generic driver. (The other reason could be that you want to create a |
📌 Commit 278145a has been approved by |
Add InputPin trait I needed a basic InputPin trait for the buttons on my Stellaris Launchpad.
☀️ Test successful - status-travis |
@japaric Indeed. It is useful to bind it as an used "interrupt" pin to a driver to make sure it's correctly configured and cannot be used otherwise by accident. I'm curious how we could actually establish the connection with a real interrupt though since that setup is still somewhat messy and manual. |
Add InputPin trait I needed a basic InputPin trait for the buttons on my Stellaris Launchpad.
36: Add timer::CountDown implementation r=posborne a=dbrgn Based on the [implementation by @MathiasKoch](https://github.com/BlackbirdHQ/ublox-cellular-rs/blob/master/examples/common/timer.rs). Co-authored-by: Danilo Bargen <[email protected]>
I needed a basic InputPin trait for the buttons on my Stellaris Launchpad.