diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2022-07-25 17:21:29 +0300 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2022-07-25 17:21:29 +0300 |
commit | 3796a319599e84b58886ec6f733277bfe4f1a747 (patch) | |
tree | 0a44fd3b2593d868a1c20f6d224961de978bce18 | |
parent | 3387a9c23d940c7d449f197b272616eda11a5e3d (diff) |
stm32: Add CCRDY check to stm32g0 adc
The stm32g0 specification states that it is required to wait for the
CCRDY flag to be raised after changing the channel configuration.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | src/stm32/stm32f0_adc.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/stm32/stm32f0_adc.c b/src/stm32/stm32f0_adc.c index 8f27dce75..f46ccbde9 100644 --- a/src/stm32/stm32f0_adc.c +++ b/src/stm32/stm32f0_adc.c @@ -119,7 +119,16 @@ gpio_adc_sample(struct gpio_adc g) return 0; goto need_delay; } +#if CONFIG_MACH_STM32G0 + if (adc->CHSELR != g.chan) { + adc->ISR = ADC_ISR_CCRDY; + adc->CHSELR = g.chan; + while (!(adc->ISR & ADC_ISR_CCRDY)) + ; + } +#else adc->CHSELR = g.chan; +#endif adc->CR = CR_FLAGS | ADC_CR_ADSTART; need_delay: |