Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

nikkoxp
Copy link

@nikkoxp nikkoxp commented Jul 30, 2024

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

@alexandruradovici alexandruradovici changed the title Function that returns the number of channels in adc Add ADC Channel parameter to the ADC API Jul 30, 2024
apis/peripherals/adc/src/lib.rs Outdated Show resolved Hide resolved
apis/peripherals/adc/src/lib.rs Outdated Show resolved Hide resolved
apis/peripherals/adc/src/lib.rs Outdated Show resolved Hide resolved
apis/peripherals/adc/src/lib.rs Outdated Show resolved Hide resolved
examples/adc.rs Outdated Show resolved Hide resolved
examples/adc.rs Outdated Show resolved Hide resolved
@bradjc
Copy link
Contributor

bradjc commented Jul 30, 2024

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.

apis/peripherals/adc/src/lib.rs Outdated Show resolved Hide resolved
examples/adc.rs Outdated Show resolved Hide resolved
@alexandruradovici
Copy link
Contributor

alexandruradovici commented Jul 31, 2024

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
Copy link
Contributor

@nikkoxp please modify the tests.

examples/adc.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants