libtock-rs icon indicating copy to clipboard operation
libtock-rs copied to clipboard

Add ADC Channel parameter to the ADC API

Open nikkoxp opened this issue 1 year ago • 3 comments

Pull Request Overview

This pull request adds:

  • a function that returns the number of ADC channels.
  • updates the API functions to allow specifying the ADC channel by parameterising the existing functions
  • improve the example by adding a while loop was added in the adc.rs file to test all available channels at once

Testing Strategy

This pull request was tested on a microbit.

TODO or Help Wanted

Feedback

nikkoxp avatar Jul 30 '24 12:07 nikkoxp

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.

bradjc avatar Jul 30 '24 18:07 bradjc

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.

alexandruradovici avatar Jul 31 '24 08:07 alexandruradovici

@nikkoxp please modify the tests.

alexandruradovici avatar Jul 31 '24 09:07 alexandruradovici