-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add ADC Channel parameter to the ADC API #555
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Alexandru Radovici <msg4alex@gmail.com>
Co-authored-by: Alexandru Radovici <msg4alex@gmail.com>
Do we need this for an older version of the kernel? Or is OK if this only works on latest master of the kernel? If the latter, it would be better to add a new get_counts command to the adc capsule and then use that command number. We made a mistake using command 0 for the count here, and if we fix it now that reduces the overhead for whenever tock 3.0 happens. |
This should work with the current version of the kernel. The kernel driver does not have a special command for returning the number of channels, command 0 still does this. |
@nikkoxp please modify the tests. |
S::command( | ||
DRIVER_NUM, | ||
SINGLE_SAMPLE, | ||
(channel as usize).try_into().unwrap(), |
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.
(channel as usize).try_into().unwrap(), | |
channel as u32, |
I would avoid the panic as most probably usize
will be 32 bits.
@jrvanwhy I would like your input on this.
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.
Without looking at the entire CL: it looks like read_single_sample
should take channel
as a u32
.
One question to ask that helps decide usize
versus u32
is "in the unit test environment, which runs on 64-bit platforms, should this number get larger?" I don't think a unit test environment should support more channels than the real hardware, so this should be a u32
. usize
makes sense for memory addresses and offsets, but not necessarily for other hardware addresses.
Pull Request Overview
This pull request adds:
adc.rs
file to test all available channels at onceTesting Strategy
This pull request was tested on a microbit.
TODO or Help Wanted
Feedback