Browse Source

mpu9250: add support to MPU6500

MPU9250 is mostly an MPU6500 with a mag (AK8963) in the same package.
Support driving MPU6500 with the MPU9250 driver. The id of the driver
isn't set differently since this way it allows to force a recalibration.

Ideally MPU9250 driver could even not exist and the support for these
sensors be merged back in the MPU6000 that's more complete. This is an
intermediate step in that direction.
sbg
Lucas De Marchi 8 years ago committed by Lorenz Meier
parent
commit
3200b032c0
  1. 3
      src/drivers/mpu9250/mpu9250.cpp
  2. 1
      src/drivers/mpu9250/mpu9250.h
  3. 21
      src/drivers/mpu9250/mpu9250_spi.cpp

3
src/drivers/mpu9250/mpu9250.cpp

@ -328,7 +328,9 @@ MPU9250::init() @@ -328,7 +328,9 @@ MPU9250::init()
#endif
/* do CDev init for the mag device node, keep it optional */
if (_whoami == MPU_WHOAMI_9250) {
ret = _mag->init();
}
/* if probe/setup failed, bail now */
if (ret != OK) {
@ -450,6 +452,7 @@ MPU9250::probe() @@ -450,6 +452,7 @@ MPU9250::probe()
// verify product revision
switch (_whoami) {
case MPU_WHOAMI_9250:
case MPU_WHOAMI_6500:
memset(_checked_values, 0, sizeof(_checked_values));
memset(_checked_bad, 0, sizeof(_checked_bad));
_checked_values[0] = _whoami;

1
src/drivers/mpu9250/mpu9250.h

@ -178,6 +178,7 @@ @@ -178,6 +178,7 @@
#define BIT_I2C_SLV3_DLY_EN 0x08
#define MPU_WHOAMI_9250 0x71
#define MPU_WHOAMI_6500 0x70
#define MPU9250_ACCEL_DEFAULT_RATE 1000
#define MPU9250_ACCEL_MAX_OUTPUT_RATE 280

21
src/drivers/mpu9250/mpu9250_spi.cpp

@ -265,8 +265,25 @@ int @@ -265,8 +265,25 @@ int
MPU9250_SPI::probe()
{
uint8_t whoami = 0;
uint8_t expected = MPU_WHOAMI_9250;
return (read(MPUREG_WHOAMI, &whoami, 1) == OK && (whoami == expected)) ? 0 : -EIO;
int ret = read(MPUREG_WHOAMI, &whoami, 1);
if (ret != OK) {
return -EIO;
}
switch (whoami) {
case MPU_WHOAMI_9250:
case MPU_WHOAMI_6500:
ret = 0;
break;
default:
PX4_WARN("probe failed! %u", whoami);
ret = -EIO;
}
return ret;
}
#endif // PX4_SPIDEV_MPU

Loading…
Cancel
Save