Browse Source

Fixed unreliable ICM20948 detection.

Fixed ICM20948 magnetometer only option.
Specified bus for internal mpu9250 on Pixhawk 2.1 to avoid premature detection of
other device.
sbg
Florian Olbrich 6 years ago committed by Daniel Agar
parent
commit
280a60c86f
  1. 2
      boards/px4/fmu-v3/init/rc.board
  2. 12
      src/drivers/imu/mpu9250/main.cpp
  3. 7
      src/drivers/imu/mpu9250/mpu9250.cpp
  4. 1
      src/drivers/imu/mpu9250/mpu9250.h

2
boards/px4/fmu-v3/init/rc.board

@ -116,7 +116,7 @@ then @@ -116,7 +116,7 @@ then
if [ $BOARD_FMUV3 = 21 ]
then
# v2.1 internal MPU9250 is rotated 180 deg roll, 270 deg yaw
mpu9250 -R 14 start
mpu9250 -s -R 14 start
fi
else

12
src/drivers/imu/mpu9250/main.cpp

@ -264,7 +264,17 @@ start_bus(struct mpu9250_bus_option &bus, enum Rotation rotation, bool external, @@ -264,7 +264,17 @@ start_bus(struct mpu9250_bus_option &bus, enum Rotation rotation, bool external,
goto fail;
}
fd = open(bus.accelpath, O_RDONLY);
/*
* Set the poll rate to default, starts automatic data collection.
* Doing this through the mag device for the time being - it's always there, even in magnetometer only mode.
* Using accel device for MPU6500.
*/
if (bus.dev->get_whoami() == MPU_WHOAMI_6500) {
fd = open(bus.accelpath, O_RDONLY);
} else {
fd = open(bus.magpath, O_RDONLY);
}
if (fd < 0) {
PX4_INFO("ioctl failed");

7
src/drivers/imu/mpu9250/mpu9250.cpp

@ -421,6 +421,11 @@ MPU9250::init() @@ -421,6 +421,11 @@ MPU9250::init()
return ret;
}
uint8_t MPU9250::get_whoami()
{
return _whoami;
}
int MPU9250::reset()
{
irqstate_t state;
@ -574,6 +579,8 @@ MPU9250::probe() @@ -574,6 +579,8 @@ MPU9250::probe()
// If it's not an MPU it must be an ICM
if ((_whoami != MPU_WHOAMI_9250) && (_whoami != MPU_WHOAMI_6500)) {
// Make sure selected register bank is bank 0 (which contains WHOAMI)
select_register_bank(REG_BANK(ICMREG_20948_WHOAMI));
_whoami = read_reg(ICMREG_20948_WHOAMI);
}

1
src/drivers/imu/mpu9250/mpu9250.h

@ -386,6 +386,7 @@ public: @@ -386,6 +386,7 @@ public:
virtual ~MPU9250();
virtual int init();
uint8_t get_whoami();
/**
* Diagnostics - print some basic information about the driver.

Loading…
Cancel
Save