summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
c37cd66)
Use DATA bits to mark which sensors have failed, then report that in
beeps at startup time to help diagnose hardware failures while still
allowing the board to be used over USB.
Signed-off-by: Keith Packard <keithp@keithp.com>
uint8_t devid = ao_adxl375_reg_read(AO_ADXL375_DEVID);
if (devid != AO_ADXL375_DEVID_ID)
uint8_t devid = ao_adxl375_reg_read(AO_ADXL375_DEVID);
if (devid != AO_ADXL375_DEVID_ID)
+ AO_SENSOR_ERROR(AO_DATA_ADXL375);
/* Set the data rate */
ao_adxl375_reg_write(AO_ADXL375_BW_RATE,
/* Set the data rate */
ao_adxl375_reg_write(AO_ADXL375_BW_RATE,
self_test_value = z_change;
if (z_change < MIN_SELF_TEST)
self_test_value = z_change;
if (z_change < MIN_SELF_TEST)
+ AO_SENSOR_ERROR(AO_DATA_ADXL375);
/* This check is commented out as maximum self test is unreliable
if (z_change > MAX_SELF_TEST)
/* This check is commented out as maximum self test is unreliable
if (z_change > MAX_SELF_TEST)
+ AO_SENSOR_ERROR(AO_DATA_ADXL375);
ao_delay(AO_ST_DELAY);
}
if (tries == AO_ST_TRIES)
ao_delay(AO_ST_DELAY);
}
if (tries == AO_ST_TRIES)
+ AO_SENSOR_ERROR(AO_DATA_MMA655X);
ao_mma655x_reg_write(AO_MMA655X_DEVCFG,
DEVCFG_VALUE | (1 << AO_MMA655X_DEVCFG_ENDINIT));
ao_mma655x_reg_write(AO_MMA655X_DEVCFG,
DEVCFG_VALUE | (1 << AO_MMA655X_DEVCFG_ENDINIT));
}
if (st_tries == ST_TRIES)
}
if (st_tries == ST_TRIES)
+ AO_SENSOR_ERROR(AO_DATA_MPU6000);
/* Filter to about 100Hz, which also sets the gyro rate to 1000Hz */
_ao_mpu6000_reg_write(MPU6000_CONFIG,
/* Filter to about 100Hz, which also sets the gyro rate to 1000Hz */
_ao_mpu6000_reg_write(MPU6000_CONFIG,
static uint8_t ao_mpu9250_configured;
static uint8_t ao_mpu9250_configured;
-extern uint8_t ao_sensor_errors;
-
#ifndef AO_MPU9250_I2C_INDEX
#define AO_MPU9250_SPI 1
#else
#ifndef AO_MPU9250_I2C_INDEX
#define AO_MPU9250_SPI 1
#else
}
if (st_tries == ST_TRIES)
}
if (st_tries == ST_TRIES)
+ AO_SENSOR_ERROR(AO_DATA_MPU9250);
/* Set up the mag sensor */
/* Set up the mag sensor */
}
if (mag_tries == MAG_TRIES)
}
if (mag_tries == MAG_TRIES)
+ AO_SENSOR_ERROR(AO_DATA_MPU9250);
/* Select continuous mode 2 (100Hz), 16 bit samples */
/* Select continuous mode 2 (100Hz), 16 bit samples */
if (!ao_ms5607_prom_valid((uint8_t *) prom)) {
#if HAS_SENSOR_ERRORS
if (!ao_ms5607_prom_valid((uint8_t *) prom)) {
#if HAS_SENSOR_ERRORS
+ AO_SENSOR_ERROR(AO_DATA_MS5607);
#else
ao_panic(AO_PANIC_SELF_TEST_MS5607);
#endif
#else
ao_panic(AO_PANIC_SELF_TEST_MS5607);
#endif
*/
#define AO_DATA_PRESENT(bit) (ao_data_present |= (bit))
*/
#define AO_DATA_PRESENT(bit) (ao_data_present |= (bit))
+/*
+ * Mark sensor failed, and unblock the sample collection code by
+ * marking the data as present
+ */
+#define AO_SENSOR_ERROR(bit) (ao_data_present |= (ao_sensor_errors |= (bit)))
+
/*
* Wait until it is time to write a sensor sample; this is
* signaled by the timer tick
/*
* Wait until it is time to write a sensor sample; this is
* signaled by the timer tick
else
#endif
ao_report_beep();
else
#endif
ao_report_beep();
+#if HAS_SENSOR_ERRORS
+ if (ao_report_state == ao_flight_invalid && ao_sensor_errors)
+ ao_report_number(ao_sensor_errors);
+#endif
+
if (ao_report_state == ao_flight_landed) {
ao_report_altitude();
#if HAS_FLIGHT
if (ao_report_state == ao_flight_landed) {
ao_report_altitude();
#if HAS_FLIGHT