aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-07-25 10:21:29 -0400
committerKevin O'Connor <kevin@koconnor.net>2022-07-25 10:21:29 -0400
commit3796a319599e84b58886ec6f733277bfe4f1a747 (patch)
tree0a44fd3b2593d868a1c20f6d224961de978bce18
parent3387a9c23d940c7d449f197b272616eda11a5e3d (diff)
downloadkutter-3796a319599e84b58886ec6f733277bfe4f1a747.tar.gz
kutter-3796a319599e84b58886ec6f733277bfe4f1a747.tar.xz
kutter-3796a319599e84b58886ec6f733277bfe4f1a747.zip
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.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/stm32/stm32f0_adc.c b/src/stm32/stm32f0_adc.c
index 8f27dce7..f46ccbde 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: