From f77620c3f4cfcd1fc97dff9b1af78f2eb7166811 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Aug 2015 16:13:55 +1000 Subject: [PATCH] mpu6000: check WHOAMI register this prevents a mpu9250 being seen as a mpu6000 --- src/drivers/mpu6000/mpu6000.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/drivers/mpu6000/mpu6000.cpp b/src/drivers/mpu6000/mpu6000.cpp index 288ad579ab..7c7bc43d3e 100644 --- a/src/drivers/mpu6000/mpu6000.cpp +++ b/src/drivers/mpu6000/mpu6000.cpp @@ -147,6 +147,8 @@ #define BIT_I2C_IF_DIS 0x10 #define BIT_INT_STATUS_DATA 0x01 +#define MPU_WHOAMI_6000 0x68 + // Product ID Description for MPU6000 // high 4 bits low 4 bits // Product Name Product Revision @@ -755,6 +757,13 @@ int MPU6000::reset() int MPU6000::probe() { + uint8_t whoami; + whoami = read_reg(MPUREG_WHOAMI); + if (whoami != MPU_WHOAMI_6000) { + DEVICE_DEBUG("unexpected WHOAMI 0x%02x", whoami); + return -EIO; + + } /* look for a product ID we recognise */ _product = read_reg(MPUREG_PRODUCT_ID);