aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/adc.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-11-26 23:06:56 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-11-27 11:16:41 -0500
commitfc476f22b66c81cb57c161ae843cc434bdeabe26 (patch)
tree55fcdce6030a38688438841e854fbc06a13da9a3 /src/stm32/adc.c
parent8d93d1a8ef89a3c727fa2f8059961363c785dd78 (diff)
downloadkutter-fc476f22b66c81cb57c161ae843cc434bdeabe26.tar.gz
kutter-fc476f22b66c81cb57c161ae843cc434bdeabe26.tar.xz
kutter-fc476f22b66c81cb57c161ae843cc434bdeabe26.zip
stm32: Fix typo in adc startup delay
Fix (harmless) typo and add comments on adc timing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/adc.c')
-rw-r--r--src/stm32/adc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/stm32/adc.c b/src/stm32/adc.c
index b6aa14b8..3998915f 100644
--- a/src/stm32/adc.c
+++ b/src/stm32/adc.c
@@ -34,6 +34,11 @@ static const uint8_t adc_pins[] = {
#define CR2_FLAGS ADC_CR2_ADON
#endif
+// ADC timing:
+// stm32f103: ADC clock=9Mhz, Tconv=12.5, Tsamp=28.5, total=4.556us
+// stm32f407: ADC clock=21Mhz, Tconv=12, Tsamp=56, total=3.238us
+// stm32f446: ADC clock=22.5Mhz, Tconv=12, Tsamp=56, total=3.022us
+
struct gpio_adc
gpio_adc_setup(uint32_t pin)
{
@@ -72,7 +77,7 @@ gpio_adc_setup(uint32_t pin)
#if CONFIG_MACH_STM32F1
// Perform calibration
- udelay(timer_from_us(1));
+ udelay(10);
adc->CR2 = ADC_CR2_CAL | CR2_FLAGS;
while (adc->CR2 & ADC_CR2_CAL)
;