Skip to content
Snippets Groups Projects
Commit e27a76e4 authored by Andrew Tridgell's avatar Andrew Tridgell
Browse files

AP_InertialSensor: fixed auxiliary bus with FIFO enabled

make sure fifo reset doesn't check I2C master enable
parent 46785e8e
No related branches found
No related tags found
No related merge requests found
...@@ -322,9 +322,10 @@ bool AP_InertialSensor_MPU6000::_init() ...@@ -322,9 +322,10 @@ bool AP_InertialSensor_MPU6000::_init()
void AP_InertialSensor_MPU6000::_fifo_reset() void AP_InertialSensor_MPU6000::_fifo_reset()
{ {
_register_write(MPUREG_USER_CTRL, 0); uint8_t user_ctrl = _master_i2c_enable?BIT_USER_CTRL_I2C_MST_EN:0;
_register_write(MPUREG_USER_CTRL, BIT_USER_CTRL_FIFO_RESET); _register_write(MPUREG_USER_CTRL, user_ctrl);
_register_write(MPUREG_USER_CTRL, BIT_USER_CTRL_FIFO_EN); _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() void AP_InertialSensor_MPU6000::_fifo_enable()
...@@ -907,6 +908,8 @@ void AP_MPU6000_AuxiliaryBus::_configure_slaves() ...@@ -907,6 +908,8 @@ void AP_MPU6000_AuxiliaryBus::_configure_slaves()
uint8_t user_ctrl = backend._register_read(MPUREG_USER_CTRL); 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._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 */ /* stop condition between reads; clock at 400kHz */
backend._register_write(MPUREG_I2C_MST_CTRL, backend._register_write(MPUREG_I2C_MST_CTRL,
BIT_I2C_MST_P_NSR | BIT_I2C_MST_CLK_400KHZ); BIT_I2C_MST_P_NSR | BIT_I2C_MST_CLK_400KHZ);
......
...@@ -115,6 +115,9 @@ private: ...@@ -115,6 +115,9 @@ private:
float _last_temp; float _last_temp;
uint8_t _temp_counter; uint8_t _temp_counter;
// has master i2c been enabled?
bool _master_i2c_enable;
// buffer for fifo read // buffer for fifo read
uint8_t *_fifo_buffer; uint8_t *_fifo_buffer;
}; };
......
...@@ -276,9 +276,10 @@ bool AP_InertialSensor_MPU9250::_init() ...@@ -276,9 +276,10 @@ bool AP_InertialSensor_MPU9250::_init()
void AP_InertialSensor_MPU9250::_fifo_reset() void AP_InertialSensor_MPU9250::_fifo_reset()
{ {
_register_write(MPUREG_USER_CTRL, 0); uint8_t user_ctrl = _master_i2c_enable?BIT_USER_CTRL_I2C_MST_EN:0;
_register_write(MPUREG_USER_CTRL, BIT_USER_CTRL_FIFO_RESET); _register_write(MPUREG_USER_CTRL, user_ctrl);
_register_write(MPUREG_USER_CTRL, BIT_USER_CTRL_FIFO_EN); _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() void AP_InertialSensor_MPU9250::_fifo_enable()
...@@ -781,6 +782,8 @@ void AP_MPU9250_AuxiliaryBus::_configure_slaves() ...@@ -781,6 +782,8 @@ void AP_MPU9250_AuxiliaryBus::_configure_slaves()
uint8_t user_ctrl = backend._register_read(MPUREG_USER_CTRL); 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._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 */ /* stop condition between reads; clock at 400kHz */
backend._register_write(MPUREG_I2C_MST_CTRL, backend._register_write(MPUREG_I2C_MST_CTRL,
I2C_MST_CLOCK_400KHZ | I2C_MST_P_NSR); I2C_MST_CLOCK_400KHZ | I2C_MST_P_NSR);
......
...@@ -100,6 +100,9 @@ private: ...@@ -100,6 +100,9 @@ private:
// are we doing more than 1kHz sampling? // are we doing more than 1kHz sampling?
bool _fast_sampling; bool _fast_sampling;
// has master i2c been enabled?
bool _master_i2c_enable;
// last temperature reading, used to detect FIFO errors // last temperature reading, used to detect FIFO errors
float _last_temp; float _last_temp;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment