Skip to content

Commit aa670f7

Browse files
gautierg-stnashif
authored andcommitted
drivers: adc: stm32: check ldo ready bit
For STM32H7, U5 and WBA, check the LDORDY bit of the ADC ISR register after enabling the internal regulator. This method is safer than the delay. Signed-off-by: Guillaume Gautier <[email protected]>
1 parent faa5fa1 commit aa670f7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/adc/adc_stm32.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,28 @@ static int adc_stm32_init(const struct device *dev)
14461446
!DT_HAS_COMPAT_STATUS_OKAY(st_stm32f1_adc) && \
14471447
!DT_HAS_COMPAT_STATUS_OKAY(st_stm32f4_adc)
14481448
LL_ADC_EnableInternalRegulator(adc);
1449+
/* Wait for Internal regulator stabilisation
1450+
* Some series have a dedicated status bit, others relie on a delay
1451+
*/
1452+
#if defined(CONFIG_SOC_SERIES_STM32H7X) && defined(ADC_VER_V5_V90)
1453+
/* ADC3 on H72x/H73x doesn't have the LDORDY status bit */
1454+
if (adc == ADC3) {
1455+
k_busy_wait(LL_ADC_DELAY_INTERNAL_REGUL_STAB_US);
1456+
} else {
1457+
while (LL_ADC_IsActiveFlag_LDORDY(adc) == 0) {
1458+
}
1459+
}
1460+
#elif defined(CONFIG_SOC_SERIES_STM32H7X) || \
1461+
defined(CONFIG_SOC_SERIES_STM32U5X) || \
1462+
defined(CONFIG_SOC_SERIES_STM32WBAX)
1463+
/* Don't use LL_ADC_IsActiveFlag_LDORDY since not present in U5 LL (1.5.0)
1464+
* (internal issue 185106)
1465+
*/
1466+
while ((READ_BIT(adc->ISR, LL_ADC_FLAG_LDORDY) != (LL_ADC_FLAG_LDORDY))) {
1467+
}
1468+
#else
14491469
k_busy_wait(LL_ADC_DELAY_INTERNAL_REGUL_STAB_US);
1470+
#endif
14501471
#endif
14511472

14521473
if (config->irq_cfg_func) {

0 commit comments

Comments
 (0)