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>
This commit is contained in:
Kevin O'Connor 2022-07-25 10:21:29 -04:00
parent 3387a9c23d
commit 3796a31959
1 changed files with 9 additions and 0 deletions

View File

@ -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: