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.
This commit is contained in:
Florian Olbrich 2019-01-08 21:16:36 +01:00 committed by Daniel Agar
parent c2f82b5996
commit 280a60c86f
4 changed files with 20 additions and 2 deletions

View File

@ -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

View File

@ -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");

View File

@ -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()
// 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);
}

View File

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