altos: Allow ms5607 driver to either set ao_sensor_errors or panic
authorKeith Packard <keithp@keithp.com>
Mon, 15 Jul 2019 20:26:30 +0000 (13:26 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 15 Jul 2019 20:26:30 +0000 (13:26 -0700)
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 <keithp@keithp.com>
src/drivers/ao_ms5607.c
src/kernel/ao_data.h
src/kernel/ao_flight.h
src/microkite/ao_pins.h
src/micropeak-v2.0/ao_pins.h
src/micropeak/ao_pins.h
src/microsplash/ao_pins.h

index 495fbe02c0c015262b635870c704c660f85cc82f..febe01117dbc614e11d309327d830d660f8a2e86 100644 (file)
@@ -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 */
index f52e17e2df01675562baab8df4f0c64a1251f72d..5a340c3f3b4526f5700ba487063368dcb5602f9c 100644 (file)
 #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)
index af6b0c55bedd465ed209b8284d503808c35911f5..c66860d0f4790266eb85d1b3ce8bf4832bb1de82 100644 (file)
@@ -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;
 
index 396b57e3e7e3143c95d3c256a1b2183720cd03f3..eb6d034fdeb30a715025eb85daca8595afb77c3f 100644 (file)
@@ -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
index 21ea337c5f6dfd6837310e9e362513c818eaa196..9dba26bd718fe0bc28e1fe3737f4251524fa542a 100644 (file)
@@ -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
index 7cfbca490f17a2f4cb5094f5a8e514734210823e..2c02f3a3acb34b997d79b5b733741ef30fb91e28 100644 (file)
@@ -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
index 50a993464a76cf1554bf1ed1eb0597b4e6ed250c..0461b20e1480ea23ee217f542d2d1e95e33d877d 100644 (file)
@@ -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