mirror of https://github.com/ArduPilot/ardupilot
MPU6000: protect the driver from double initialisation
initialising twice can lockup the driver
This commit is contained in:
parent
18d26dc74e
commit
6ca613337b
|
@ -100,10 +100,13 @@ AP_InertialSensor_MPU6000::AP_InertialSensor_MPU6000( uint8_t cs_pin )
|
|||
_accel.y = 0;
|
||||
_accel.z = 0;
|
||||
_temp = 0;
|
||||
_initialised = 0;
|
||||
}
|
||||
|
||||
void AP_InertialSensor_MPU6000::init( AP_PeriodicProcess * scheduler )
|
||||
{
|
||||
if (_initialised) return;
|
||||
_initialised = 1;
|
||||
hardware_init();
|
||||
scheduler->register_process( &AP_InertialSensor_MPU6000::read );
|
||||
}
|
||||
|
|
|
@ -64,6 +64,9 @@ class AP_InertialSensor_MPU6000 : public AP_InertialSensor
|
|||
|
||||
/* TODO deprecate _cs_pin */
|
||||
static uint8_t _cs_pin;
|
||||
|
||||
// ensure we can't initialise twice
|
||||
unsigned _initialised:1;
|
||||
};
|
||||
|
||||
#endif // __AP_INERTIAL_SENSOR_MPU6000_H__
|
||||
|
|
Loading…
Reference in New Issue