Skip to content

Commit f1ac138

Browse files
committed
stm32 L4xx HAL drivers and datasheets quote a worst case startup time of 120us for the temperature
Based on previous examples, bump this value by 25% and add the wait
1 parent 84389a5 commit f1ac138

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/adc.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,19 @@ impl ADC {
199199
}
200200

201201
/// Enable and get the `Temperature`
202-
pub fn enable_temperature(&mut self) -> Temperature {
202+
pub fn enable_temperature(&mut self, delay: &mut impl DelayUs<u32>) -> Temperature {
203203
self.common.ccr.modify(|_, w| w.ch17sel().set_bit());
204204

205+
// rm0351 section 18.4.32 pg580 (L47/L48/L49/L4A models)
206+
// Note:
207+
// The sensor has a startup time after waking from power-down mode before it can output VTS
208+
// at the correct level. The ADC also has a startup time after power-on, so to minimize the
209+
// delay, the ADEN and CH17SEL bits should be set at the same time.
210+
//
211+
// https://github.com/STMicroelectronics/STM32CubeL4/blob/master/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_adc.h#L1363
212+
// 120us is used in the ST HAL code
213+
delay.delay_us(150);
214+
205215
Temperature {}
206216
}
207217

0 commit comments

Comments
 (0)