From 2a912dcde191e2f750845c464611641a5abdc28a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:04:53 -0800 Subject: altos: Execute self-test on MMA655X part This doesn't check for fine calibration, just makes sure the part is within the broad tolerances specified by the manufacturer. The subtle fix here was actually getting reset working -- there was a typo in the bitpattern definition which caused the reset to fail, making it hard to self-test the part, as self-test is only valid before the part is running. Signed-off-by: Keith Packard --- src/drivers/ao_mma655x.c | 124 ++++++++++++++++++++++++++++------------------- src/drivers/ao_mma655x.h | 8 +++ 2 files changed, 81 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/drivers/ao_mma655x.c b/src/drivers/ao_mma655x.c index ce83a5a3..c36858ad 100644 --- a/src/drivers/ao_mma655x.c +++ b/src/drivers/ao_mma655x.c @@ -20,14 +20,15 @@ #if HAS_MMA655X -#if 0 -#define PRINTD(...) do { printf ("\r%5u %s: ", ao_tick_count, __func__); printf(__VA_ARGS__); } while(0) +#define DEBUG 0 +#define DEBUG_LOW 1 +#define DEBUG_HIGH 2 +#if 1 +#define PRINTD(l, ...) do { if (DEBUG & (l)) { printf ("\r%5u %s: ", ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } } while(0) #else -#define PRINTD(...) +#define PRINTD(l,...) #endif -static uint8_t mma655x_configured; - uint8_t ao_mma655x_spi_index = AO_MMA655X_SPI_INDEX; static void @@ -53,7 +54,7 @@ ao_mma655x_restart(void) { ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, AO_MMA655X_CS, 1); /* Emperical testing on STM32L151 at 32MHz for this delay amount */ - for (i = 0; i < 9; i++) + for (i = 0; i < 10; i++) ao_arch_nop(); ao_gpio_set(AO_MMA655X_CS_PORT, AO_MMA655X_CS_PIN, AO_MMA655X_CS, 0); } @@ -72,15 +73,17 @@ ao_parity(uint8_t v) return p; } +#if 0 static void ao_mma655x_cmd(uint8_t d[2]) { ao_mma655x_start(); - PRINTD("\tSEND %02x %02x\n", d[0], d[1]); + PRINTD(DEBUG_LOW, "\tSEND %02x %02x\n", d[0], d[1]); ao_spi_duplex(d, d, 2, AO_MMA655X_SPI_INDEX); - PRINTD("\t\tRECV %02x %02x\n", d[0], d[1]); + PRINTD(DEBUG_LOW, "\t\tRECV %02x %02x\n", d[0], d[1]); ao_mma655x_stop(); } +#endif static uint8_t ao_mma655x_reg_read(uint8_t addr) @@ -97,6 +100,7 @@ ao_mma655x_reg_read(uint8_t addr) d[1] = 0x00; ao_spi_duplex(&d, &d, 2, AO_MMA655X_SPI_INDEX); ao_mma655x_stop(); + PRINTD(DEBUG_LOW, "read %x = %x %x\n", addr, d[0], d[1]); return d[1]; } @@ -105,6 +109,7 @@ ao_mma655x_reg_write(uint8_t addr, uint8_t value) { uint8_t d[2]; + PRINTD(DEBUG_LOW, "write %x %x\n", addr, value); addr |= (1 << 6); /* write mode */ d[0] = addr | (ao_parity(addr^value) << 7); d[1] = value; @@ -113,8 +118,6 @@ ao_mma655x_reg_write(uint8_t addr, uint8_t value) ao_mma655x_stop(); addr &= ~(1 << 6); - PRINTD("write %x %x = %x\n", - addr, value, ao_mma655x_reg_read(addr)); } static uint16_t @@ -131,14 +134,14 @@ ao_mma655x_value(void) (0 << 1) | /* Arm disabled */ (1 << 0)); /* Odd parity */ ao_mma655x_start(); - PRINTD("value SEND %02x %02x\n", d[0], d[1]); + PRINTD(DEBUG_LOW, "value SEND %02x %02x\n", d[0], d[1]); ao_spi_send(d, 2, AO_MMA655X_SPI_INDEX); ao_mma655x_restart(); d[0] = 0x80; d[1] = 0x00; ao_spi_duplex(d, d, 2, AO_MMA655X_SPI_INDEX); ao_mma655x_stop(); - PRINTD("value RECV %02x %02x\n", d[0], d[1]); + PRINTD(DEBUG_LOW, "value RECV %02x %02x\n", d[0], d[1]); v = (uint16_t) d[1] << 2; v |= d[0] >> 6; @@ -148,15 +151,16 @@ ao_mma655x_value(void) static void ao_mma655x_reset(void) { + PRINTD(DEBUG_HIGH, "reset\n"); ao_mma655x_reg_write(AO_MMA655X_DEVCTL, (0 << AO_MMA655X_DEVCTL_RES_1) | - (0 << AO_MMA655X_DEVCTL_RES_1)); + (0 << AO_MMA655X_DEVCTL_RES_0)); ao_mma655x_reg_write(AO_MMA655X_DEVCTL, (1 << AO_MMA655X_DEVCTL_RES_1) | - (1 << AO_MMA655X_DEVCTL_RES_1)); + (1 << AO_MMA655X_DEVCTL_RES_0)); ao_mma655x_reg_write(AO_MMA655X_DEVCTL, (0 << AO_MMA655X_DEVCTL_RES_1) | - (1 << AO_MMA655X_DEVCTL_RES_1)); + (1 << AO_MMA655X_DEVCTL_RES_0)); } #define DEVCFG_VALUE (\ @@ -169,54 +173,73 @@ ao_mma655x_reset(void) { (0 << AO_MMA655X_AXISCFG_LPF)) /* 100Hz 4-pole filter */ +#define AO_ST_TRIES 10 +#define AO_ST_DELAY AO_MS_TO_TICKS(100) + static void ao_mma655x_setup(void) { - uint8_t v; uint16_t a, a_st; - uint8_t stdefl; - uint8_t i; + int16_t st_change; + int tries; + uint8_t devstat; +#if 0 uint8_t s0, s1, s2, s3; - uint8_t pn; uint32_t lot; - uint16_t serial; - - - if (mma655x_configured) - return; - mma655x_configured = 1; - ao_delay(AO_MS_TO_TICKS(10)); /* Top */ - ao_mma655x_reset(); - ao_delay(AO_MS_TO_TICKS(10)); /* Top */ - (void) ao_mma655x_reg_read(AO_MMA655X_DEVSTAT); - v = ao_mma655x_reg_read(AO_MMA655X_DEVSTAT); - - /* Configure R/W register values. - * Most of them relate to the arming feature, which - * we don't use, so the only registers we need to - * write are DEVCFG and AXISCFG - */ +#endif - ao_mma655x_reg_write(AO_MMA655X_DEVCFG, - DEVCFG_VALUE | (0 << AO_MMA655X_DEVCFG_ENDINIT)); + for (tries = 0; tries < AO_ST_TRIES; tries++) { + ao_delay(AO_MS_TO_TICKS(10)); + ao_mma655x_reset(); + ao_delay(AO_MS_TO_TICKS(10)); - /* Test X axis - */ + devstat = ao_mma655x_reg_read(AO_MMA655X_DEVSTAT); + PRINTD(DEBUG_HIGH, "devstat %x\n", devstat); + + if (!(devstat & (1 << AO_MMA655X_DEVSTAT_DEVRES))) + continue; + + /* Configure R/W register values. + * Most of them relate to the arming feature, which + * we don't use, so the only registers we need to + * write are DEVCFG and AXISCFG + */ + + ao_mma655x_reg_write(AO_MMA655X_DEVCFG, + DEVCFG_VALUE | (0 << AO_MMA655X_DEVCFG_ENDINIT)); + + /* Test X axis + */ - ao_mma655x_reg_write(AO_MMA655X_AXISCFG, - AXISCFG_VALUE | - (1 << AO_MMA655X_AXISCFG_ST)); - a_st = ao_mma655x_value(); + ao_mma655x_reg_write(AO_MMA655X_AXISCFG, + AXISCFG_VALUE | + (1 << AO_MMA655X_AXISCFG_ST)); + ao_delay(AO_MS_TO_TICKS(10)); + + a_st = ao_mma655x_value(); + + ao_mma655x_reg_write(AO_MMA655X_AXISCFG, + AXISCFG_VALUE | + (0 << AO_MMA655X_AXISCFG_ST)); + + ao_delay(AO_MS_TO_TICKS(10)); + + a = ao_mma655x_value(); - stdefl = ao_mma655x_reg_read(AO_MMA655X_STDEFL); + st_change = a_st - a; - ao_mma655x_reg_write(AO_MMA655X_AXISCFG, - AXISCFG_VALUE | - (0 << AO_MMA655X_AXISCFG_ST)); - a = ao_mma655x_value(); + PRINTD(DEBUG_HIGH, "self test %d normal %d change %d\n", a_st, a, st_change); + + if (AO_ST_MIN <= st_change && st_change <= AO_ST_MAX) + break; + ao_delay(AO_ST_DELAY); + } + if (tries == AO_ST_TRIES) + ao_sensor_errors = 1; ao_mma655x_reg_write(AO_MMA655X_DEVCFG, DEVCFG_VALUE | (1 << AO_MMA655X_DEVCFG_ENDINIT)); +#if 0 s0 = ao_mma655x_reg_read(AO_MMA655X_SN0); s1 = ao_mma655x_reg_read(AO_MMA655X_SN1); s2 = ao_mma655x_reg_read(AO_MMA655X_SN2); @@ -226,6 +249,7 @@ ao_mma655x_setup(void) serial = lot & 0x1fff; lot >>= 12; pn = ao_mma655x_reg_read(AO_MMA655X_PN); +#endif } uint16_t ao_mma655x_current; @@ -259,8 +283,6 @@ static __xdata struct ao_task ao_mma655x_task; void ao_mma655x_init(void) { - mma655x_configured = 0; - ao_cmd_register(&ao_mma655x_cmds[0]); ao_spi_init_cs(AO_MMA655X_CS_PORT, (1 << AO_MMA655X_CS_PIN)); diff --git a/src/drivers/ao_mma655x.h b/src/drivers/ao_mma655x.h index 2d951e07..e57e3377 100644 --- a/src/drivers/ao_mma655x.h +++ b/src/drivers/ao_mma655x.h @@ -78,6 +78,14 @@ #define AO_MMA655X_COUNT 0x15 #define AO_MMA655X_OFFCORR 0x16 +/* + * Range of valid self-test difference from + * normal measurement + */ + +#define AO_ST_MIN 300 +#define AO_ST_MAX 800 + extern uint16_t ao_mma655x_current; void -- cgit v1.2.3 From c8b27410e45cc3d80ad4b896bffe70e9aec5e3aa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:06:52 -0800 Subject: altos: 3-axis accel calibration was invalid in explicit accel cal mode When explicit Z-axis accel calibration values were provided to the 'c a' command, the 3-axis accelerometer calibration values would get set to uninitialized values. Not so helpful. Signed-off-by: Keith Packard --- src/core/ao_config.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/core/ao_config.c b/src/core/ao_config.c index a30ec64a..4a1c58b9 100644 --- a/src/core/ao_config.c +++ b/src/core/ao_config.c @@ -353,9 +353,9 @@ ao_config_accel_calibrate_set(void) __reentrant { int16_t up, down; #if HAS_GYRO - int16_t accel_along_up, accel_along_down; - int16_t accel_across_up, accel_across_down; - int16_t accel_through_up, accel_through_down; + int16_t accel_along_up = 0, accel_along_down = 0; + int16_t accel_across_up = 0, accel_across_down = 0; + int16_t accel_through_up = 0, accel_through_down = 0; #endif ao_cmd_decimal(); @@ -390,9 +390,11 @@ ao_config_accel_calibrate_set(void) __reentrant ao_config.accel_plus_g = up; ao_config.accel_minus_g = down; #if HAS_GYRO - ao_config.accel_zero_along = (accel_along_up + accel_along_down) / 2; - ao_config.accel_zero_across = (accel_across_up + accel_across_down) / 2; - ao_config.accel_zero_through = (accel_through_up + accel_through_down) / 2; + if (ao_cmd_lex_i == 0) { + ao_config.accel_zero_along = (accel_along_up + accel_along_down) / 2; + ao_config.accel_zero_across = (accel_across_up + accel_across_down) / 2; + ao_config.accel_zero_through = (accel_through_up + accel_through_down) / 2; + } #endif _ao_config_edit_finish(); } -- cgit v1.2.3 From 758acb92cccbe4b64a35a1883b42713738c90630 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:08:11 -0800 Subject: altos: Complain about sensor self-test errors only in idle mode When the accelerometer says to go into pad mode, don't look for other sensor self test errors. Only look for sensor self test errors to choose between idle and invalid mode. This will prevent minor sensor self test errors from letting the rocket fly safely. Signed-off-by: Keith Packard --- src/core/ao_flight.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/core/ao_flight.c b/src/core/ao_flight.c index 463ff4a2..5918b997 100644 --- a/src/core/ao_flight.c +++ b/src/core/ao_flight.c @@ -104,9 +104,6 @@ ao_flight(void) ao_config.accel_minus_g == 0 || ao_ground_accel < ao_config.accel_plus_g - ACCEL_NOSE_UP || ao_ground_accel > ao_config.accel_minus_g + ACCEL_NOSE_UP || -#if HAS_IMU - ao_sensor_errors || -#endif ao_ground_height < -1000 || ao_ground_height > 7000) { @@ -152,7 +149,11 @@ ao_flight(void) #endif } else { /* Set idle mode */ - ao_flight_state = ao_flight_idle; + ao_flight_state = ao_flight_idle; +#if HAS_IMU + if (ao_sensor_errors) + ao_flight_state = ao_flight_invalid; +#endif #if HAS_ACCEL && HAS_RADIO && PACKET_HAS_SLAVE /* Turn on packet system in idle mode on TeleMetrum */ -- cgit v1.2.3 From 755082d36231c1b247bc0e1f13919dd9b5c362a8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:13:32 -0800 Subject: altos: mma655x also needs ao_sensor_errors TeleMetrum has an MMA655X but no IMU, so it needs an explicit addition for sensor errors. Signed-off-by: Keith Packard --- src/core/ao_flight.c | 4 ++-- src/core/ao_flight.h | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/ao_flight.c b/src/core/ao_flight.c index 5918b997..aac6880d 100644 --- a/src/core/ao_flight.c +++ b/src/core/ao_flight.c @@ -46,7 +46,7 @@ __pdata enum ao_flight_state ao_flight_state; /* current flight state */ __pdata uint16_t ao_boost_tick; /* time of launch detect */ __pdata uint16_t ao_motor_number; /* number of motors burned so far */ -#if HAS_IMU +#if HAS_SENSOR_ERRORS /* Any sensor can set this to mark the flight computer as 'broken' */ __xdata uint8_t ao_sensor_errors; #endif @@ -150,7 +150,7 @@ ao_flight(void) } else { /* Set idle mode */ ao_flight_state = ao_flight_idle; -#if HAS_IMU +#if HAS_SENSOR_ERRORS if (ao_sensor_errors) ao_flight_state = ao_flight_invalid; #endif diff --git a/src/core/ao_flight.h b/src/core/ao_flight.h index c7c02ccf..01d21c11 100644 --- a/src/core/ao_flight.h +++ b/src/core/ao_flight.h @@ -41,7 +41,11 @@ extern __pdata enum ao_flight_state ao_flight_state; extern __pdata uint16_t ao_boost_tick; extern __pdata uint16_t ao_motor_number; -#if HAS_IMU +#if HAS_IMU || HAS_MMA655X +#define HAS_SENSOR_ERRORS 1 +#endif + +#if HAS_SENSOR_ERRORS extern __xdata uint8_t ao_sensor_errors; #endif -- cgit v1.2.3 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/core/ao_gps_report_mega.c | 1 - src/core/ao_ignite.c | 4 ++++ src/core/ao_telemetry.c | 1 - src/drivers/ao_cc1120.c | 10 ++++------ src/drivers/ao_hmc5883.c | 1 - src/drivers/ao_mpu6000.c | 1 - src/stm/ao_adc_stm.c | 4 +++- src/stm/ao_i2c_stm.c | 6 ------ src/stm/ao_usb_stm.c | 4 ---- 9 files changed, 11 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/core/ao_gps_report_mega.c b/src/core/ao_gps_report_mega.c index d13885dd..07a2bc5b 100644 --- a/src/core/ao_gps_report_mega.c +++ b/src/core/ao_gps_report_mega.c @@ -24,7 +24,6 @@ ao_gps_report_mega(void) static __xdata struct ao_log_mega gps_log; static __xdata struct ao_telemetry_location gps_data; static __xdata struct ao_telemetry_satellite gps_tracking_data; - uint8_t date_reported = 0; uint8_t new; uint8_t c, n, i; diff --git a/src/core/ao_ignite.c b/src/core/ao_ignite.c index 9f2ec0a7..823d003c 100644 --- a/src/core/ao_ignite.c +++ b/src/core/ao_ignite.c @@ -114,6 +114,8 @@ ao_igniter_fire(enum ao_igniter igniter) ao_delay(AO_IGNITER_FIRE_TIME); AO_IGNITER_SET_MAIN(0); break; + default: + break; } break; case AO_IGNITE_MODE_MAIN: @@ -127,6 +129,8 @@ ao_igniter_fire(enum ao_igniter igniter) ao_delay(AO_IGNITER_FIRE_TIME); AO_IGNITER_SET_MAIN(0); break; + default: + break; } break; } diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c index c118d007..e529b717 100644 --- a/src/core/ao_telemetry.c +++ b/src/core/ao_telemetry.c @@ -473,7 +473,6 @@ ao_telemetry(void) } else time = ao_time(); - bottom: ; } } } diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index 37d04927..3429768b 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -152,6 +152,7 @@ ao_radio_strobe(uint8_t addr) return in; } +#if 0 static uint8_t ao_radio_fifo_read(uint8_t *data, uint8_t len) { @@ -166,6 +167,7 @@ ao_radio_fifo_read(uint8_t *data, uint8_t len) ao_radio_deselect(); return status; } +#endif static uint8_t ao_radio_fifo_write_start(void) @@ -207,11 +209,13 @@ ao_radio_tx_fifo_space(void) return CC1120_FIFO_SIZE - ao_radio_reg_read(CC1120_NUM_TXBYTES); } +#if 0 static uint8_t ao_radio_status(void) { return ao_radio_strobe (CC1120_SNOP); } +#endif void ao_radio_recv_abort(void) @@ -751,13 +755,11 @@ static uint8_t tx_data[(AO_RADIO_MAX_SEND + 4) * 2]; void ao_radio_send(const void *d, uint8_t size) { - uint8_t marc_status; uint8_t *e = tx_data; uint8_t encode_len; uint8_t this_len; uint8_t started = 0; uint8_t fifo_space; - uint8_t q; encode_len = ao_fec_encode(d, size, tx_data); @@ -948,11 +950,9 @@ uint8_t ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout) { uint8_t len; - uint16_t i; uint8_t radio_rssi = 0; uint8_t rssi0; uint8_t ret; - static int been_here = 0; size -= 2; /* status bytes */ if (size > AO_RADIO_MAX_RECV) { @@ -1334,8 +1334,6 @@ static const struct ao_cmds ao_radio_cmds[] = { void ao_radio_init(void) { - int i; - ao_radio_configured = 0; ao_spi_init_cs (AO_CC1120_SPI_CS_PORT, (1 << AO_CC1120_SPI_CS_PIN)); diff --git a/src/drivers/ao_hmc5883.c b/src/drivers/ao_hmc5883.c index 782d03f4..2d217bcf 100644 --- a/src/drivers/ao_hmc5883.c +++ b/src/drivers/ao_hmc5883.c @@ -70,7 +70,6 @@ ao_hmc5883_sample(struct ao_hmc5883_sample *sample) { uint16_t *d = (uint16_t *) sample; int i = sizeof (*sample) / 2; - uint8_t single = HMC5883_MODE_SINGLE; ao_hmc5883_done = 0; ao_exti_enable(AO_HMC5883_INT_PORT, AO_HMC5883_INT_PIN); diff --git a/src/drivers/ao_mpu6000.c b/src/drivers/ao_mpu6000.c index f8ce7346..0689d7a7 100644 --- a/src/drivers/ao_mpu6000.c +++ b/src/drivers/ao_mpu6000.c @@ -21,7 +21,6 @@ #if HAS_MPU6000 -static uint8_t ao_mpu6000_wake; static uint8_t ao_mpu6000_configured; #ifndef AO_MPU6000_I2C_INDEX 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') 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') 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 316d898715746a379068ac8511692bdb9da14b39 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:44:20 -0800 Subject: altos: unsigned value in ao_pyro_set checked for negative value No sense checking unsigned values for less than zero. Signed-off-by: Keith Packard --- src/core/ao_pyro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/ao_pyro.c b/src/core/ao_pyro.c index a260aa99..e59f5bc4 100644 --- a/src/core/ao_pyro.c +++ b/src/core/ao_pyro.c @@ -436,7 +436,7 @@ ao_pyro_set(void) if (ao_cmd_status != ao_cmd_success) return; p = ao_cmd_lex_i; - if (p < 0 || AO_PYRO_NUM <= p) { + if (AO_PYRO_NUM <= p) { printf ("invalid pyro channel %d\n", p); return; } -- cgit v1.2.3 From 1406a5b0721a135913a9801e9eea9e91f0a536b4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:45:01 -0800 Subject: altos: Add default button return value from ao_button_get This "can't" happen, but it's not unreasonable to have a default return value. Signed-off-by: Keith Packard --- src/drivers/ao_button.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/drivers/ao_button.c b/src/drivers/ao_button.c index 25c0cd5c..cdf07352 100644 --- a/src/drivers/ao_button.c +++ b/src/drivers/ao_button.c @@ -59,6 +59,7 @@ _ao_button_get(struct ao_debounce *debounce) case 4: return ao_button_value(4); #endif } + return 0; } static void -- 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') 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 e11fcc299f4a1a0461a3442ca13f8984d76c30ff Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:58:10 -0800 Subject: altos: Clean up warnings for LPC products Unused varibles, functions and parameters. Signed-off-by: Keith Packard --- src/core/ao_log.c | 2 ++ src/core/ao_log_mini.c | 4 ++-- src/core/ao_notask.c | 1 + src/core/ao_telemetry.c | 2 +- src/drivers/ao_cc115l.c | 26 +++++++++++--------------- src/lpc/ao_adc_lpc.c | 2 ++ src/lpc/ao_spi_lpc.c | 2 -- src/lpc/ao_usb_lpc.c | 10 ++++++++-- src/product/ao_flash_task.c | 1 + 9 files changed, 28 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/core/ao_log.c b/src/core/ao_log.c index 701c81ab..20febefe 100644 --- a/src/core/ao_log.c +++ b/src/core/ao_log.c @@ -196,7 +196,9 @@ ao_log_full(void) return ao_log_current_pos == ao_log_end_pos; } +#if HAS_ADC static __xdata struct ao_task ao_log_task; +#endif void ao_log_list(void) __reentrant diff --git a/src/core/ao_log_mini.c b/src/core/ao_log_mini.c index 99a85982..29e3bd9f 100644 --- a/src/core/ao_log_mini.c +++ b/src/core/ao_log_mini.c @@ -78,7 +78,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_mini))] ; void ao_log(void) { - __pdata uint16_t next_sensor, next_other; + __pdata uint16_t next_sensor; ao_storage_setup(); @@ -99,7 +99,7 @@ ao_log(void) * when starting up. */ ao_log_data_pos = ao_data_ring_next(ao_data_head); - next_other = next_sensor = ao_data_ring[ao_log_data_pos].tick; + next_sensor = ao_data_ring[ao_log_data_pos].tick; ao_log_state = ao_flight_startup; for (;;) { /* Write samples to EEPROM */ diff --git a/src/core/ao_notask.c b/src/core/ao_notask.c index a41712d2..6f967e6d 100644 --- a/src/core/ao_notask.c +++ b/src/core/ao_notask.c @@ -41,5 +41,6 @@ ao_sleep(__xdata void *wchan) void ao_wakeup(__xdata void *wchan) { + (void) wchan; ao_wchan = 0; } diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c index 86158063..5a00d825 100644 --- a/src/core/ao_telemetry.c +++ b/src/core/ao_telemetry.c @@ -24,9 +24,9 @@ #endif static __pdata uint16_t ao_telemetry_interval; -static __pdata uint8_t ao_rdf = 0; #if HAS_RDF +static __pdata uint8_t ao_rdf = 0; static __pdata uint16_t ao_rdf_time; #endif diff --git a/src/drivers/ao_cc115l.c b/src/drivers/ao_cc115l.c index 0fa1e899..5d4f3bd6 100644 --- a/src/drivers/ao_cc115l.c +++ b/src/drivers/ao_cc115l.c @@ -29,8 +29,6 @@ static uint8_t ao_radio_fifo; /* fifo drained interrupt received */ static uint8_t ao_radio_done; /* tx done interrupt received */ static uint8_t ao_radio_wake; /* sleep address for radio interrupts */ static uint8_t ao_radio_abort; /* radio operation should abort */ -static uint8_t ao_radio_mcu_wake; /* MARC status change */ -static uint8_t ao_radio_marcstate; /* Last read MARC state value */ /* Debugging commands */ #define CC115L_DEBUG 0 @@ -106,7 +104,6 @@ static uint8_t ao_radio_reg_read(uint8_t addr) { uint8_t data[1]; - uint8_t d; data[0] = ((1 << CC115L_READ) | (0 << CC115L_BURST) | @@ -123,7 +120,6 @@ static void ao_radio_reg_write(uint8_t addr, uint8_t value) { uint8_t data[2]; - uint8_t d; trace_add(trace_write, addr, value, NULL); data[0] = ((0 << CC115L_READ) | @@ -135,11 +131,11 @@ ao_radio_reg_write(uint8_t addr, uint8_t value) ao_radio_deselect(); } +#if UNUSED static void ao_radio_burst_read_start (uint16_t addr) { uint8_t data[1]; - uint8_t d; data[0] = ((1 << CC115L_READ) | (1 << CC115L_BURST) | @@ -153,6 +149,7 @@ ao_radio_burst_read_stop (void) { ao_radio_deselect(); } +#endif static uint8_t @@ -200,19 +197,23 @@ ao_radio_tx_fifo_space(void) return CC115L_FIFO_SIZE - (ao_radio_reg_read(CC115L_TXBYTES) & CC115L_TXBYTES_NUM_TX_BYTES_MASK); } +#if UNUSED static uint8_t ao_radio_status(void) { return ao_radio_strobe (CC115L_SNOP); } +#endif #define ao_radio_rdf_value 0x55 +#if UNUSED static uint8_t ao_radio_get_marcstate(void) { return ao_radio_reg_read(CC115L_MARCSTATE) & CC115L_MARCSTATE_MASK; } +#endif static void ao_radio_done_isr(void) @@ -232,11 +233,6 @@ ao_radio_fifo_isr(void) ao_wakeup(&ao_radio_wake); } -static void -ao_radio_start_tx(void) -{ -} - static void ao_radio_idle(void) { @@ -401,7 +397,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; @@ -466,7 +462,7 @@ static uint8_t ao_radio_configured = 0; static void ao_radio_setup(void) { - int i; + unsigned int i; ao_radio_strobe(CC115L_SRES); ao_delay(AO_MS_TO_TICKS(10)); @@ -730,8 +726,6 @@ ao_radio_send_fill(uint8_t *buf, int16_t len) void ao_radio_send(const void *d, uint8_t size) { - int i; - ao_radio_get(); ao_radio_send_len = ao_fec_encode(d, size, tx_data); ao_radio_send_buf = tx_data; @@ -912,7 +906,6 @@ static void ao_radio_packet(void) { ao_radio_send(packet, sizeof (packet)); } -#endif /* CC115L_DEBUG */ #if HAS_APRS #include @@ -926,6 +919,7 @@ ao_radio_aprs() ao_aprs_send(); } #endif +#endif /* CC115L_DEBUG */ static const struct ao_cmds ao_radio_cmds[] = { { ao_radio_test_cmd, "C <1 start, 0 stop, none both>\0Radio carrier test" }, @@ -943,7 +937,9 @@ static const struct ao_cmds ao_radio_cmds[] = { void ao_radio_init(void) { +#if 0 int i; +#endif ao_radio_configured = 0; ao_spi_init_cs (AO_CC115L_SPI_CS_PORT, (1 << AO_CC115L_SPI_CS_PIN)); diff --git a/src/lpc/ao_adc_lpc.c b/src/lpc/ao_adc_lpc.c index 7005f86e..e1aae0e4 100644 --- a/src/lpc/ao_adc_lpc.c +++ b/src/lpc/ao_adc_lpc.c @@ -149,8 +149,10 @@ static void ao_adc_dump(void) __reentrant { struct ao_data packet; +#ifndef AO_ADC_DUMP int16_t *d; uint8_t i; +#endif ao_data_get(&packet); #ifdef AO_ADC_DUMP diff --git a/src/lpc/ao_spi_lpc.c b/src/lpc/ao_spi_lpc.c index a889137c..e72b8286 100644 --- a/src/lpc/ao_spi_lpc.c +++ b/src/lpc/ao_spi_lpc.c @@ -21,8 +21,6 @@ static uint8_t ao_spi_mutex[LPC_NUM_SPI]; static struct lpc_ssp * const ao_lpc_ssp[LPC_NUM_SPI] = { &lpc_ssp0, &lpc_ssp1 }; -static uint8_t spi_dev_null; - #define tx_busy(lpc_ssp) (lpc_ssp->sr & ((1 << LPC_SSP_SR_BSY) | (1 << LPC_SSP_SR_TNF))) != (1 << LPC_SSP_SR_TNF) #define rx_busy(lpc_ssp) (lpc_ssp->sr & ((1 << LPC_SSP_SR_BSY) | (1 << LPC_SSP_SR_RNE))) != (1 << LPC_SSP_SR_RNE) diff --git a/src/lpc/ao_usb_lpc.c b/src/lpc/ao_usb_lpc.c index 686dc3a4..d02ccdd6 100644 --- a/src/lpc/ao_usb_lpc.c +++ b/src/lpc/ao_usb_lpc.c @@ -111,7 +111,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 @@ -246,11 +245,13 @@ ao_usb_epn_in(uint8_t n) return &lpc_usb_endpoint.epn[n-1].in[0]; } +#if UNUSED static void ao_usb_set_epn_in(uint8_t n, uint8_t *addr, uint16_t nbytes) { ao_usb_set_ep(ao_usb_epn_in(n), addr, nbytes); } +#endif static void ao_usb_set_epn_out(uint8_t n, uint8_t *addr, uint16_t nbytes) @@ -633,11 +634,12 @@ ao_usb_ep0_handle(uint8_t receive) } } -static uint16_t control_count; +#if USB_DEBUG static uint16_t int_count; static uint16_t in_count; static uint16_t out_count; static uint16_t reset_count; +#endif void lpc_usb_irq_isr(void) @@ -665,7 +667,9 @@ lpc_usb_irq_isr(void) /* Handle OUT packets */ if (intstat & (1 << LPC_USB_INT_EPOUT(AO_USB_OUT_EP))) { +#if USB_DEBUG ++out_count; +#endif _rx_dbg1("RX ISR", *ao_usb_epn_out(AO_USB_OUT_EP)); ao_usb_out_avail = 1; _rx_dbg0("out avail set"); @@ -675,7 +679,9 @@ lpc_usb_irq_isr(void) /* Handle IN packets */ if (intstat & (1 << LPC_USB_INT_EPIN(AO_USB_IN_EP))) { +#if USB_DEBUG ++in_count; +#endif _tx_dbg1("TX ISR", *ao_usb_epn_in(AO_USB_IN_EP)); ao_usb_in_pending = 0; ao_wakeup(&ao_usb_in_pending); diff --git a/src/product/ao_flash_task.c b/src/product/ao_flash_task.c index 4cfbf75f..6cb308e1 100644 --- a/src/product/ao_flash_task.c +++ b/src/product/ao_flash_task.c @@ -24,6 +24,7 @@ void ao_panic(uint8_t reason) { + (void) reason; } void -- cgit v1.2.3 From 48f996a9d65631238b4de446530f31f83acb99f5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 22:59:42 -0800 Subject: altos: cc115l driver tone_run wasn't recording number of tones This would prevent the cc115l driver from ever sending tones. Signed-off-by: Keith Packard --- src/drivers/ao_cc115l.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/drivers/ao_cc115l.c b/src/drivers/ao_cc115l.c index 5d4f3bd6..f0f72d4d 100644 --- a/src/drivers/ao_cc115l.c +++ b/src/drivers/ao_cc115l.c @@ -564,6 +564,7 @@ ao_radio_tone_run(struct ao_radio_tone *tones, int ntones) ao_radio_tone = tones; ao_radio_tone_current = 0; ao_radio_tone_offset = 0; + ao_radio_tone_count = ntones; _ao_radio_send_lots(ao_radio_tone_fill, AO_RADIO_MODE_RDF); ao_radio_put(); } -- cgit v1.2.3 From 14790172e02d4e1624c35797f87ffd94345d54ff Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 23:00:43 -0800 Subject: altos: lpc exti setup was incorrectly testing mode Check for NOCONFIGURE bit was missing parens Signed-off-by: Keith Packard --- src/lpc/ao_exti_lpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lpc/ao_exti_lpc.c b/src/lpc/ao_exti_lpc.c index 588cf58c..941aa965 100644 --- a/src/lpc/ao_exti_lpc.c +++ b/src/lpc/ao_exti_lpc.c @@ -91,7 +91,7 @@ ao_exti_setup (uint8_t port, uint8_t pin, uint8_t mode, void (*callback)(void)) if (pint == LPC_NUM_PINT) ao_panic(AO_PANIC_EXTI); - if (!mode & AO_EXTI_PIN_NOCONFIGURE) + if (!(mode & AO_EXTI_PIN_NOCONFIGURE)) ao_enable_input(port, pin, mode); ao_arch_block_interrupts(); -- cgit v1.2.3 From f578d9455eec9ea0eccd2d5e21349e274ea4281a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 23:02:21 -0800 Subject: altos/lpc: Missing */ in definition of PIO0_4 Would maek using these values pretty hard. Signed-off-by: Keith Packard --- src/lpc/lpc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lpc/lpc.h b/src/lpc/lpc.h index 3300c86f..9408ceab 100644 --- a/src/lpc/lpc.h +++ b/src/lpc/lpc.h @@ -120,7 +120,7 @@ extern struct lpc_ioconf lpc_ioconf; #define LPC_IOCONF_FUNC_PIO0_3 0 #define LPC_IOCONF_FUNC_USB_VBUS 1 -/* PIO0_4 +/* PIO0_4 */ #define LPC_IOCONF_FUNC_PIO0_4 0 #define LPC_IOCONF_FUNC_I2C_SCL 1 -- cgit v1.2.3 From 16b37b49985daf21ebb93b3d6ae64af67533be22 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 20 Dec 2013 23:02:51 -0800 Subject: altos: Turn on warnings for LPC products too Signed-off-by: Keith Packard --- src/lpc/Makefile-lpc.defs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lpc/Makefile-lpc.defs b/src/lpc/Makefile-lpc.defs index 3d55cf67..b9687196 100644 --- a/src/lpc/Makefile-lpc.defs +++ b/src/lpc/Makefile-lpc.defs @@ -26,8 +26,11 @@ endif ELFTOHEX=$(TOPDIR)/../ao-tools/ao-elftohex/ao-elftohex CC=$(ARM_CC) +WARN_FLAGS=-Wall -Wextra + 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 -ffreestanding -nostdlib $(AO_CFLAGS) +LPC_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m0 -mthumb\ + -ffreestanding -nostdlib $(AO_CFLAGS) $(WARN_FLAGS) NICKLE=nickle -- 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') 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 afc16e805145c3e9ab4ba948f9ab1d9aa2b27afb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 28 Dec 2013 10:18:53 -0800 Subject: altos: Add 'O' command for TeleMega orient testing Only present when HAS_FLIGHT_DEBUG is enabled, this command lets the user check the orientation tracking code by showing the current orientation and when the calibration values are reset. Signed-off-by: Keith Packard --- src/core/ao_flight.c | 9 +++++++++ src/core/ao_sample.c | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'src') diff --git a/src/core/ao_flight.c b/src/core/ao_flight.c index aac6880d..08302140 100644 --- a/src/core/ao_flight.c +++ b/src/core/ao_flight.c @@ -443,9 +443,18 @@ ao_gyro_test(void) ao_flight_state = ao_flight_idle; } +uint8_t ao_orient_test; + +static void +ao_orient_test_select(void) +{ + ao_orient_test = !ao_orient_test; +} + __code struct ao_cmds ao_flight_cmds[] = { { ao_flight_dump, "F\0Dump flight status" }, { ao_gyro_test, "G\0Test gyro code" }, + { ao_orient_test_select,"O\0Test orientation code" }, { 0, NULL }, }; #endif diff --git a/src/core/ao_sample.c b/src/core/ao_sample.c index adf8399d..34658951 100644 --- a/src/core/ao_sample.c +++ b/src/core/ao_sample.c @@ -92,6 +92,10 @@ __pdata int32_t ao_sample_roll_sum; static struct ao_quaternion ao_rotation; #endif +#if HAS_FLIGHT_DEBUG +extern uint8_t ao_orient_test; +#endif + static void ao_sample_preflight_add(void) { @@ -159,7 +163,11 @@ ao_sample_preflight_set(void) * that as the current rotation vector */ ao_quaternion_vectors_to_rotation(&ao_rotation, &up, &orient); +#if HAS_FLIGHT_DEBUG + if (ao_orient_test) + printf("\n\treset\n"); #endif +#endif nsamples = 0; } @@ -210,6 +218,17 @@ ao_sample_rotate(void) rotz = ao_rotation.z * ao_rotation.z - ao_rotation.y * ao_rotation.y - ao_rotation.x * ao_rotation.x + ao_rotation.r * ao_rotation.r; ao_sample_orient = acosf(rotz) * (float) (180.0/M_PI); + +#if HAS_FLIGHT_DEBUG + if (ao_orient_test) { + printf ("rot %d %d %d orient %d \r", + (int) (x * 1000), + (int) (y * 1000), + (int) (z * 1000), + ao_sample_orient); + } +#endif + } #endif -- cgit v1.2.3 From c35ea586b9e792c45b287924fd256928308d9a36 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 1 Jan 2014 21:12:20 -0800 Subject: altos: Flip acceleration data consistently for orientation changes Must flip the acceleration calibration data using the same function as flipping the actual acceleration data or the calibration will no longer be valid after changing orientation. For the MMA655x, this means using 4095 in both places, rather than using 0x7fff for the calibration data changes and 4095 for the data value changes. For the MPU6000, this means using 0 in both places. Signed-off-by: Keith Packard --- src/core/ao_config.c | 10 +++++++--- src/core/ao_data.h | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/core/ao_config.c b/src/core/ao_config.c index 590d8a49..4482f673 100644 --- a/src/core/ao_config.c +++ b/src/core/ao_config.c @@ -514,6 +514,10 @@ ao_config_pad_orientation_show(void) __reentrant printf("Pad orientation: %d\n", ao_config.pad_orientation); } +#ifndef AO_ACCEL_INVERT +#define AO_ACCEL_INVERT 0x7fff +#endif + void ao_config_pad_orientation_set(void) __reentrant { @@ -523,10 +527,10 @@ ao_config_pad_orientation_set(void) __reentrant _ao_config_edit_start(); ao_cmd_lex_i &= 1; if (ao_config.pad_orientation != ao_cmd_lex_i) { - uint16_t t; + int16_t t; t = ao_config.accel_plus_g; - ao_config.accel_plus_g = 0x7fff - ao_config.accel_minus_g; - ao_config.accel_minus_g = 0x7fff - t; + ao_config.accel_plus_g = AO_ACCEL_INVERT - ao_config.accel_minus_g; + ao_config.accel_minus_g = AO_ACCEL_INVERT - t; } ao_config.pad_orientation = ao_cmd_lex_i; _ao_config_edit_finish(); diff --git a/src/core/ao_data.h b/src/core/ao_data.h index e1d8a139..c4b062fd 100644 --- a/src/core/ao_data.h +++ b/src/core/ao_data.h @@ -273,14 +273,16 @@ typedef int16_t accel_t; /* MMA655X is hooked up so that positive values represent negative acceleration */ +#define AO_ACCEL_INVERT 4095 + #define ao_data_accel(packet) ((packet)->mma655x) #if AO_MMA655X_INVERT -#define ao_data_accel_cook(packet) (4095 - (packet)->mma655x) +#define ao_data_accel_cook(packet) (AO_ACCEL_INVERT - (packet)->mma655x) #else #define ao_data_accel_cook(packet) ((packet)->mma655x) #endif #define ao_data_set_accel(packet, accel) ((packet)->mma655x = (accel)) -#define ao_data_accel_invert(accel) (4095 - (accel)) +#define ao_data_accel_invert(accel) (AO_ACCEL_INVERT - (accel)) #endif @@ -288,6 +290,8 @@ typedef int16_t accel_t; #define HAS_ACCEL 1 +#define AO_ACCEL_INVERT 0 + typedef int16_t accel_t; /* MPU6000 is hooked up so that positive y is positive acceleration */ -- cgit v1.2.3 From 9d812b3db418fd9816731b761a0853eb38f5a265 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 14 Jan 2014 23:21:40 -0800 Subject: altos: Switch APRS to compressed position format This provides lat/lon/alt in fewer bytes while improving precision. Signed-off-by: Keith Packard --- src/drivers/ao_aprs.c | 75 +++++++++++++++++++++++++++++++----- src/lpc/Makefile-lpc.defs | 4 +- src/math/ef_log.c | 92 ++++++++++++++++++++++++++++++++++++++++++++ src/math/fdlibm.h | 1 + src/math/math.h | 2 + src/telegps-v0.3/Makefile | 4 ++ src/telemega-v0.1/Makefile | 3 +- src/telemega-v1.0/Makefile | 3 +- src/telemetrum-v2.0/Makefile | 4 ++ 9 files changed, 174 insertions(+), 14 deletions(-) create mode 100644 src/math/ef_log.c (limited to 'src') diff --git a/src/drivers/ao_aprs.c b/src/drivers/ao_aprs.c index 6ab61e6a..96e90f00 100644 --- a/src/drivers/ao_aprs.c +++ b/src/drivers/ao_aprs.c @@ -144,6 +144,7 @@ #endif #include +#include // Public methods, constants, and data structures for each class. @@ -254,9 +255,9 @@ typedef enum /// AX.25 compliant packet header that contains destination, station call sign, and path. /// 0x76 for SSID-11, 0x78 for SSID-12 static uint8_t TNC_AX25_HEADER[] = { - 'A' << 1, 'P' << 1, 'A' << 1, 'M' << 1, ' ' << 1, ' ' << 1, 0x60, \ - 'N' << 1, '0' << 1, 'C' << 1, 'A' << 1, 'L' << 1, 'L' << 1, 0x78, \ - 'W' << 1, 'I' << 1, 'D' << 1, 'E' << 1, '2' << 1, ' ' << 1, 0x65, \ + 'A' << 1, 'P' << 1, 'A' << 1, 'M' << 1, ' ' << 1, ' ' << 1, 0x60, + 'N' << 1, '0' << 1, 'C' << 1, 'A' << 1, 'L' << 1, 'L' << 1, 0x78, + 'W' << 1, 'I' << 1, 'D' << 1, 'E' << 1, '2' << 1, ' ' << 1, 0x65, 0x03, 0xf0 }; #define TNC_CALLSIGN_OFF 7 @@ -479,6 +480,14 @@ static void tnc1200TimerTick() } // END switch } +static void tncCompressInt(uint8_t *dest, int32_t value, int len) { + int i; + for (i = len - 1; i >= 0; i--) { + dest[i] = value % 91 + 33; + value /= 91; + } +} + /** * Generate the plain text position packet. */ @@ -487,7 +496,14 @@ static int tncPositionPacket(void) int32_t latitude = ao_gps_data.latitude; int32_t longitude = ao_gps_data.longitude; int32_t altitude = ao_gps_data.altitude; + uint8_t *buf; + if (altitude < 0) + 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; @@ -495,8 +511,6 @@ static int tncPositionPacket(void) uint16_t lon_min; uint16_t lon_frac; - char lat_sign = 'N', lon_sign = 'E'; - if (latitude < 0) { lat_sign = 'S'; latitude = -latitude; @@ -529,15 +543,56 @@ static int tncPositionPacket(void) longitude -= lon_min * 10000000; lon_frac = longitude / 100000; - if (altitude < 0) - altitude = 0; - - altitude = (altitude * (int32_t) 10000 + (3048/2)) / (int32_t) 3048; - +#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++ = '/'; + + latitude = ((uint64_t) 380926 * (900000000 - latitude)) / 10000000; + longitude = ((uint64_t) 190463 * (1800000000 + longitude)) / 10000000; + +#define ALTITUDE_LOG_BASE 0.001998002662673f /* log(1.002) */ + + altitude = logf((float) altitude) * (1/ALTITUDE_LOG_BASE); + + tncCompressInt(buf, latitude, 4); + buf += 4; + tncCompressInt(buf, longitude, 4); + buf += 4; + + /* Symbol code */ + *buf++ = '\''; + + tncCompressInt(buf, altitude, 2); + buf += 2; + + *buf++ = 33 + ((1 << 5) | (2 << 3)); + *buf++ = '\0'; + return buf - tncBuffer; } static int16_t diff --git a/src/lpc/Makefile-lpc.defs b/src/lpc/Makefile-lpc.defs index dd2bf0e6..fecb9135 100644 --- a/src/lpc/Makefile-lpc.defs +++ b/src/lpc/Makefile-lpc.defs @@ -4,7 +4,7 @@ endif include $(TOPDIR)/Makedefs -vpath % $(TOPDIR)/lpc:$(TOPDIR)/product:$(TOPDIR)/drivers:$(TOPDIR)/core:$(TOPDIR)/util:$(TOPDIR)/kalman:$(TOPDIR/aes):$(TOPDIR) +vpath % $(TOPDIR)/lpc:$(TOPDIR)/product:$(TOPDIR)/drivers:$(TOPDIR)/core:$(TOPDIR)/util:$(TOPDIR)/kalman:$(TOPDIR/aes):$(TOPDIR):$(TOPDIR)/math vpath make-altitude $(TOPDIR)/util vpath make-kalman $(TOPDIR)/util vpath kalman.5c $(TOPDIR)/kalman @@ -28,7 +28,7 @@ CC=$(ARM_CC) WARN_FLAGS=-Wall -Wextra -Werror -AO_CFLAGS=-I. -I$(TOPDIR)/lpc -I$(TOPDIR)/core -I$(TOPDIR)/drivers -I$(TOPDIR)/product -I$(TOPDIR) $(PDCLIB_INCLUDES) +AO_CFLAGS=-I. -I$(TOPDIR)/lpc -I$(TOPDIR)/core -I$(TOPDIR)/drivers -I$(TOPDIR)/product -I$(TOPDIR) -I$(TOPDIR)/math -I$(TOPDIR) $(PDCLIB_INCLUDES) LPC_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m0 -mthumb\ -ffreestanding -nostdlib $(AO_CFLAGS) $(WARN_FLAGS) diff --git a/src/math/ef_log.c b/src/math/ef_log.c new file mode 100644 index 00000000..619fe909 --- /dev/null +++ b/src/math/ef_log.c @@ -0,0 +1,92 @@ +/* ef_log.c -- float version of e_log.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "fdlibm.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +ln2_hi = 6.9313812256e-01, /* 0x3f317180 */ +ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */ +two25 = 3.355443200e+07, /* 0x4c000000 */ +Lg1 = 6.6666668653e-01, /* 3F2AAAAB */ +Lg2 = 4.0000000596e-01, /* 3ECCCCCD */ +Lg3 = 2.8571429849e-01, /* 3E924925 */ +Lg4 = 2.2222198546e-01, /* 3E638E29 */ +Lg5 = 1.8183572590e-01, /* 3E3A3325 */ +Lg6 = 1.5313838422e-01, /* 3E1CD04F */ +Lg7 = 1.4798198640e-01; /* 3E178897 */ + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_logf(float x) +#else + float __ieee754_logf(x) + float x; +#endif +{ + float hfsq,f,s,z,R,w,t1,t2,dk; + __int32_t k,ix,i,j; + + GET_FLOAT_WORD(ix,x); + + k=0; + if (FLT_UWORD_IS_ZERO(ix&0x7fffffff)) + return -two25/zero; /* log(+-0)=-inf */ + if (ix<0) return (x-x)/zero; /* log(-#) = NaN */ + if (!FLT_UWORD_IS_FINITE(ix)) return x+x; + if (FLT_UWORD_IS_SUBNORMAL(ix)) { + k -= 25; x *= two25; /* subnormal number, scale up x */ + GET_FLOAT_WORD(ix,x); + } + k += (ix>>23)-127; + ix &= 0x007fffff; + i = (ix+(0x95f64<<3))&0x800000; + SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */ + k += (i>>23); + f = x-(float)1.0; + if((0x007fffff&(15+ix))<16) { /* |f| < 2**-20 */ + if(f==zero) { if(k==0) return zero; else {dk=(float)k; + return dk*ln2_hi+dk*ln2_lo;}} + R = f*f*((float)0.5-(float)0.33333333333333333*f); + if(k==0) return f-R; else {dk=(float)k; + return dk*ln2_hi-((R-dk*ln2_lo)-f);} + } + s = f/((float)2.0+f); + dk = (float)k; + z = s*s; + i = ix-(0x6147a<<3); + w = z*z; + j = (0x6b851<<3)-ix; + t1= w*(Lg2+w*(Lg4+w*Lg6)); + t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); + i |= j; + R = t2+t1; + if(i>0) { + hfsq=(float)0.5*f*f; + if(k==0) return f-(hfsq-s*(hfsq+R)); else + return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f); + } else { + if(k==0) return f-s*(f-R); else + return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f); + } +} diff --git a/src/math/fdlibm.h b/src/math/fdlibm.h index 821619ad..ee9fcb22 100644 --- a/src/math/fdlibm.h +++ b/src/math/fdlibm.h @@ -19,6 +19,7 @@ #define __ieee754_acosf acosf #define __ieee754_sqrtf sqrtf +#define __ieee754_logf logf /* REDHAT LOCAL: Include files. */ #include diff --git a/src/math/math.h b/src/math/math.h index fd543bc2..97dd74cf 100644 --- a/src/math/math.h +++ b/src/math/math.h @@ -34,4 +34,6 @@ float scalbnf(float x, int n); float copysignf(float x, float y); +float logf(float x); + #endif diff --git a/src/telegps-v0.3/Makefile b/src/telegps-v0.3/Makefile index bb9c8c64..5aad32b5 100644 --- a/src/telegps-v0.3/Makefile +++ b/src/telegps-v0.3/Makefile @@ -19,6 +19,9 @@ INC = \ Makefile +MATH_SRC=\ + ef_log.c + ALTOS_SRC = \ ao_interrupt.c \ ao_boot_chain.c \ @@ -47,6 +50,7 @@ ALTOS_SRC = \ ao_log.c \ ao_log_mega.c \ ao_gps_report_mega.c \ + $(MATH_SRC) \ $(SAMPLE_PROFILE) PRODUCT=TeleGPS-v0.3 diff --git a/src/telemega-v0.1/Makefile b/src/telemega-v0.1/Makefile index 0145f49c..35f28b30 100644 --- a/src/telemega-v0.1/Makefile +++ b/src/telemega-v0.1/Makefile @@ -58,7 +58,8 @@ MATH_SRC=\ sf_sin.c \ sf_fabs.c \ sf_floor.c \ - sf_scalbn.c + sf_scalbn.c \ + ef_log.c ALTOS_SRC = \ ao_boot_chain.c \ diff --git a/src/telemega-v1.0/Makefile b/src/telemega-v1.0/Makefile index 543f7e74..b5c1f402 100644 --- a/src/telemega-v1.0/Makefile +++ b/src/telemega-v1.0/Makefile @@ -59,7 +59,8 @@ MATH_SRC=\ sf_fabs.c \ sf_floor.c \ sf_scalbn.c \ - sf_sin.c + sf_sin.c \ + ef_log.c ALTOS_SRC = \ ao_boot_chain.c \ diff --git a/src/telemetrum-v2.0/Makefile b/src/telemetrum-v2.0/Makefile index cebc9cab..0b9e6914 100644 --- a/src/telemetrum-v2.0/Makefile +++ b/src/telemetrum-v2.0/Makefile @@ -37,6 +37,9 @@ INC = \ #STACK_GUARD=ao_mpu_stm.c #STACK_GUARD_DEF=-DHAS_STACK_GUARD=1 +MATH_SRC=\ + ef_log.c + ALTOS_SRC = \ ao_boot_chain.c \ ao_interrupt.c \ @@ -83,6 +86,7 @@ ALTOS_SRC = \ ao_packet.c \ ao_companion.c \ ao_aprs.c \ + $(MATH_SRC) \ $(PROFILE) \ $(SAMPLE_PROFILE) \ $(STACK_GUARD) -- cgit v1.2.3 From cc06242e882cba462791962c199b7c89e79adc65 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 14 Jan 2014 23:29:59 -0800 Subject: altos: Use factory calibration for all acceleration computations The ground acceleration value will vary depending on the tilt angle of the airframe, which will result in incorrect acceleration computations during flight. This also avoids accidental boost detect when moving the airframe around in pad mode. Signed-off-by: Keith Packard --- altoslib/AltosState.java | 12 ++---------- src/core/ao_flight.c | 2 +- src/core/ao_kalman.c | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 134aeb4e..08dafbb4 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -949,14 +949,8 @@ public class AltosState implements Cloneable { } void update_accel() { - double ground = ground_accel; - - if (ground == AltosLib.MISSING) - ground = ground_accel_avg; if (accel == AltosLib.MISSING) return; - if (ground == AltosLib.MISSING) - return; if (accel_plus_g == AltosLib.MISSING) return; if (accel_minus_g == AltosLib.MISSING) @@ -964,7 +958,7 @@ public class AltosState implements Cloneable { double counts_per_g = (accel_minus_g - accel_plus_g) / 2.0; double counts_per_mss = counts_per_g / 9.80665; - acceleration.set_measured((ground - accel) / counts_per_mss, time); + acceleration.set_measured((accel_plus_g - accel) / counts_per_mss, time); } public void set_accel_g(double accel_plus_g, double accel_minus_g) { @@ -976,10 +970,8 @@ public class AltosState implements Cloneable { } public void set_ground_accel(double ground_accel) { - if (ground_accel != AltosLib.MISSING) { + if (ground_accel != AltosLib.MISSING) this.ground_accel = ground_accel; - update_accel(); - } } public void set_accel(double accel) { diff --git a/src/core/ao_flight.c b/src/core/ao_flight.c index 08302140..702c3403 100644 --- a/src/core/ao_flight.c +++ b/src/core/ao_flight.c @@ -401,7 +401,7 @@ ao_flight_dump(void) #if HAS_ACCEL int16_t accel; - accel = ((ao_ground_accel - ao_sample_accel) * ao_accel_scale) >> 16; + accel = ((ao_config.accel_plus_g - ao_sample_accel) * ao_accel_scale) >> 16; #endif printf ("sample:\n"); diff --git a/src/core/ao_kalman.c b/src/core/ao_kalman.c index 7fd4f889..9aea1f14 100644 --- a/src/core/ao_kalman.c +++ b/src/core/ao_kalman.c @@ -166,7 +166,7 @@ ao_kalman_err_accel(void) { int32_t accel; - accel = (ao_ground_accel - ao_sample_accel) * ao_accel_scale; + accel = (ao_config.accel_plus_g - ao_sample_accel) * ao_accel_scale; /* Can't use ao_accel here as it is the pre-prediction value still */ ao_error_a = (accel - ao_k_accel) >> 16; -- 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') 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 From cfcb127b248b62231049b6b50cf9b7edc2731f0a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 15 Jan 2014 13:28:16 -0800 Subject: altos: Add missing ADC divider values for Tmega v1.0 Somehow I left these out of the previous commit Signed-off-by: Keith Packard --- src/telemega-v1.0/ao_pins.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/telemega-v1.0/ao_pins.h b/src/telemega-v1.0/ao_pins.h index 95644dae..fe97c684 100644 --- a/src/telemega-v1.0/ao_pins.h +++ b/src/telemega-v1.0/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 */ -- cgit v1.2.3