-
Notifications
You must be signed in to change notification settings - Fork 39
Add getTemperature() to support internal temp sensor #159
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
I've tried this branch, seems all good. getTemperature() returns believable values at room temperature and under hot air at nominally 100degC. |
Code looks good! We're test-driving the new (more formal) process of merging PRs into the 'release-candidate' branch. @nseidle can you adjust this PR to target that branch? I'm not sure if there is an easy way or if you will have to close this PR and open a new one targeting the correct branch. Let me know if you run into trouble since this is a pretty new process for us! |
4814dda
to
870e83d
Compare
Changed target branch (not too hard). |
Awesome. I'm glad it was easy for you. I wonder if that had to do with your access level? PaulZC had trouble with the same task here |
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.
While doing my final review I had one thought about the name of this function. Other than that it seems good and others report that it tests well (I loaned my hardware to Kyle last week and have yet to retrieve it)
@@ -44,6 +44,7 @@ ap3_err_t ap3_change_channel(ap3_gpio_pad_t padNumber); | |||
bool power_adc_disable(); | |||
uint16_t analogRead(uint8_t pinNumber); | |||
ap3_err_t analogReadResolution(uint8_t bits); | |||
float getTemperature(); |
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 feel like getTemperature()
is just a bit too generic. What am I getting the temperature of? Should I be passing in an argument that is a value to convert to temperature?
How about something like getInternalTempC()
or getChipTempC()
?
I'm all for a name change. getInternalTemp() is better IMO. Want me to make the changes? |
This PR:
Function is wholly based on adc_vbatt.c example from latest Ambiq SDK. Function is required (rather than a ADC read and a series of maths) because there's a HAL call that reads the on board calibration factors. It was easier to leverage their call then roll our own.
getTemperature correctly pulls in user's chosen analogResolution() with a pow(2, _analogBits) calculation.