mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-30 04:28:30 -04:00
AP_InertialSensor: added support for IIM-42652 and ICM-40605 sensors
handle new Invensense v3 sensor types
This commit is contained in:
parent
7b90326888
commit
586c2064a6
@ -121,6 +121,8 @@ public:
|
|||||||
DEVTYPE_INS_ICM40609 = 0x33,
|
DEVTYPE_INS_ICM40609 = 0x33,
|
||||||
DEVTYPE_INS_ICM42688 = 0x34,
|
DEVTYPE_INS_ICM42688 = 0x34,
|
||||||
DEVTYPE_INS_ICM42605 = 0x35,
|
DEVTYPE_INS_ICM42605 = 0x35,
|
||||||
|
DEVTYPE_INS_ICM40605 = 0x36,
|
||||||
|
DEVTYPE_INS_IIM42652 = 0x37,
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
ICM-40609
|
ICM-40609
|
||||||
ICM-42688
|
ICM-42688
|
||||||
ICM-42605
|
ICM-42605
|
||||||
|
ICM-40605
|
||||||
|
IIM-42652
|
||||||
|
|
||||||
Note that this sensor includes 32kHz internal sampling and an
|
Note that this sensor includes 32kHz internal sampling and an
|
||||||
anti-aliasing filter, which means this driver can be a lot simpler
|
anti-aliasing filter, which means this driver can be a lot simpler
|
||||||
@ -62,9 +64,11 @@ static const float GYRO_SCALE = (0.0174532f / 16.4f);
|
|||||||
#define INV3REG_BANK_SEL 0x76
|
#define INV3REG_BANK_SEL 0x76
|
||||||
|
|
||||||
// WHOAMI values
|
// WHOAMI values
|
||||||
|
#define INV3_ID_ICM40605 0x33
|
||||||
#define INV3_ID_ICM40609 0x3b
|
#define INV3_ID_ICM40609 0x3b
|
||||||
#define INV3_ID_ICM42605 0x42
|
#define INV3_ID_ICM42605 0x42
|
||||||
#define INV3_ID_ICM42688 0x47
|
#define INV3_ID_ICM42688 0x47
|
||||||
|
#define INV3_ID_IIM42652 0x6f
|
||||||
|
|
||||||
// run output data at 2kHz
|
// run output data at 2kHz
|
||||||
#define INV3_ODR 2000
|
#define INV3_ODR 2000
|
||||||
@ -127,7 +131,7 @@ void AP_InertialSensor_Invensensev3::fifo_reset()
|
|||||||
// FIFO_MODE stop-on-full
|
// FIFO_MODE stop-on-full
|
||||||
register_write(INV3REG_FIFO_CONFIG, 0x80);
|
register_write(INV3REG_FIFO_CONFIG, 0x80);
|
||||||
// FIFO partial disable, enable accel, gyro, temperature
|
// FIFO partial disable, enable accel, gyro, temperature
|
||||||
register_write(INV3REG_FIFO_CONFIG1, 0x07);
|
register_write(INV3REG_FIFO_CONFIG1, fifo_config1);
|
||||||
// little-endian, fifo count in records, last data hold for ODR mismatch
|
// little-endian, fifo count in records, last data hold for ODR mismatch
|
||||||
register_write(INV3REG_INTF_CONFIG0, 0xC0);
|
register_write(INV3REG_INTF_CONFIG0, 0xC0);
|
||||||
register_write(INV3REG_SIGNAL_PATH_RESET, 2);
|
register_write(INV3REG_SIGNAL_PATH_RESET, 2);
|
||||||
@ -143,24 +147,40 @@ void AP_InertialSensor_Invensensev3::start()
|
|||||||
// initially run the bus at low speed
|
// initially run the bus at low speed
|
||||||
dev->set_speed(AP_HAL::Device::SPEED_LOW);
|
dev->set_speed(AP_HAL::Device::SPEED_LOW);
|
||||||
|
|
||||||
// always use FIFO
|
|
||||||
fifo_reset();
|
|
||||||
|
|
||||||
// grab the used instances
|
// grab the used instances
|
||||||
enum DevTypes devtype;
|
enum DevTypes devtype;
|
||||||
switch (inv3_type) {
|
switch (inv3_type) {
|
||||||
|
case Invensensev3_Type::IIM42652:
|
||||||
|
devtype = DEVTYPE_INS_IIM42652;
|
||||||
|
fifo_config1 = 0x07;
|
||||||
|
temp_sensitivity = 1.0 / 2.07;
|
||||||
|
break;
|
||||||
case Invensensev3_Type::ICM42688:
|
case Invensensev3_Type::ICM42688:
|
||||||
devtype = DEVTYPE_INS_ICM42688;
|
devtype = DEVTYPE_INS_ICM42688;
|
||||||
|
fifo_config1 = 0x07;
|
||||||
|
temp_sensitivity = 1.0 / 2.07;
|
||||||
break;
|
break;
|
||||||
case Invensensev3_Type::ICM42605:
|
case Invensensev3_Type::ICM42605:
|
||||||
devtype = DEVTYPE_INS_ICM42605;
|
devtype = DEVTYPE_INS_ICM42605;
|
||||||
|
fifo_config1 = 0x07;
|
||||||
|
temp_sensitivity = 1.0 / 2.07;
|
||||||
|
break;
|
||||||
|
case Invensensev3_Type::ICM40605:
|
||||||
|
devtype = DEVTYPE_INS_ICM40605;
|
||||||
|
fifo_config1 = 0x0F;
|
||||||
|
temp_sensitivity = 1.0 * 128 / 115.49;
|
||||||
break;
|
break;
|
||||||
case Invensensev3_Type::ICM40609:
|
case Invensensev3_Type::ICM40609:
|
||||||
default:
|
default:
|
||||||
devtype = DEVTYPE_INS_ICM40609;
|
devtype = DEVTYPE_INS_ICM40609;
|
||||||
|
temp_sensitivity = 1.0 / 2.07;
|
||||||
|
fifo_config1 = 0x07;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// always use FIFO
|
||||||
|
fifo_reset();
|
||||||
|
|
||||||
if (!_imu.register_gyro(gyro_instance, INV3_ODR, dev->get_bus_id_devtype(devtype)) ||
|
if (!_imu.register_gyro(gyro_instance, INV3_ODR, dev->get_bus_id_devtype(devtype)) ||
|
||||||
!_imu.register_accel(accel_instance, INV3_ODR, dev->get_bus_id_devtype(devtype))) {
|
!_imu.register_accel(accel_instance, INV3_ODR, dev->get_bus_id_devtype(devtype))) {
|
||||||
return;
|
return;
|
||||||
@ -343,6 +363,14 @@ bool AP_InertialSensor_Invensensev3::check_whoami(void)
|
|||||||
inv3_type = Invensensev3_Type::ICM42605;
|
inv3_type = Invensensev3_Type::ICM42605;
|
||||||
accel_scale = (GRAVITY_MSS / 2048);
|
accel_scale = (GRAVITY_MSS / 2048);
|
||||||
return true;
|
return true;
|
||||||
|
case INV3_ID_ICM40605:
|
||||||
|
inv3_type = Invensensev3_Type::ICM40605;
|
||||||
|
accel_scale = (GRAVITY_MSS / 2048);
|
||||||
|
return true;
|
||||||
|
case INV3_ID_IIM42652:
|
||||||
|
inv3_type = Invensensev3_Type::IIM42652;
|
||||||
|
accel_scale = (GRAVITY_MSS / 2048);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
// not a value WHOAMI result
|
// not a value WHOAMI result
|
||||||
return false;
|
return false;
|
||||||
@ -368,7 +396,9 @@ bool AP_InertialSensor_Invensensev3::hardware_init(void)
|
|||||||
_clip_limit = 29.5f * GRAVITY_MSS;
|
_clip_limit = 29.5f * GRAVITY_MSS;
|
||||||
break;
|
break;
|
||||||
case Invensensev3_Type::ICM42688:
|
case Invensensev3_Type::ICM42688:
|
||||||
|
case Invensensev3_Type::IIM42652:
|
||||||
case Invensensev3_Type::ICM42605:
|
case Invensensev3_Type::ICM42605:
|
||||||
|
case Invensensev3_Type::ICM40605:
|
||||||
_clip_limit = 15.5f * GRAVITY_MSS;
|
_clip_limit = 15.5f * GRAVITY_MSS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ public:
|
|||||||
ICM40609 = 0,
|
ICM40609 = 0,
|
||||||
ICM42688,
|
ICM42688,
|
||||||
ICM42605,
|
ICM42605,
|
||||||
|
ICM40605,
|
||||||
|
IIM42652,
|
||||||
};
|
};
|
||||||
|
|
||||||
// acclerometers on Invensense sensors will return values up to 32G
|
// acclerometers on Invensense sensors will return values up to 32G
|
||||||
@ -63,8 +65,11 @@ private:
|
|||||||
uint8_t gyro_instance;
|
uint8_t gyro_instance;
|
||||||
uint8_t accel_instance;
|
uint8_t accel_instance;
|
||||||
|
|
||||||
|
// reset FIFO configure1 register
|
||||||
|
uint8_t fifo_config1;
|
||||||
|
|
||||||
// temp scaling for FIFO temperature
|
// temp scaling for FIFO temperature
|
||||||
const float temp_sensitivity = 1.0f/2.07;
|
float temp_sensitivity;
|
||||||
const float temp_zero = 25; // degC
|
const float temp_zero = 25; // degC
|
||||||
|
|
||||||
const enum Rotation rotation;
|
const enum Rotation rotation;
|
||||||
|
Loading…
Reference in New Issue
Block a user