-
Notifications
You must be signed in to change notification settings - Fork 246
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 Channel<Adc> for DynPin #557
Conversation
rp2040-hal/src/adc.rs
Outdated
where | ||
WORD: From<u16>, | ||
{ | ||
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.
Could we have an enum there?
Something simple like
#[cfg_attr(feature = "defmt", derive(defmt::Defmt))]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct InvalidPinError;
and return Err(nb::Error::Other(InvalidPinError))
.
(The exact error's name may be different.)
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.
Good point. I copied that type from impl<WORD, PIN> OneShot<Adc, WORD, PIN> for Adc
. But there, something like InvalidPinError
can't happen. In fact, that implementation never returns Err
. I wonder why it has type Error = ()
and not type Error = Infallible
. But that's a different topic, and changing that would be a breaking change.
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 didn't include all those derives on purpose:
- we don't do it on the other error types in this crate
- I think we should strive for consistently
- adding derives is easier than removing them, as it doesn't break existing code
Changed to draft as it probably conflicts with #585 |
Obsoleted by #585 |
No description provided.