From 321556be4eda94be40dbefe13f0549ad224c7c33 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 10 Jan 2024 23:49:00 -0800 Subject: [PATCH] altos/stm32f1: Turn on ADC during initialization sequence The ADC needs to be left 'on' so that it will actually run the conversion sequence when started. Signed-off-by: Keith Packard --- src/stm32f1/ao_adc_single_stm.c | 13 +++++-------- src/stm32f103-nucleo/flash-loader/ao_pins.h | 4 +++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/stm32f1/ao_adc_single_stm.c b/src/stm32f1/ao_adc_single_stm.c index ac0342b5..3ddddf10 100644 --- a/src/stm32f1/ao_adc_single_stm.c +++ b/src/stm32f1/ao_adc_single_stm.c @@ -207,7 +207,7 @@ ao_adc_single_init(void) (0 << STM_ADC_CR1_AWDCH )); /* 384 cycle sample time for everyone */ - stm_adc.smpr1 = 0x3ffff; + stm_adc.smpr1 = 0x00ffffff; stm_adc.smpr2 = 0x3fffffff; stm_adc.sqr1 = ((AO_NUM_ADC - 1) << 20); @@ -263,17 +263,14 @@ ao_adc_single_init(void) #error "too many ADC channels" #endif -#ifndef HAS_ADC_TEMP -#error Please define HAS_ADC_TEMP -#endif -#if HAS_ADC_TEMP - stm_adc.cr2 |= ((1 << STM_ADC_CR2_TSVREFE)); -#endif - /* Clear any stale status bits */ stm_adc.sr = 0; ao_dma_alloc(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC1)); + /* Turn on the ADC so that it is ready to convert */ + + stm_adc.cr2 = AO_ADC_CR2_VAL; + ao_cmd_register(&ao_adc_cmds[0]); } diff --git a/src/stm32f103-nucleo/flash-loader/ao_pins.h b/src/stm32f103-nucleo/flash-loader/ao_pins.h index f46a385c..0353aa81 100644 --- a/src/stm32f103-nucleo/flash-loader/ao_pins.h +++ b/src/stm32f103-nucleo/flash-loader/ao_pins.h @@ -38,7 +38,9 @@ #include -/* Companion port cs_companion0 PB6 */ +/* USB DM is on PA11 (CN10 pin 14). USB DP is on PA12 (CN10 pin 12) */ + +/* For pullup, we'll use PB6 (CN10 pin 16) */ #define AO_BOOT_PIN 1 #define AO_BOOT_APPLICATION_GPIO stm_gpiob -- 2.30.2