altos: Record MPU6000 failure but let device boot
[fw/altos] / src / drivers / ao_mpu6000.c
index 7c9d6b6bffaa343469576c4429bf4d883fad69d5..dd3da8dee3837f504a6df05d4633a0d5e03bf9cf 100644 (file)
@@ -164,6 +164,8 @@ ao_mpu6000_gyro_check(int16_t normal, int16_t test)
        return 0;
 }
 
+static uint8_t mpu_id;
+
 static void
 _ao_mpu6000_wait_alive(void)
 {
@@ -172,11 +174,11 @@ _ao_mpu6000_wait_alive(void)
        /* Wait for the chip to wake up */
        for (i = 0; i < 30; i++) {
                ao_delay(AO_MS_TO_TICKS(100));
-               if (_ao_mpu6000_reg_read(MPU6000_WHO_AM_I) == 0x68)
-                       break;
+               mpu_id = _ao_mpu6000_reg_read(MPU6000_WHO_AM_I);
+               if (mpu_id == 0x68)
+                       return;
        }
-       if (i == 30)
-               ao_panic(AO_PANIC_SELF_TEST_MPU6000);
+       AO_SENSOR_ERROR(AO_DATA_MPU6000);
 }
 
 #define ST_TRIES       10
@@ -355,13 +357,14 @@ static struct ao_task ao_mpu6000_task;
 static void
 ao_mpu6000_show(void)
 {
-       printf ("Accel: %7d %7d %7d Gyro: %7d %7d %7d\n",
+       printf ("Accel: %7d %7d %7d Gyro: %7d %7d %7d id %02x\n",
                ao_mpu6000_current.accel_x,
                ao_mpu6000_current.accel_y,
                ao_mpu6000_current.accel_z,
                ao_mpu6000_current.gyro_x,
                ao_mpu6000_current.gyro_y,
-               ao_mpu6000_current.gyro_z);
+               ao_mpu6000_current.gyro_z,
+               mpu_id);
 }
 
 static const struct ao_cmds ao_mpu6000_cmds[] = {