Browse Source

AP_InertialSensor: fixed auxiliary bus with FIFO enabled

make sure fifo reset doesn't check I2C master enable
master
Andrew Tridgell 8 years ago
parent
commit
e27a76e460
  1. 9
      libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp
  2. 3
      libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.h
  3. 9
      libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.cpp
  4. 3
      libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.h

9
libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp

@ -322,9 +322,10 @@ bool AP_InertialSensor_MPU6000::_init() @@ -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() @@ -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);

3
libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.h

@ -115,6 +115,9 @@ private: @@ -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;
};

9
libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.cpp

@ -276,9 +276,10 @@ bool AP_InertialSensor_MPU9250::_init() @@ -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() @@ -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);

3
libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.h

@ -100,6 +100,9 @@ private: @@ -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;

Loading…
Cancel
Save