-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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 a STM32 Digital Temperature Sensor and add it to STM32H7 family DTS #72982
Conversation
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.
Thanks for this addition @aurel32.
To be complete, we'd need a way to at least build this driver in CI (using samples/sensor/die_temp_polling
?)
I have just pushed a new version renaming the sensor to I have added a board overlay for the
|
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.
Thanks a lot for adding this new driver !
It's a interesting enhancement
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.
Few late comments that I forgot to commit, sorry.
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.
Thanks for the changes!
One very last request and this will be fine to me:
Unless I'm wrong, you'll need to add nucleo_h7a3zi_q
as integration platform to the sample to ensure it is taken into account in test campaigns.
(We'll also need to tune this later on to get it ran on our test bench, but we'll take care of it).
That should be done now. |
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.
Thanks!
while (READ_BIT(dts->SR, DTS_SR_TS1_RDY) == 0) { | ||
k_yield(); | ||
} | ||
|
||
/* Trigger a measurement */ | ||
SET_BIT(dts->CFGR1, DTS_CFGR1_TS1_START); | ||
CLEAR_BIT(dts->CFGR1, DTS_CFGR1_TS1_START); | ||
|
||
/* Wait for interrupt */ | ||
k_sem_take(&data->sem_isr, K_FOREVER); |
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.
Non-blocker suggestion: should we have a fail-safe on the while-loop
and k_sem_take()
? I'm thinking of returning -ETIMEDOUT
or similar in case the happy-path does not work.
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.
Do we really need to do that with K_FOREVER
. Looking at the documentation, it could return:
0
– Semaphore taken.-EBUSY
– Returned without waiting.-EAGAIN
– Waiting period timed out, or the semaphore was reset during the waiting period.
It seems that the -EBUSY
case can only happens when using K_NO_WAIT
. For -EAGAIN
, the period timeout can't happen as K_FOREVER
is used, and the semaphore reset also can't happened as it is only initialized in stm32_digi_temp_init
as part of the driver initialization.
Therefore I don't think we need to add a while loop around it. In addition, I haven't found such a structure (with K_FOREVER
) elsewhere in the Zephyr's code.
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.
Perhaps I didn't explain myself:
WRT the while-loop: I'm referring to
while (READ_BIT(dts->SR, DTS_SR_TS1_RDY) == 0) {
k_yield();
}
WRT the semaphore: I'm alluding of a scenario where the semaphore is not given, therefore the execution path is blockde. Handling such case involves changing the semaphore from K_FOREVER to a specific timeout and handling the error-codes you described.
This add basic support for the STM32 Digital Temperature Sensor found notably on the STM32H7 series. It work in interrupt mode and support basic power device management. It does not support the more advanced features like using the temperature threshold, triggers from LPTIM or using the LSE clock in during sleep or stop. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Add a digi_dietemp node for the STM32 Digital Temperature Sensor into stm32h723.dtsi (used as a base for H723, H725, H730 and H735) and stm32h7a3.dtsi (used as a base for H7A3, H7B0 and H7B3). The sensor is not available on other H7 SoCs. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Added board nucleo_h7a3zi_q overlay file to permit testing the STM32 Digital Temperature Sensor. Also added the board as integration platform to the sample. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Tested on a Nucleo h7a3zi board, it gives similar results as the analog temperature sensor.