stm32: Fix ADC for STM32G4

At least STM32G4 requires four ADC clock cycles between hardware
clearing ADCCAL and setting ADEN or the write disappears. Make a
tenacious write attempt.

Signed-off-by: Alex Maclean <monkeh@monkeh.net>
This commit is contained in:
Alex Maclean 2023-12-15 22:49:07 +00:00 committed by KevinOConnor
parent 71ab6240f2
commit 147492b253
1 changed files with 3 additions and 2 deletions

View File

@ -240,6 +240,7 @@ gpio_adc_setup(uint32_t pin)
// Enable ADC // Enable ADC
adc->ISR = ADC_ISR_ADRDY; adc->ISR = ADC_ISR_ADRDY;
adc->ISR; // Dummy read to make sure write is flushed adc->ISR; // Dummy read to make sure write is flushed
while (!(adc->CR & ADC_CR_ADEN))
adc->CR |= ADC_CR_ADEN; adc->CR |= ADC_CR_ADEN;
while (!(adc->ISR & ADC_ISR_ADRDY)) while (!(adc->ISR & ADC_ISR_ADRDY))
; ;