-
Notifications
You must be signed in to change notification settings - Fork 3k
Extend AnalogIn API: read_voltage #12471
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
Conversation
@AGlass0fMilk, thank you for your changes. |
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.
Why was the default value chosen to be in drivers, not part of HAL as each target (=board in this case) can overwrite this value - it's board dependent (external vs internal ref used).
Good point. I immediately thought "AnalogIn configuration ==> mbed_lib.json in drivers folder" I can change it to a target-level configuration and add it to the base target that everything inherits from to provide a default. Would that be acceptable? |
I would think that would be better in this case. Any objections? |
I will rebase this soon. Had a thought though: In the future the AnalogIn (and all Analog-related API's, really) should be redesigned. The function |
2684038
to
5810160
Compare
@0xc0170 I addressed the outstanding issues with this PR and rebased. Let me know if any other changes are needed. |
Any update on the CI? LGTM |
CI restarted
It should be stable ,so lets try |
@0xc0170 @kjbracey-arm |
@0xc0170 @kjbracey-arm Any update on this PR? I have addressed all change requests. |
@0xc0170 Any update on this? It's blocking development at my company. |
@AGlass0fMilk I'll see if I can get someone to review and move this on. |
Ci triggered @ithinuel Can you review if this is now OK to go in? |
Test run: SUCCESSSummary: 6 of 6 test jobs passed |
Waiting on @ithinuel review |
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
@0xc0170 merge merge merge! |
Summary of changes
For calculating real-world parameters (eg: ohms, amps) from ADC readings, it is often useful to know the actual voltage represented by the ADC's numerical output. This functionality can indeed be abstracted elsewhere, but I think it makes sense to put this in the ADC API itself.
As it stands, the
AnalogIn
API only provides a normalized output and leaves the application up to calculate the actual voltage based on the system's ADC reference.This PR adds the ability for the user to configure a default ADC Vref by overriding
target.default-adc-vref
. Additionally, anAnalogIn
instance's reference voltage can be set at runtime in case multiple ADC references are possible in the target (in the case of multiple ADC peripherals or internally configurable ADC references such as in the case of Nordic chips).Impact of changes
Since this PR only extends the AnalogIn API, there should be no impacts on existing users.
Migration actions required
None
Documentation
I will update
AnalogIn
API documentation once this PR has been discussed with the Mbed OS team and agreed upon.Pull request type
Test results
Reviewers