AP_InertialSensor: fixed auxiliary bus with FIFO enabled

make sure fifo reset doesn't check I2C master enable
This commit is contained in:
Andrew Tridgell 2016-11-09 19:54:53 +11:00
parent 46785e8ecf
commit e27a76e460
4 changed files with 18 additions and 6 deletions

View File

@ -322,9 +322,10 @@ bool AP_InertialSensor_MPU6000::_init()
void AP_InertialSensor_MPU6000::_fifo_reset()
{
_register_write(MPUREG_USER_CTRL, 0);
_register_write(MPUREG_USER_CTRL, BIT_USER_CTRL_FIFO_RESET);
_register_write(MPUREG_USER_CTRL, BIT_USER_CTRL_FIFO_EN);
uint8_t user_ctrl = _master_i2c_enable?BIT_USER_CTRL_I2C_MST_EN:0;
_register_write(MPUREG_USER_CTRL, user_ctrl);
_register_write(MPUREG_USER_CTRL, user_ctrl | BIT_USER_CTRL_FIFO_RESET);
_register_write(MPUREG_USER_CTRL, user_ctrl | BIT_USER_CTRL_FIFO_EN);
}
void AP_InertialSensor_MPU6000::_fifo_enable()
@ -907,6 +908,8 @@ void AP_MPU6000_AuxiliaryBus::_configure_slaves()
uint8_t user_ctrl = backend._register_read(MPUREG_USER_CTRL);
backend._register_write(MPUREG_USER_CTRL, user_ctrl | BIT_USER_CTRL_I2C_MST_EN);
backend._master_i2c_enable = true;
/* stop condition between reads; clock at 400kHz */
backend._register_write(MPUREG_I2C_MST_CTRL,
BIT_I2C_MST_P_NSR | BIT_I2C_MST_CLK_400KHZ);

View File

@ -115,6 +115,9 @@ private:
float _last_temp;
uint8_t _temp_counter;
// has master i2c been enabled?
bool _master_i2c_enable;
// buffer for fifo read
uint8_t *_fifo_buffer;
};

View File

@ -276,9 +276,10 @@ bool AP_InertialSensor_MPU9250::_init()
void AP_InertialSensor_MPU9250::_fifo_reset()
{
_register_write(MPUREG_USER_CTRL, 0);
_register_write(MPUREG_USER_CTRL, BIT_USER_CTRL_FIFO_RESET);
_register_write(MPUREG_USER_CTRL, BIT_USER_CTRL_FIFO_EN);
uint8_t user_ctrl = _master_i2c_enable?BIT_USER_CTRL_I2C_MST_EN:0;
_register_write(MPUREG_USER_CTRL, user_ctrl);
_register_write(MPUREG_USER_CTRL, user_ctrl | BIT_USER_CTRL_FIFO_RESET);
_register_write(MPUREG_USER_CTRL, user_ctrl | BIT_USER_CTRL_FIFO_EN);
}
void AP_InertialSensor_MPU9250::_fifo_enable()
@ -781,6 +782,8 @@ void AP_MPU9250_AuxiliaryBus::_configure_slaves()
uint8_t user_ctrl = backend._register_read(MPUREG_USER_CTRL);
backend._register_write(MPUREG_USER_CTRL, user_ctrl | BIT_USER_CTRL_I2C_MST_EN);
backend._master_i2c_enable = true;
/* stop condition between reads; clock at 400kHz */
backend._register_write(MPUREG_I2C_MST_CTRL,
I2C_MST_CLOCK_400KHZ | I2C_MST_P_NSR);

View File

@ -100,6 +100,9 @@ private:
// are we doing more than 1kHz sampling?
bool _fast_sampling;
// has master i2c been enabled?
bool _master_i2c_enable;
// last temperature reading, used to detect FIFO errors
float _last_temp;