From c70fc859093d06a384c91e1e8cdf5f953f4b1daf Mon Sep 17 00:00:00 2001 From: Adam Serbinski Date: Wed, 24 Feb 2021 11:09:41 -0500 Subject: [PATCH] drivers: sensors: mpu6050: add support for mpu9250 mpu9250 is a single package that contains both an mpu6050 6-axis motion sensor and an ak8963 magnetometer. The two parts have separate i2c addresses, yet despite the common mpu6050 component, it has a different value in the "WHOAMI" register -- 0x71 instead of 0x68. This adds the additional chip id value in order to enable the use of mpu9250. Signed-off-by: Adam Serbinski --- drivers/sensor/mpu6050/mpu6050.c | 2 +- drivers/sensor/mpu6050/mpu6050.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/sensor/mpu6050/mpu6050.c b/drivers/sensor/mpu6050/mpu6050.c index c533baf63bc..65adbdd812c 100644 --- a/drivers/sensor/mpu6050/mpu6050.c +++ b/drivers/sensor/mpu6050/mpu6050.c @@ -161,7 +161,7 @@ int mpu6050_init(const struct device *dev) return -EIO; } - if (id != MPU6050_CHIP_ID) { + if (id != MPU6050_CHIP_ID && id != MPU9250_CHIP_ID) { LOG_ERR("Invalid chip ID."); return -EINVAL; } diff --git a/drivers/sensor/mpu6050/mpu6050.h b/drivers/sensor/mpu6050/mpu6050.h index 59adbf88134..4190438f9c7 100644 --- a/drivers/sensor/mpu6050/mpu6050.h +++ b/drivers/sensor/mpu6050/mpu6050.h @@ -14,6 +14,7 @@ #define MPU6050_REG_CHIP_ID 0x75 #define MPU6050_CHIP_ID 0x68 +#define MPU9250_CHIP_ID 0x71 #define MPU6050_REG_GYRO_CFG 0x1B #define MPU6050_GYRO_FS_SHIFT 3