From: Keith Packard Date: Sun, 17 Jun 2018 00:58:00 +0000 (-0700) Subject: Switch to adc single X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=ffcdffbac36771faa1aa9c3bb9ab510718aa7f95 Switch to adc single --- diff --git a/src/stm-demo-adc/Makefile b/src/stm-demo-adc/Makefile index 869fb32f..7870792e 100644 --- a/src/stm-demo-adc/Makefile +++ b/src/stm-demo-adc/Makefile @@ -32,7 +32,7 @@ ALTOS_SRC = \ ao_mutex.c \ ao_dma_stm.c \ ao_spi_stm.c \ - ao_adc_stm.c \ + ao_adc_single_stm.c \ ao_data.c \ ao_i2c_stm.c \ ao_usb_stm.c \ diff --git a/src/stm-demo-adc/ao_demo.c b/src/stm-demo-adc/ao_demo.c index fba42d8d..75716c1c 100644 --- a/src/stm-demo-adc/ao_demo.c +++ b/src/stm-demo-adc/ao_demo.c @@ -22,6 +22,7 @@ #include #include #include +#include struct ao_task demo_task; @@ -138,19 +139,27 @@ ao_i2c_write(void) { } } + static void ao_temp (void) { - struct ao_data packet; + struct ao_adc adc; int temp; +#if HAS_ADC + struct ao_data packet; ao_data_get(&packet); + adc = packet.adc; +#endif +#if HAS_ADC_SINGLE + ao_adc_single_get(&adc); +#endif /* * r = (110 - 25) / (ts_cal_hot - ts_cal_cold) * 25 + (110 - 25) * (temp - ts_cal_cold) / (ts_cal_hot - ts_cal_cold) */ - temp = 25 + (110 - 25) * (packet.adc.temp - stm_temp_cal.ts_cal_cold) / (stm_temp_cal.ts_cal_hot - stm_temp_cal.ts_cal_cold); + temp = 25 + (110 - 25) * (adc.temp - stm_temp_cal.ts_cal_cold) / (stm_temp_cal.ts_cal_hot - stm_temp_cal.ts_cal_cold); printf ("temp: %d\n", temp); } @@ -231,7 +240,7 @@ main(void) // ao_timer_set_adc_interval(100); - ao_adc_init(); + ao_adc_single_init(); ao_usb_init(); ao_add_task(&ao_blink_task, ao_blink, "blink"); diff --git a/src/stm-demo-adc/ao_pins.h b/src/stm-demo-adc/ao_pins.h index eb33aa70..428fcde9 100644 --- a/src/stm-demo-adc/ao_pins.h +++ b/src/stm-demo-adc/ao_pins.h @@ -140,9 +140,7 @@ #define AO_LCD_DUTY STM_LCD_CR_DUTY_STATIC -#define HAS_ADC 1 - -#define AO_ADC_RING 32 +#define HAS_ADC_SINGLE 1 struct ao_adc { int16_t idd; @@ -150,8 +148,8 @@ struct ao_adc { int16_t vref; }; -#define AO_ADC_DUMP(p) printf("tick: %5u idd %5d temp %5d vref %5d\n", \ - (p)->tick, (p)->adc.idd, (p)->adc.temp, (p)->adc.vref) +#define AO_ADC_DUMP(p) printf("idd %5d temp %5d vref %5d\n", \ + (p)->idd, (p)->temp, (p)->vref) #define AO_ADC_IDD 4 #define AO_ADC_PIN0_PORT (&stm_gpioa)