drivers: adc: stm32: Clear ADRDY before waiting
Clear ADRDY before enabling ADC to ensure the subsequent wait for ADRDY does not stop prematurely in case ADRDY was already set. The "ADC on-off control" sections of the following reference manuals were consulted. That gives at least one instance per series affected by this change, even if not every affected MCU is covered. - RM0438 (STM32L552xx and STM32L562xx) - RM0351 (STM32L47xxx, STM32L48xxx, STM32L49xxx and STM32L4Axxx) - RM0434 (STM32WB55xx and STM32WB35xx) - RM0454 (STM32G0x0) - RM0440 (STM32G4 Series) - RM0399 (STM32H745/755 and STM32H747/757) - RM0433 (STM32H742, STM32H743/753 and STM32H750) - RM0453 (STM32WL5x) Signed-off-by: Alexander Mihajlovic <a@abxy.se>
This commit is contained in:
parent
e521c7d49e
commit
cfce5afcd9
1 changed files with 10 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue