altos/stm32f1: Turn on ADC during initialization sequence
authorKeith Packard <keithp@keithp.com>
Thu, 11 Jan 2024 07:49:00 +0000 (23:49 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 1 Feb 2024 01:50:19 +0000 (17:50 -0800)
The ADC needs to be left 'on' so that it will actually
run the conversion sequence when started.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/stm32f1/ao_adc_single_stm.c
src/stm32f103-nucleo/flash-loader/ao_pins.h

index ac0342b51402acb005eb46f2261ad8505e3916b1..3ddddf1093faff45fc8bd32f01516367b9cb2e9e 100644 (file)
@@ -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]);
 }
index f46a385ce876d0993e546ce75788f3752d81f1cc..0353aa81edf7f14c0a890526d3be0cb1e4e2eaba 100644 (file)
@@ -38,7 +38,9 @@
 
 #include <ao_flash_stm_pins.h>
 
-/* 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