Skip to content
Snippets Groups Projects
Commit 3200b032 authored by Lucas De Marchi's avatar Lucas De Marchi Committed by Lorenz Meier
Browse files

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.
parent 2805bffe
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment