-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/nrf5x: add driver for internal temperature sensor #11139
Conversation
0bfd51a
to
b2a4028
Compare
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.
OK, looks good to me. I'll test later. I was first confused with the name saul_temperature
and thought it should be a pseudo module to enable all present temperature senors. I'd think you should better rename that to include nrf5x in the name somewhere.
while (!NRF_TEMP->EVENTS_DATARDY); /* takes 36us according to manual */ | ||
|
||
/* temperature is in 0.25°C step, so just divide by 4 */ | ||
*temp = (int16_t)NRF_TEMP->TEMP >> 2; |
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'd guess the last one or two bits of this make a good entropy source for random generators. (<-- Totally unrelated to this PR, I'm just curious.)
* @} | ||
*/ | ||
|
||
#ifdef MODULE_SAUL_TEMPERATURE |
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 think it is unlikely that other temperature sensors can share this code for auto init, as e.g. all external sensors need to be configured (at least the interface needs to be specified). Also, other auto init codes allows to add multiple sensors (e.g. when interfacing with an array of DHT11 sensors), which makes no sense for this driver - there will never be more than one CPU internal temp sensor on a board. I really would rename this to include nrf5x somewhere.
I agree with this proposition and will update. What about |
b2a4028
to
eee75b3
Compare
@maribu, I renamed the saul function to include |
I'll test on Monday. Feel free to squash |
eee75b3
to
f390a8d
Compare
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.
Works on a nrf52840dk
. Let's rerun Murdock and then hit merge.
Thanks @maribu ! |
No problem. Thanks for the contribution! |
Contribution description
The Nordic MCUs provide an internal temperature sensor. This PR is providing a basic implementation for it and wraps it in the saul API.
The driver is enabled for all nrf (51 and 52) boards.
I'm not sure of the design approach of this PR, so review comments to improve are welcome.
Testing procedure
Build and flash examples/saul on any nrf based board, and read the temperature.
Issues/PRs references
None