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.
This commit is contained in:
Lucas De Marchi 2017-03-14 23:12:43 -07:00 committed by Lorenz Meier
parent 2805bffe52
commit 3200b032c0
3 changed files with 24 additions and 3 deletions

View File

@ -328,7 +328,9 @@ MPU9250::init()
#endif
/* do CDev init for the mag device node, keep it optional */
ret = _mag->init();
if (_whoami == MPU_WHOAMI_9250) {
ret = _mag->init();
}
/* if probe/setup failed, bail now */
if (ret != OK) {
@ -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;

View File

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

View File

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