-
Notifications
You must be signed in to change notification settings - Fork 179
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
digital v2 #93
digital v2 #93
Conversation
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.
Thanks for the PR! If I understand this correctly, all an end user has to do to use this version with a v1 driver is what's done in examples/mfrc522.rs
? Perhaps it would be a good idea to add that to the docs to make things less confusing for new users.
Apart from that, and the note about the never type, I'd say this looks good to merge
src/gpio.rs
Outdated
@@ -143,49 +143,52 @@ macro_rules! gpio { | |||
} | |||
|
|||
impl<MODE> OutputPin for $PXx<Output<MODE>> { | |||
fn set_high(&mut self) { | |||
type Error = (); |
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 think I read somewhere that the prefered error type for a non-failable pin is !
rather than ()
. Though the never type isn't fully implemented iirc
My English not good enough to write documentation. |
No problem. I was thinking something like this Interfacing with v1 traits
This is done using let nss = gpioa.pa4.into_push_pull_output(&mut gpioa.crl);
let mut mfrc522 = Mfrc522::new(spi, OldOutputPin::from(nss)).unwrap(); |
Do I need to add this in README or only in docs? |
Docs should be enough I think |
Maybe using the void crate for the error instead of ()? |
Yea, that might not be a bad idea, especially since we already depend on it. What are the problems with using |
I think ! is not usable at this position on stable. |
Done. Rebased. |
I think it might be better to put the new docs in the |
What |
Yes
|
Done. |
src/gpio.rs
Outdated
!self.is_low() | ||
type Error = Void; | ||
fn is_high(&self) -> Result<bool, Self::Error> { | ||
Ok(!(self.is_low()?)) |
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.
Is there any reason why this snippet differs from all the other places ?
Why not the same here:
self.is_low().map(|b| !b)
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.
Fixed.
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.
LGTM, thanks !
It looks like |
Fixed. |
Perfect, thanks! |
No description provided.