AP_InertialSensor: added check for WHOAMI on MPU9250

This commit is contained in:
Andrew Tridgell 2014-07-07 16:32:52 +10:00
parent e2822a2d8f
commit 6a6dbe5790

View File

@ -21,6 +21,7 @@
#include "AP_InertialSensor_MPU9250.h"
#include "../AP_HAL_Linux/GPIO.h"
#include <stdio.h>
extern const AP_HAL::HAL& hal;
@ -210,6 +211,14 @@ uint16_t AP_InertialSensor_MPU9250::_init_sensor( Sample_rate sample_rate )
hal.scheduler->suspend_timer_procs();
uint8_t whoami = _register_read(MPUREG_WHOAMI);
if (whoami != 0x71) {
// TODO: we should probably accept multiple chip
// revisions. This is the one on the PXF
hal.console->printf("MPU9250: unexpected WHOAMI 0x%x\n", (unsigned)whoami);
hal.scheduler->panic("MPU9250: bad WHOAMI");
}
uint8_t tries = 0;
do {
bool success = _hardware_init(sample_rate);