diff --git a/drivers/adc/adc_stm32.c b/drivers/adc/adc_stm32.c index ac311460e9b..a6b59de6195 100644 --- a/drivers/adc/adc_stm32.c +++ b/drivers/adc/adc_stm32.c @@ -412,11 +412,6 @@ static void adc_stm32_oversampling(ADC_TypeDef *adc, uint8_t ratio, uint32_t shi */ static int adc_stm32_enable(ADC_TypeDef *adc) { - if (LL_ADC_IsEnabled(adc) == 1UL) { - return 0; - } - LL_ADC_Enable(adc); - #if defined(CONFIG_SOC_SERIES_STM32L4X) || \ defined(CONFIG_SOC_SERIES_STM32L5X) || \ defined(CONFIG_SOC_SERIES_STM32WBX) || \ @@ -424,6 +419,14 @@ static int adc_stm32_enable(ADC_TypeDef *adc) defined(CONFIG_SOC_SERIES_STM32G4X) || \ defined(CONFIG_SOC_SERIES_STM32H7X) || \ defined(CONFIG_SOC_SERIES_STM32WLX) + + if (LL_ADC_IsEnabled(adc) == 1UL) { + return 0; + } + + LL_ADC_ClearFlag_ADRDY(adc); + LL_ADC_Enable(adc); + /* * Enabling ADC modules in L4, WB, G0 and G4 series may fail if they are * still not stabilized, this will wait for a short time to ensure ADC @@ -440,6 +443,8 @@ static int adc_stm32_enable(ADC_TypeDef *adc) } } } +#else + LL_ADC_Enable(adc); #endif return 0;