From: Keith Packard Date: Mon, 8 Jan 2024 03:14:03 +0000 (-0800) Subject: altos/telelco-v3.0: Add ao_adc_single usage to get battery voltage X-Git-Tag: 1.9.18~2^2~60 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=8c5c7dfe66098bc8af47768146739a7cda605968 altos/telelco-v3.0: Add ao_adc_single usage to get battery voltage Poll the ADC to acquire battery voltage data. Signed-off-by: Keith Packard --- diff --git a/src/telelco-v3.0/Makefile b/src/telelco-v3.0/Makefile index 60057622..b5763972 100644 --- a/src/telelco-v3.0/Makefile +++ b/src/telelco-v3.0/Makefile @@ -17,7 +17,6 @@ INC = \ ao_sample.h \ ao_pins.h \ ao_product.h \ - ao_seven_segment.h \ ao_lco.h \ ao_lco_cmd.h \ ao_lco_func.h \ @@ -48,6 +47,7 @@ ALTOS_SRC = \ ao_timer.c \ ao_mutex.c \ ao_freq.c \ + ao_adc_single_stm.c \ ao_dma_stm.c \ ao_spi_stm.c \ ao_beep_stm.c \ diff --git a/src/telelco-v3.0/ao_lco_v3.c b/src/telelco-v3.0/ao_lco_v3.c index 998dbc3a..5fe50472 100644 --- a/src/telelco-v3.0/ao_lco_v3.c +++ b/src/telelco-v3.0/ao_lco_v3.c @@ -22,6 +22,7 @@ #include #include #include +#include #define WIDTH AO_ST7565_WIDTH #define HEIGHT AO_ST7565_HEIGHT @@ -281,8 +282,7 @@ ao_lco_batt_voltage(void) struct ao_adc packet; int16_t decivolt; -// ao_adc_single_get(&packet); - packet.v_batt = 0; + ao_adc_single_get(&packet); decivolt = ao_battery_decivolt(packet.v_batt); ao_lco_show_voltage((uint16_t) decivolt, "LCO battery"); ao_delay(AO_MS_TO_TICKS(1000)); diff --git a/src/telelco-v3.0/ao_pins.h b/src/telelco-v3.0/ao_pins.h index 312e8d03..6402ed49 100644 --- a/src/telelco-v3.0/ao_pins.h +++ b/src/telelco-v3.0/ao_pins.h @@ -270,8 +270,6 @@ struct ao_adc { #define AO_ADC_V_BATT_PORT (&stm_gpioa) #define AO_ADC_V_BATT_PIN 2 -#define AO_ADC_RCC_AHBENR (1 << STM_RCC_AHBENR_GPIOAEN) - #define AO_ADC_PIN0_PORT AO_ADC_V_BATT_PORT #define AO_ADC_PIN0_PIN AO_ADC_V_BATT_PIN diff --git a/src/telelco-v3.0/ao_telelco.c b/src/telelco-v3.0/ao_telelco.c index 9530cf14..4ce46f3e 100644 --- a/src/telelco-v3.0/ao_telelco.c +++ b/src/telelco-v3.0/ao_telelco.c @@ -27,7 +27,7 @@ #include #include #include -//#include +#include #include int @@ -44,6 +44,7 @@ main(void) ao_spi_init(); ao_dma_init(); ao_exti_init(); + ao_adc_single_init(); ao_beep_init(); ao_cmd_init();