From 245a49a85dd7b6a7cb9ec36ad02f6bb66e42f4e2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 15 Jul 2019 13:26:30 -0700 Subject: [PATCH] altos: Allow ms5607 driver to either set ao_sensor_errors or panic Products that want to remain usable (over USB) after a sensor failure don't want to panic when the ms5607 fails, but products with limited ROM space don't want to have extra code to check for the sensor failure and panic. Change the MS5607 driver to allow either option, and then make the micropeak based devices use it. Signed-off-by: Keith Packard --- src/drivers/ao_ms5607.c | 8 +++++++- src/kernel/ao_data.h | 10 ++++++++++ src/kernel/ao_flight.h | 8 -------- src/microkite/ao_pins.h | 1 + src/micropeak-v2.0/ao_pins.h | 1 + src/micropeak/ao_pins.h | 1 + src/microsplash/ao_pins.h | 1 + 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 495fbe02..febe0111 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -112,8 +112,14 @@ ao_ms5607_prom_read(struct ao_ms5607_prom *prom) r++; } - if (!ao_ms5607_prom_valid((uint8_t *) prom)) + + if (!ao_ms5607_prom_valid((uint8_t *) prom)) { +#if HAS_SENSOR_ERRORS + ao_sensor_errors = 1; +#else ao_panic(AO_PANIC_SELF_TEST_MS5607); +#endif + } #if __BYTE_ORDER == __LITTLE_ENDIAN /* Byte swap */ diff --git a/src/kernel/ao_data.h b/src/kernel/ao_data.h index f52e17e2..5a340c3f 100644 --- a/src/kernel/ao_data.h +++ b/src/kernel/ao_data.h @@ -76,6 +76,16 @@ #define AO_DATA_MAX6691 0 #endif +#ifndef HAS_SENSOR_ERRORS +#if HAS_IMU || HAS_MMA655X || HAS_MS5607 || HAS_MS5611 +#define HAS_SENSOR_ERRORS 1 +#endif +#endif + +#if HAS_SENSOR_ERRORS +extern uint8_t ao_sensor_errors; +#endif + #ifdef AO_DATA_RING #define AO_DATA_ALL (AO_DATA_ADC|AO_DATA_MS5607|AO_DATA_MPU6000|AO_DATA_HMC5883|AO_DATA_MMA655X|AO_DATA_MPU9250|AO_DATA_ADXL375) diff --git a/src/kernel/ao_flight.h b/src/kernel/ao_flight.h index af6b0c55..c66860d0 100644 --- a/src/kernel/ao_flight.h +++ b/src/kernel/ao_flight.h @@ -43,14 +43,6 @@ extern uint16_t ao_boost_tick; extern uint16_t ao_launch_tick; extern uint16_t ao_motor_number; -#if HAS_IMU || HAS_MMA655X -#define HAS_SENSOR_ERRORS 1 -#endif - -#if HAS_SENSOR_ERRORS -extern uint8_t ao_sensor_errors; -#endif - extern uint16_t ao_launch_time; extern uint8_t ao_flight_force_idle; diff --git a/src/microkite/ao_pins.h b/src/microkite/ao_pins.h index 396b57e3..eb6d034f 100644 --- a/src/microkite/ao_pins.h +++ b/src/microkite/ao_pins.h @@ -31,6 +31,7 @@ #define HAS_SERIAL_1 0 #define HAS_TASK 0 #define HAS_MS5607 1 +#define HAS_SENSOR_ERRORS 0 #define HAS_MS5611 0 #define HAS_EEPROM 0 #define HAS_BEEP 0 diff --git a/src/micropeak-v2.0/ao_pins.h b/src/micropeak-v2.0/ao_pins.h index 21ea337c..9dba26bd 100644 --- a/src/micropeak-v2.0/ao_pins.h +++ b/src/micropeak-v2.0/ao_pins.h @@ -63,6 +63,7 @@ extern uint8_t ao_on_battery; #define IS_FLASH_LOADER 0 #define HAS_MS5607 1 +#define HAS_SENSOR_ERRORS 0 #define HAS_MS5611 0 #define HAS_MS5607_TASK 0 #define HAS_EEPROM 1 diff --git a/src/micropeak/ao_pins.h b/src/micropeak/ao_pins.h index 7cfbca49..2c02f3a3 100644 --- a/src/micropeak/ao_pins.h +++ b/src/micropeak/ao_pins.h @@ -32,6 +32,7 @@ #define HAS_TASK 0 #define HAS_MS5607 1 #define HAS_MS5611 0 +#define HAS_SENSOR_ERRORS 0 #define HAS_EEPROM 0 #define HAS_BEEP 0 #define AVR_CLOCK 250000UL diff --git a/src/microsplash/ao_pins.h b/src/microsplash/ao_pins.h index 50a99346..0461b20e 100644 --- a/src/microsplash/ao_pins.h +++ b/src/microsplash/ao_pins.h @@ -31,6 +31,7 @@ #define HAS_SERIAL_1 0 #define HAS_TASK 0 #define HAS_MS5607 1 +#define HAS_SENSOR_ERRORS 0 #define HAS_MS5611 0 #define HAS_EEPROM 0 #define HAS_BEEP 0 -- 2.30.2