Skip to content

Commit

Permalink
stm32: Fix typo in adc startup delay
Browse files Browse the repository at this point in the history
Fix (harmless) typo and add comments on adc timing.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Nov 27, 2019
1 parent 8d93d1a commit fc476f2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/stm32/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
;
Expand Down

0 comments on commit fc476f2

Please sign in to comment.