From b31b4622d5bd92c0cc0851818f5b595dbdb60ead Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:15:25 -0800 Subject: altos: Clean up some minor warnings from -Wall Unused variables, functions and labels, missing enums in switch. Signed-off-by: Keith Packard --- src/stm/ao_adc_stm.c | 4 +++- src/stm/ao_i2c_stm.c | 6 ------ src/stm/ao_usb_stm.c | 4 ---- 3 files changed, 3 insertions(+), 11 deletions(-) (limited to 'src/stm') diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c index 53f19b40..505addfa 100644 --- a/src/stm/ao_adc_stm.c +++ b/src/stm/ao_adc_stm.c @@ -109,8 +109,10 @@ static void ao_adc_dump(void) __reentrant { struct ao_data packet; - int16_t *d; +#ifndef AO_ADC_DUMP uint8_t i; + int16_t *d; +#endif ao_data_get(&packet); #ifdef AO_ADC_DUMP diff --git a/src/stm/ao_i2c_stm.c b/src/stm/ao_i2c_stm.c index 809b5c6f..1c90cdb8 100644 --- a/src/stm/ao_i2c_stm.c +++ b/src/stm/ao_i2c_stm.c @@ -185,7 +185,6 @@ uint8_t ao_i2c_start(uint8_t index, uint16_t addr) { struct stm_i2c *stm_i2c = ao_i2c_stm_info[index].stm_i2c; - uint32_t sr1, sr2; int t; ao_i2c_state[index] = I2C_IDLE; @@ -239,10 +238,7 @@ uint8_t ao_i2c_send(void *block, uint16_t len, uint8_t index, uint8_t stop) { struct stm_i2c *stm_i2c = ao_i2c_stm_info[index].stm_i2c; - uint8_t *b = block; - uint32_t sr1; uint8_t tx_dma_index = ao_i2c_stm_info[index].tx_dma_index; - int t; /* Clear any pending ADDR bit */ (void) stm_i2c->sr2; @@ -304,8 +300,6 @@ uint8_t ao_i2c_recv(void *block, uint16_t len, uint8_t index, uint8_t stop) { struct stm_i2c *stm_i2c = ao_i2c_stm_info[index].stm_i2c; - uint8_t *b = block; - int t; uint8_t ret = TRUE; if (len == 0) diff --git a/src/stm/ao_usb_stm.c b/src/stm/ao_usb_stm.c index 28a9f9f3..27b82357 100644 --- a/src/stm/ao_usb_stm.c +++ b/src/stm/ao_usb_stm.c @@ -119,7 +119,6 @@ static uint8_t ao_usb_in_pending; static uint8_t ao_usb_out_avail; static uint8_t ao_usb_running; static uint8_t ao_usb_configuration; -static uint8_t ueienx_0; #define AO_USB_EP0_GOT_RESET 1 #define AO_USB_EP0_GOT_SETUP 2 @@ -313,7 +312,6 @@ ao_usb_init_ep(uint8_t ep, uint32_t addr, uint32_t type, uint32_t stat_rx, uint3 static void ao_usb_set_ep0(void) { - uint32_t epr; int e; ao_usb_sram_addr = 0; @@ -356,8 +354,6 @@ ao_usb_set_ep0(void) static void ao_usb_set_configuration(void) { - uint32_t epr; - debug ("ao_usb_set_configuration\n"); /* Set up the INT end point */ -- cgit v1.2.3 From db8f3426ac1cf756a2e4974ca61a5ae9048c80ce Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:21:23 -0800 Subject: altos: Turn on -Wall for stm compiles The warnings are all cleaned up now, leave this on by default Signed-off-by: Keith Packard --- src/stm/Makefile.defs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/stm') diff --git a/src/stm/Makefile.defs b/src/stm/Makefile.defs index 9adcfeb3..d0e5a699 100644 --- a/src/stm/Makefile.defs +++ b/src/stm/Makefile.defs @@ -24,8 +24,11 @@ include $(TOPDIR)/Makedefs CC=$(ARM_CC) LIBS=$(PDCLIB_LIBS_M3) -lgcc +WARN_FLAGS=-Wall + AO_CFLAGS=-I. -I../stm -I../core -I../drivers -I../math -I.. $(PDCLIB_INCLUDES) -STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb -ffreestanding -nostdlib $(AO_CFLAGS) +STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb \ + -ffreestanding -nostdlib $(AO_CFLAGS) $(WARN_FLAGS) LDFLAGS=-L../stm -Wl,-Taltos.ld -- cgit v1.2.3 From 5c9172ba5681ff93d63c9c263a453d0025170045 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:43:18 -0800 Subject: altos: Clean up -Wextra warnings Unused variables, mismatching signed/unsigned and a few other misc warnings. Signed-off-by: Keith Packard --- src/aes/ao_aes.c | 1 + src/core/ao_config.c | 2 ++ src/core/ao_fec.h | 2 +- src/core/ao_gps_report_metrum.c | 3 +-- src/core/ao_log_metrum.c | 1 - src/core/ao_radio_cmac.c | 1 - src/core/ao_telemetry.c | 1 - src/drivers/ao_cc1120.c | 4 ++-- src/drivers/ao_companion.c | 4 ++-- src/drivers/ao_event.c | 2 +- src/drivers/ao_event.h | 2 +- src/drivers/ao_lco_cmd.c | 1 - src/drivers/ao_lco_func.c | 1 - src/drivers/ao_mpu6000.c | 16 ++++++++-------- src/math/ef_rem_pio2.c | 2 +- src/stm/ao_adc_stm.c | 1 + src/stm/ao_exti_stm.c | 5 +++++ src/stm/ao_lcd_stm.c | 3 +-- src/stm/ao_profile.h | 2 +- src/stm/ao_spi_stm_slave.c | 2 +- src/stm/stm32l.h | 6 +++--- src/telelco-v0.2/ao_lco.c | 4 ---- 22 files changed, 32 insertions(+), 34 deletions(-) (limited to 'src/stm') diff --git a/src/aes/ao_aes.c b/src/aes/ao_aes.c index 52463f5d..a04174c6 100644 --- a/src/aes/ao_aes.c +++ b/src/aes/ao_aes.c @@ -367,6 +367,7 @@ static uint8_t iv[16]; void ao_aes_set_mode(enum ao_aes_mode mode) { + (void) mode; /* we only do CBC_MAC anyways... */ } diff --git a/src/core/ao_config.c b/src/core/ao_config.c index 4a1c58b9..590d8a49 100644 --- a/src/core/ao_config.c +++ b/src/core/ao_config.c @@ -658,8 +658,10 @@ ao_config_help(void) __reentrant; static void ao_config_show(void) __reentrant; +#if HAS_EEPROM static void ao_config_save(void) __reentrant; +#endif __code struct ao_config_var ao_config_vars[] = { #if HAS_FLIGHT diff --git a/src/core/ao_fec.h b/src/core/ao_fec.h index eedea8f4..618756c1 100644 --- a/src/core/ao_fec.h +++ b/src/core/ao_fec.h @@ -31,7 +31,7 @@ void ao_fec_dump_bytes(const uint8_t *bytes, uint16_t len, const char *name); #endif -static uint16_t inline +static inline uint16_t ao_fec_crc_byte(uint8_t byte, uint16_t crc) { uint8_t bit; diff --git a/src/core/ao_gps_report_metrum.c b/src/core/ao_gps_report_metrum.c index fa038976..696a833b 100644 --- a/src/core/ao_gps_report_metrum.c +++ b/src/core/ao_gps_report_metrum.c @@ -24,9 +24,8 @@ ao_gps_report_metrum(void) static __xdata struct ao_log_metrum gps_log; static __xdata struct ao_telemetry_location gps_data; static __xdata struct ao_telemetry_satellite gps_tracking_data; - uint8_t c, n, i, p, valid, packets; + uint8_t c, n, i; uint8_t svid; - uint8_t date_reported = 0; uint8_t new; for (;;) { diff --git a/src/core/ao_log_metrum.c b/src/core/ao_log_metrum.c index 43441e7a..91624d98 100644 --- a/src/core/ao_log_metrum.c +++ b/src/core/ao_log_metrum.c @@ -81,7 +81,6 @@ void ao_log(void) { __pdata uint16_t next_sensor, next_other; - uint8_t i; ao_storage_setup(); diff --git a/src/core/ao_radio_cmac.c b/src/core/ao_radio_cmac.c index 3ca3c313..bff848f6 100644 --- a/src/core/ao_radio_cmac.c +++ b/src/core/ao_radio_cmac.c @@ -21,7 +21,6 @@ static __xdata uint8_t ao_radio_cmac_mutex; __pdata int8_t ao_radio_cmac_rssi; static __xdata uint8_t cmac_data[AO_CMAC_MAX_LEN + AO_CMAC_KEY_LEN + 2 + AO_CMAC_KEY_LEN]; -static __pdata uint8_t ao_radio_cmac_len; static uint8_t round_len(uint8_t len) diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c index e529b717..86158063 100644 --- a/src/core/ao_telemetry.c +++ b/src/core/ao_telemetry.c @@ -211,7 +211,6 @@ ao_send_metrum_data(void) { if (--ao_telemetry_metrum_data_cur <= 0) { __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; - uint8_t i; telemetry.generic.tick = packet->tick; telemetry.generic.type = AO_TELEMETRY_METRUM_DATA; diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index 3429768b..31225939 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -509,7 +509,7 @@ static void ao_radio_set_mode(uint16_t new_mode) { uint16_t changes; - int i; + unsigned int i; if (new_mode == ao_radio_mode) return; @@ -563,7 +563,7 @@ static uint8_t ao_radio_configured = 0; static void ao_radio_setup(void) { - int i; + unsigned int i; ao_radio_strobe(CC1120_SRES); diff --git a/src/drivers/ao_companion.c b/src/drivers/ao_companion.c index 0f405253..570b9e40 100644 --- a/src/drivers/ao_companion.c +++ b/src/drivers/ao_companion.c @@ -67,8 +67,8 @@ ao_companion_get_setup(void) ao_companion_send_command(AO_COMPANION_SETUP); ao_spi_recv(&ao_companion_setup, sizeof (ao_companion_setup), AO_COMPANION_SPI_BUS); COMPANION_DESELECT(); - return (ao_companion_setup.board_id == - (uint16_t) ~ao_companion_setup.board_id_inverse); + return ((int16_t) ao_companion_setup.board_id == + (int16_t) (uint16_t) (~ao_companion_setup.board_id_inverse)); } static void diff --git a/src/drivers/ao_event.c b/src/drivers/ao_event.c index c428125d..5c0d2863 100644 --- a/src/drivers/ao_event.c +++ b/src/drivers/ao_event.c @@ -30,7 +30,7 @@ uint8_t ao_event_queue_insert; uint8_t ao_event_queue_remove; -uint8_t +void ao_event_get(struct ao_event *ev) { ao_arch_critical( diff --git a/src/drivers/ao_event.h b/src/drivers/ao_event.h index ed9a7433..584a845a 100644 --- a/src/drivers/ao_event.h +++ b/src/drivers/ao_event.h @@ -29,7 +29,7 @@ struct ao_event { int32_t value; }; -uint8_t +void ao_event_get(struct ao_event *ev); void diff --git a/src/drivers/ao_lco_cmd.c b/src/drivers/ao_lco_cmd.c index 9c35b324..acbf589a 100644 --- a/src/drivers/ao_lco_cmd.c +++ b/src/drivers/ao_lco_cmd.c @@ -119,7 +119,6 @@ lco_report_cmd(void) __reentrant static void lco_fire_cmd(void) __reentrant { - static __xdata struct ao_pad_command command; uint8_t secs; uint8_t i; int8_t r; diff --git a/src/drivers/ao_lco_func.c b/src/drivers/ao_lco_func.c index 99e58b76..a5d28e61 100644 --- a/src/drivers/ao_lco_func.c +++ b/src/drivers/ao_lco_func.c @@ -26,7 +26,6 @@ static __xdata uint8_t ao_lco_mutex; int8_t ao_lco_query(uint16_t box, struct ao_pad_query *query, uint16_t *tick_offset) { - uint8_t i; int8_t r; uint16_t sent_time; diff --git a/src/drivers/ao_mpu6000.c b/src/drivers/ao_mpu6000.c index 0689d7a7..c0458027 100644 --- a/src/drivers/ao_mpu6000.c +++ b/src/drivers/ao_mpu6000.c @@ -132,7 +132,7 @@ ao_mpu6000_gyro(int16_t v) #endif static uint8_t -ao_mpu6000_accel_check(int16_t normal, int16_t test, char *which) +ao_mpu6000_accel_check(int16_t normal, int16_t test) { int16_t diff = test - normal; @@ -146,7 +146,7 @@ ao_mpu6000_accel_check(int16_t normal, int16_t test, char *which) } static uint8_t -ao_mpu6000_gyro_check(int16_t normal, int16_t test, char *which) +ao_mpu6000_gyro_check(int16_t normal, int16_t test) { int16_t diff = test - normal; @@ -292,13 +292,13 @@ _ao_mpu6000_setup(void) ao_delay(AO_MS_TO_TICKS(200)); _ao_mpu6000_sample(&normal_mode); - errors += ao_mpu6000_accel_check(normal_mode.accel_x, test_mode.accel_x, "x"); - errors += ao_mpu6000_accel_check(normal_mode.accel_y, test_mode.accel_y, "y"); - errors += ao_mpu6000_accel_check(normal_mode.accel_z, test_mode.accel_z, "z"); + errors += ao_mpu6000_accel_check(normal_mode.accel_x, test_mode.accel_x); + errors += ao_mpu6000_accel_check(normal_mode.accel_y, test_mode.accel_y); + errors += ao_mpu6000_accel_check(normal_mode.accel_z, test_mode.accel_z); - errors += ao_mpu6000_gyro_check(normal_mode.gyro_x, test_mode.gyro_x, "x"); - errors += ao_mpu6000_gyro_check(normal_mode.gyro_y, test_mode.gyro_y, "y"); - errors += ao_mpu6000_gyro_check(normal_mode.gyro_z, test_mode.gyro_z, "z"); + errors += ao_mpu6000_gyro_check(normal_mode.gyro_x, test_mode.gyro_x); + errors += ao_mpu6000_gyro_check(normal_mode.gyro_y, test_mode.gyro_y); + errors += ao_mpu6000_gyro_check(normal_mode.gyro_z, test_mode.gyro_z); if (!errors) break; } diff --git a/src/math/ef_rem_pio2.c b/src/math/ef_rem_pio2.c index f1191d09..3e58f809 100644 --- a/src/math/ef_rem_pio2.c +++ b/src/math/ef_rem_pio2.c @@ -142,7 +142,7 @@ pio2_3t = 6.1232342629e-17; /* 0x248d3132 */ fn = (float)n; r = t-fn*pio2_1; w = fn*pio2_1t; /* 1st round good to 40 bit */ - if(n<32&&(ix&0xffffff00)!=npio2_hw[n-1]) { + if(n<32&&(ix&(__int32_t)0xffffff00)!=npio2_hw[n-1]) { y[0] = r-w; /* quick check no cancellation */ } else { __uint32_t high; diff --git a/src/stm/ao_adc_stm.c b/src/stm/ao_adc_stm.c index 505addfa..53d4b8c3 100644 --- a/src/stm/ao_adc_stm.c +++ b/src/stm/ao_adc_stm.c @@ -41,6 +41,7 @@ static uint8_t ao_adc_ready; */ static void ao_adc_done(int index) { + (void) index; AO_DATA_PRESENT(AO_DATA_ADC); ao_dma_done_transfer(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC1)); if (ao_data_present == AO_DATA_ALL) { diff --git a/src/stm/ao_exti_stm.c b/src/stm/ao_exti_stm.c index c1dcdf85..35958cf8 100644 --- a/src/stm/ao_exti_stm.c +++ b/src/stm/ao_exti_stm.c @@ -119,6 +119,8 @@ ao_exti_setup (struct stm_gpio *gpio, uint8_t pin, uint8_t mode, void (*callback void ao_exti_set_mode(struct stm_gpio *gpio, uint8_t pin, uint8_t mode) { + (void) gpio; + uint32_t mask = 1 << pin; if (mode & AO_EXTI_MODE_RISING) @@ -133,12 +135,14 @@ ao_exti_set_mode(struct stm_gpio *gpio, uint8_t pin, uint8_t mode) { void ao_exti_set_callback(struct stm_gpio *gpio, uint8_t pin, void (*callback)()) { + (void) gpio; ao_exti_callback[pin] = callback; } void ao_exti_enable(struct stm_gpio *gpio, uint8_t pin) { uint32_t mask = (1 << pin); + (void) gpio; stm_exti.pr = mask; stm_exti.imr |= (1 << pin); } @@ -146,6 +150,7 @@ ao_exti_enable(struct stm_gpio *gpio, uint8_t pin) { void ao_exti_disable(struct stm_gpio *gpio, uint8_t pin) { uint32_t mask = (1 << pin); + (void) gpio; stm_exti.imr &= ~mask; stm_exti.pr = mask; } diff --git a/src/stm/ao_lcd_stm.c b/src/stm/ao_lcd_stm.c index 47ea374e..95af53d1 100644 --- a/src/stm/ao_lcd_stm.c +++ b/src/stm/ao_lcd_stm.c @@ -346,8 +346,7 @@ static const struct ao_cmds ao_lcd_stm_cmds[] = { void ao_lcd_stm_init(void) { - int s, c; - int r; + unsigned int s, c; uint32_t csr; stm_rcc.ahbenr |= ((AO_LCD_STM_USES_GPIOA << STM_RCC_AHBENR_GPIOAEN) | diff --git a/src/stm/ao_profile.h b/src/stm/ao_profile.h index f7dd029d..f8a0c25e 100644 --- a/src/stm/ao_profile.h +++ b/src/stm/ao_profile.h @@ -20,7 +20,7 @@ void ao_profile_init(); -static uint32_t inline ao_profile_tick(void) { +static inline uint32_t ao_profile_tick(void) { uint16_t hi, lo, second_hi; do { diff --git a/src/stm/ao_spi_stm_slave.c b/src/stm/ao_spi_stm_slave.c index 98022442..962ff2c6 100644 --- a/src/stm/ao_spi_stm_slave.c +++ b/src/stm/ao_spi_stm_slave.c @@ -97,7 +97,6 @@ ao_spi_slave_send(void *block, uint16_t len) ao_dma_done_transfer(miso_dma_index); } - uint8_t ao_spi_slave_recv(void *block, uint16_t len) { @@ -153,6 +152,7 @@ ao_spi_slave_recv(void *block, uint16_t len) ao_dma_done_transfer(mosi_dma_index); ao_dma_done_transfer(miso_dma_index); + return 1; } static void diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h index ff3f5336..302f4d24 100644 --- a/src/stm/stm32l.h +++ b/src/stm/stm32l.h @@ -52,7 +52,7 @@ stm_moder_set(struct stm_gpio *gpio, int pin, vuint32_t value) { value << STM_MODER_SHIFT(pin)); } -static inline vuint32_t +static inline uint32_t stm_moder_get(struct stm_gpio *gpio, int pin) { return (gpio->moder >> STM_MODER_SHIFT(pin)) & STM_MODER_MASK; } @@ -69,7 +69,7 @@ stm_otyper_set(struct stm_gpio *gpio, int pin, vuint32_t value) { value << STM_OTYPER_SHIFT(pin)); } -static inline vuint32_t +static inline uint32_t stm_otyper_get(struct stm_gpio *gpio, int pin) { return (gpio->otyper >> STM_OTYPER_SHIFT(pin)) & STM_OTYPER_MASK; } @@ -88,7 +88,7 @@ stm_ospeedr_set(struct stm_gpio *gpio, int pin, vuint32_t value) { value << STM_OSPEEDR_SHIFT(pin)); } -static inline vuint32_t +static inline uint32_t stm_ospeedr_get(struct stm_gpio *gpio, int pin) { return (gpio->ospeedr >> STM_OSPEEDR_SHIFT(pin)) & STM_OSPEEDR_MASK; } diff --git a/src/telelco-v0.2/ao_lco.c b/src/telelco-v0.2/ao_lco.c index e8d16ca9..0bbb76f1 100644 --- a/src/telelco-v0.2/ao_lco.c +++ b/src/telelco-v0.2/ao_lco.c @@ -37,7 +37,6 @@ static uint8_t ao_lco_debug; #define AO_LCO_BOX_DIGIT_10 2 static uint8_t ao_lco_min_box, ao_lco_max_box; -static uint8_t ao_lco_mutex; static uint8_t ao_lco_pad; static uint8_t ao_lco_box; static uint8_t ao_lco_armed; @@ -281,12 +280,9 @@ static void ao_lco_igniter_status(void) { uint8_t c; - uint16_t delay; for (;;) { -// ao_alarm(delay); ao_sleep(&ao_pad_query); -// ao_clear_alarm(); if (!ao_lco_valid) { ao_led_on(AO_LED_RED); ao_led_off(AO_LED_GREEN|AO_LED_AMBER); -- cgit v1.2.3 From 4ed108fb86676daea17264d7159c2cff9ea7a6e4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:45:56 -0800 Subject: altos/stm: Turn on -Wextra All of the warnings for STM projects are cleaned up now Signed-off-by: Keith Packard --- src/stm/Makefile.defs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/stm') diff --git a/src/stm/Makefile.defs b/src/stm/Makefile.defs index d0e5a699..1e31e590 100644 --- a/src/stm/Makefile.defs +++ b/src/stm/Makefile.defs @@ -24,7 +24,7 @@ include $(TOPDIR)/Makedefs CC=$(ARM_CC) LIBS=$(PDCLIB_LIBS_M3) -lgcc -WARN_FLAGS=-Wall +WARN_FLAGS=-Wall -Wextra AO_CFLAGS=-I. -I../stm -I../core -I../drivers -I../math -I.. $(PDCLIB_INCLUDES) STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb \ -- cgit v1.2.3 From 9289200ccb661b10ff892760ecbc752c7745de6b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 23:04:43 -0800 Subject: altos: Turn on -Werror for STM and LPC builds Now that the build completes with no warnings, make future warnings into errors. Signed-off-by: Keith Packard --- src/lpc/Makefile-lpc.defs | 2 +- src/stm/Makefile.defs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/stm') diff --git a/src/lpc/Makefile-lpc.defs b/src/lpc/Makefile-lpc.defs index b9687196..dd2bf0e6 100644 --- a/src/lpc/Makefile-lpc.defs +++ b/src/lpc/Makefile-lpc.defs @@ -26,7 +26,7 @@ endif ELFTOHEX=$(TOPDIR)/../ao-tools/ao-elftohex/ao-elftohex CC=$(ARM_CC) -WARN_FLAGS=-Wall -Wextra +WARN_FLAGS=-Wall -Wextra -Werror AO_CFLAGS=-I. -I$(TOPDIR)/lpc -I$(TOPDIR)/core -I$(TOPDIR)/drivers -I$(TOPDIR)/product -I$(TOPDIR) $(PDCLIB_INCLUDES) LPC_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m0 -mthumb\ diff --git a/src/stm/Makefile.defs b/src/stm/Makefile.defs index 1e31e590..42adfd09 100644 --- a/src/stm/Makefile.defs +++ b/src/stm/Makefile.defs @@ -24,7 +24,7 @@ include $(TOPDIR)/Makedefs CC=$(ARM_CC) LIBS=$(PDCLIB_LIBS_M3) -lgcc -WARN_FLAGS=-Wall -Wextra +WARN_FLAGS=-Wall -Wextra -Werror AO_CFLAGS=-I. -I../stm -I../core -I../drivers -I../math -I.. $(PDCLIB_INCLUDES) STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb \ -- cgit v1.2.3 From c743eaa060080a7bd236466b93cff3abc96f405b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Jan 2014 12:40:26 -0800 Subject: altos: Report battery, apogee and main voltages over APRS This makes APRS more usable when you mute the RF audio on the HT. Signed-off-by: Keith Packard --- src/core/ao.h | 11 +++++ src/core/ao_convert_volt.c | 33 +++++++++++++++ src/drivers/ao_aprs.c | 94 +++++++++++++------------------------------ src/stm/ao_arch.h | 3 ++ src/telemega-v0.1/Makefile | 1 + src/telemega-v0.1/ao_pins.h | 17 ++++++++ src/telemega-v1.0/Makefile | 1 + src/telemetrum-v2.0/Makefile | 1 + src/telemetrum-v2.0/ao_pins.h | 17 ++++++++ 9 files changed, 113 insertions(+), 65 deletions(-) create mode 100644 src/core/ao_convert_volt.c (limited to 'src/stm') diff --git a/src/core/ao.h b/src/core/ao.h index 0b634a79..29ad2603 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -307,6 +307,17 @@ ao_altitude_to_pa(alt_t alt); #include #endif +/* + * ao_convert_volt.c + * + * Convert ADC readings to decivolts + */ + +int16_t +ao_battery_decivolt(int16_t adc); + +int16_t +ao_ignite_decivolt(int16_t adc); /* * ao_spi_slave.c diff --git a/src/core/ao_convert_volt.c b/src/core/ao_convert_volt.c new file mode 100644 index 00000000..8556d423 --- /dev/null +++ b/src/core/ao_convert_volt.c @@ -0,0 +1,33 @@ +/* + * Copyright © 2014 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" + +#define scale(v,p,m) ((int32_t) (v) * (AO_ADC_REFERENCE_DV * ((p) + (m))) / (AO_ADC_MAX * (m))) + +int16_t +ao_battery_decivolt(int16_t adc) +{ + return scale(adc, AO_BATTERY_DIV_PLUS, AO_BATTERY_DIV_MINUS); +} + +int16_t +ao_ignite_decivolt(int16_t adc) +{ + return scale(adc, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS); +} + diff --git a/src/drivers/ao_aprs.c b/src/drivers/ao_aprs.c index 96e90f00..56d98437 100644 --- a/src/drivers/ao_aprs.c +++ b/src/drivers/ao_aprs.c @@ -488,6 +488,28 @@ static void tncCompressInt(uint8_t *dest, int32_t value, int len) { } } +#if HAS_ADC +static int tncComment(uint8_t *buf) +{ + struct ao_data packet; + + ao_arch_critical(ao_data_get(&packet);); + + int16_t battery = ao_battery_decivolt(packet.adc.v_batt); + int16_t apogee = ao_ignite_decivolt(AO_SENSE_DROGUE(&packet)); + int16_t main = ao_ignite_decivolt(AO_SENSE_MAIN(&packet)); + + return sprintf((char *) buf, + "B:%d.%d A:%d.%d M:%d.%d", + battery/10, + battery % 10, + apogee/10, + apogee%10, + main/10, + main%10); +} +#endif + /** * Generate the plain text position packet. */ @@ -502,72 +524,8 @@ static int tncPositionPacket(void) altitude = 0; altitude = (altitude * (int32_t) 10000 + (3048/2)) / (int32_t) 3048; -#if 0 - char lat_sign = 'N', lon_sign = 'E'; - uint16_t lat_deg; - uint16_t lon_deg; - uint16_t lat_min; - uint16_t lat_frac; - uint16_t lon_min; - uint16_t lon_frac; - - if (latitude < 0) { - lat_sign = 'S'; - latitude = -latitude; - } - - if (longitude < 0) { - lon_sign = 'W'; - longitude = -longitude; - } - - /* Round latitude and longitude by 0.005 minutes */ - latitude = latitude + 833; - if (latitude > 900000000) - latitude = 900000000; - longitude = longitude + 833; - if (longitude > 1800000000) - longitude = 1800000000; - - lat_deg = latitude / 10000000; - latitude -= lat_deg * 10000000; - latitude *= 60; - lat_min = latitude / 10000000; - latitude -= lat_min * 10000000; - lat_frac = latitude / 100000; - - lon_deg = longitude / 10000000; - longitude -= lon_deg * 10000000; - longitude *= 60; - lon_min = longitude / 10000000; - longitude -= lon_min * 10000000; - lon_frac = longitude / 100000; - -#if 0 - return sprintf ((char *) tncBuffer, "=%02u%02u.%02u%c\\%03u%02u.%02u%cO /A=%06u\015", - lat_deg, lat_min, lat_frac, lat_sign, - lon_deg, lon_min, lon_frac, lon_sign, - altitude); -#endif - - return sprintf ((char *) tncBuffer, "/%02u%02u%02uh%02u%02u.%02u%c/%03u%02u.%02u%c'/A=%06u\015", - ao_gps_data.hour, - ao_gps_data.minute, - ao_gps_data.second, - lat_deg, lat_min, lat_frac, lat_sign, - lon_deg, lon_min, lon_frac, lon_sign, - altitude); -#endif buf = tncBuffer; -#if APRS_TIME - sprintf ((char *) buf, "/%02u%02u%02uh", - ao_gps_data.hour, - ao_gps_data.minute, - ao_gps_data.second); - buf += 8; -#else *buf++ = '!'; -#endif /* Symbol table ID */ *buf++ = '/'; @@ -591,7 +549,13 @@ static int tncPositionPacket(void) buf += 2; *buf++ = 33 + ((1 << 5) | (2 << 3)); - *buf++ = '\0'; + +#if HAS_ADC + buf += tncComment(buf); +#else + *buf = '\0'; +#endif + return buf - tncBuffer; } diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h index 42fe727a..76fa9194 100644 --- a/src/stm/ao_arch.h +++ b/src/stm/ao_arch.h @@ -135,6 +135,9 @@ extern const uint32_t ao_radio_cal; void ao_adc_init(); +/* ADC maximum reported value */ +#define AO_ADC_MAX 4095 + #define AO_BOOT_APPLICATION_BASE ((uint32_t *) 0x08001000) #define AO_BOOT_LOADER_BASE ((uint32_t *) 0x0) #define HAS_BOOT_LOADER 1 diff --git a/src/telemega-v0.1/Makefile b/src/telemega-v0.1/Makefile index 35f28b30..28ed7c98 100644 --- a/src/telemega-v0.1/Makefile +++ b/src/telemega-v0.1/Makefile @@ -100,6 +100,7 @@ ALTOS_SRC = \ ao_i2c_stm.c \ ao_mpu6000.c \ ao_convert_pa.c \ + ao_convert_volt.c \ ao_log.c \ ao_log_mega.c \ ao_sample.c \ diff --git a/src/telemega-v0.1/ao_pins.h b/src/telemega-v0.1/ao_pins.h index daeb9f17..db397c66 100644 --- a/src/telemega-v0.1/ao_pins.h +++ b/src/telemega-v0.1/ao_pins.h @@ -249,6 +249,23 @@ struct ao_adc { #define AO_ADC_SQ8 AO_ADC_V_PBATT #define AO_ADC_SQ9 AO_ADC_TEMP +/* + * Voltage divider on ADC battery sampler + */ +#define AO_BATTERY_DIV_PLUS 56 /* 5.6k */ +#define AO_BATTERY_DIV_MINUS 100 /* 10k */ + +/* + * Voltage divider on ADC igniter samplers + */ +#define AO_IGNITE_DIV_PLUS 100 /* 100k */ +#define AO_IGNITE_DIV_MINUS 27 /* 27k */ + +/* + * ADC reference in decivolts + */ +#define AO_ADC_REFERENCE_DV 33 + /* * Pressure sensor settings */ diff --git a/src/telemega-v1.0/Makefile b/src/telemega-v1.0/Makefile index b5c1f402..7a0c1195 100644 --- a/src/telemega-v1.0/Makefile +++ b/src/telemega-v1.0/Makefile @@ -101,6 +101,7 @@ ALTOS_SRC = \ ao_i2c_stm.c \ ao_mpu6000.c \ ao_convert_pa.c \ + ao_convert_volt.c \ ao_log.c \ ao_log_mega.c \ ao_sample.c \ diff --git a/src/telemetrum-v2.0/Makefile b/src/telemetrum-v2.0/Makefile index 0b9e6914..83a364dc 100644 --- a/src/telemetrum-v2.0/Makefile +++ b/src/telemetrum-v2.0/Makefile @@ -76,6 +76,7 @@ ALTOS_SRC = \ ao_eeprom_stm.c \ ao_report.c \ ao_convert_pa.c \ + ao_convert_volt.c \ ao_log.c \ ao_log_metrum.c \ ao_sample.c \ diff --git a/src/telemetrum-v2.0/ao_pins.h b/src/telemetrum-v2.0/ao_pins.h index 02f0f5e3..1b5cedc7 100644 --- a/src/telemetrum-v2.0/ao_pins.h +++ b/src/telemetrum-v2.0/ao_pins.h @@ -189,6 +189,23 @@ struct ao_adc { #define AO_ADC_SQ3 AO_ADC_V_BATT #define AO_ADC_SQ4 AO_ADC_TEMP +/* + * Voltage divider on ADC battery sampler + */ +#define AO_BATTERY_DIV_PLUS 56 /* 5.6k */ +#define AO_BATTERY_DIV_MINUS 100 /* 10k */ + +/* + * Voltage divider on ADC igniter samplers + */ +#define AO_IGNITE_DIV_PLUS 100 /* 100k */ +#define AO_IGNITE_DIV_MINUS 27 /* 27k */ + +/* + * ADC reference in decivolts + */ +#define AO_ADC_REFERENCE_DV 33 + /* * GPS */ -- cgit v1.2.3