summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Massey <bart.massey@gmail.com>2016-02-08 18:55:28 -0800
committerKeith Packard <keithp@keithp.com>2016-02-08 18:55:28 -0800
commite36117ccbf7cbe3704c6b44d3ad429e720a1e16c (patch)
treef421f051a1b6ea260098e1a158705472ab6ffb70
parent5ce26345784459f5864ef59c96c8aa633d2ddf64 (diff)
Clean up stmf0 adc init.
This better matches the documented cal sequence. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/stmf0/ao_adc_fast.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/stmf0/ao_adc_fast.c b/src/stmf0/ao_adc_fast.c
index 26e6691c..f6740b0e 100644
--- a/src/stmf0/ao_adc_fast.c
+++ b/src/stmf0/ao_adc_fast.c
@@ -83,7 +83,6 @@ void
ao_adc_init(void)
{
uint32_t chselr;
- int i;
/* Reset ADC */
stm_rcc.apb2rstr |= (1 << STM_RCC_APB2RSTR_ADCRST);
@@ -157,12 +156,13 @@ ao_adc_init(void)
/* Shortest sample time */
stm_adc.smpr = STM_ADC_SMPR_SMP_1_5 << STM_ADC_SMPR_SMP;
+ /* Turn off enable and start */
+ stm_adc.cr &= ~((1 << STM_ADC_CR_ADEN) | (1 << STM_ADC_CR_ADSTART));
+
/* Calibrate */
stm_adc.cr |= (1 << STM_ADC_CR_ADCAL);
- for (i = 0; i < 0xf000; i++) {
- if ((stm_adc.cr & (1 << STM_ADC_CR_ADCAL)) == 0)
- break;
- }
+ while ((stm_adc.cr & (1 << STM_ADC_CR_ADCAL)) != 0)
+ ;
/* Enable */
stm_adc.cr |= (1 << STM_ADC_CR_ADEN);