stm32f1xx-hal
stm32f1xx-hal copied to clipboard
add temp/vref controls
Previously when an Adc
is initialized, the temp/vref sensor was disabled. During an ADC read, the sensor has to be turned on and off, which significantly increases the time it takes for a read. Additionally, since there was no way to enable to sensor manually, I don't think it was possible to read VREF in DMA mode.
Now, there are 3 additional functions, enable_temp_vref
, disable_temp_vref
and is_temp_vref_enabled
. These functions are optional, and will speed up reading from the ADC if it is enabled manually.
The read_aux
function now also only enables the sensor if the temp or vref channel is being read.
I tested this with an STM32F103 (bluepill)
Thanks for the PR, and sorry for the review delay! Looks good to me, I left a small note on the return value of enable_temp_vref
for discussion.
Could you also add this change to CHANGELOG.md?
I'm not seeing the note on the enable_temp_vref
function, but I don't have strong opinions on how the return value is decided.
The options:
- (current approach), return true if the function changed something, meaning the sensor was previously off.
- Returns if the sensor was previously on.
I'm fine switching the approach if that sounds better, the one I picked was mostly arbitrary.
My question was more about if the function should return anything at all. Is there a use case for knowing if it was previously on (or off)?
My question was more about if the function should return anything at all. Is there a use case for knowing if it was previously on (or off)?
Possibly. If that's blocking this change I'm fine removing the return type though.