19 #ifndef _ADAFRUIT_ICM20X_H 20 #define _ADAFRUIT_ICM20X_H 23 #include <Adafruit_BusIO_Register.h> 24 #include <Adafruit_I2CDevice.h> 25 #include <Adafruit_Sensor.h> 29 #define I2C_MASTER_RESETS_BEFORE_FAIL \ 31 #define NUM_FINISHED_CHECKS \ 36 #define ICM20X_B0_WHOAMI 0x00 37 #define ICM20X_B0_USER_CTRL 0x03 38 #define ICM20X_B0_LP_CONFIG 0x05 39 #define ICM20X_B0_REG_INT_PIN_CFG 0xF 40 #define ICM20X_B0_REG_INT_ENABLE 0x10 41 #define ICM20X_B0_REG_INT_ENABLE_1 0x11 42 #define ICM20X_B0_I2C_MST_STATUS \ 44 #define ICM20X_B0_REG_BANK_SEL 0x7F 45 #define ICM20X_B0_PWR_MGMT_1 0x06 46 #define ICM20X_B0_ACCEL_XOUT_H 0x2D 47 #define ICM20X_B0_GYRO_XOUT_H 0x33 50 #define ICM20X_B2_GYRO_SMPLRT_DIV 0x00 51 #define ICM20X_B2_GYRO_CONFIG_1 0x01 52 #define ICM20X_B2_ACCEL_SMPLRT_DIV_1 0x10 53 #define ICM20X_B2_ACCEL_SMPLRT_DIV_2 0x11 54 #define ICM20X_B2_ACCEL_CONFIG_1 0x14 57 #define ICM20X_B3_I2C_MST_ODR_CONFIG 0x0 58 #define ICM20X_B3_I2C_MST_CTRL 0x1 59 #define ICM20X_B3_I2C_MST_DELAY_CTRL 0x2 60 #define ICM20X_B3_I2C_SLV0_ADDR \ 62 #define ICM20X_B3_I2C_SLV0_REG \ 64 #define ICM20X_B3_I2C_SLV0_CTRL 0x5 65 #define ICM20X_B3_I2C_SLV0_DO 0x6 67 #define ICM20X_B3_I2C_SLV4_ADDR \ 69 #define ICM20X_B3_I2C_SLV4_REG \ 71 #define ICM20X_B3_I2C_SLV4_CTRL 0x15 72 #define ICM20X_B3_I2C_SLV4_DO 0x16 73 #define ICM20X_B3_I2C_SLV4_DI 0x17 75 #define ICM20948_CHIP_ID 0xEA 76 #define ICM20649_CHIP_ID 0xE1 80 ICM20X_ACCEL_FREQ_246_0_HZ = 0x1,
81 ICM20X_ACCEL_FREQ_111_4_HZ = 0x2,
82 ICM20X_ACCEL_FREQ_50_4_HZ = 0x3,
83 ICM20X_ACCEL_FREQ_23_9_HZ = 0x4,
84 ICM20X_ACCEL_FREQ_11_5_HZ = 0x5,
85 ICM20X_ACCEL_FREQ_5_7_HZ = 0x6,
86 ICM20X_ACCEL_FREQ_473_HZ = 0x7,
91 ICM20X_GYRO_FREQ_196_6_HZ = 0x0,
92 ICM20X_GYRO_FREQ_151_8_HZ = 0x1,
93 ICM20X_GYRO_FREQ_119_5_HZ = 0x2,
94 ICM20X_GYRO_FREQ_51_2_HZ = 0x3,
95 ICM20X_GYRO_FREQ_23_9_HZ = 0x4,
96 ICM20X_GYRO_FREQ_11_6_HZ = 0x5,
97 ICM20X_GYRO_FREQ_5_7_HZ = 0x6,
98 ICM20X_GYRO_FREQ_361_4_HZ = 0x7,
117 int _sensorID = 0x20A;
131 int _sensorID = 0x20B;
146 int _sensorID = 0x20C;
160 int _sensorID = 0x20D;
173 bool begin_SPI(uint8_t cs_pin, SPIClass *theSPI = &SPI,
174 int32_t sensor_id = 0);
175 bool begin_SPI(int8_t cs_pin, int8_t sck_pin, int8_t miso_pin,
176 int8_t mosi_pin, int32_t sensor_id = 0);
178 uint8_t getGyroRateDivisor(
void);
179 void setGyroRateDivisor(uint8_t new_gyro_divisor);
181 uint16_t getAccelRateDivisor(
void);
182 void setAccelRateDivisor(uint16_t new_accel_divisor);
190 void setInt1ActiveLow(
bool active_low);
191 void setInt2ActiveLow(
bool active_low);
193 Adafruit_Sensor *getAccelerometerSensor(
void);
194 Adafruit_Sensor *getGyroSensor(
void);
195 Adafruit_Sensor *getMagnetometerSensor(
void);
196 Adafruit_Sensor *getTemperatureSensor(
void);
198 bool getEvent(sensors_event_t *accel, sensors_event_t *gyro,
199 sensors_event_t *temp, sensors_event_t *mag = NULL);
201 uint8_t readExternalRegister(uint8_t slv_addr, uint8_t reg_addr);
202 bool writeExternalRegister(uint8_t slv_addr, uint8_t reg_addr, uint8_t value);
203 bool configureI2CMaster(
void);
204 bool enableI2CMaster(
bool enable_i2c_master);
205 void resetI2CMaster(
void);
206 void setI2CBypass(
bool bypass_i2c);
220 Adafruit_I2CDevice *i2c_dev = NULL;
221 Adafruit_SPIDevice *spi_dev = NULL;
229 uint16_t _sensorid_accel,
235 virtual void scaleValues(
void);
236 virtual bool begin_I2C(uint8_t i2c_add, TwoWire *wire, int32_t sensor_id);
238 bool _init(int32_t sensor_id);
253 void _setBank(uint8_t bank_number);
255 uint8_t readAccelRange(
void);
256 void writeAccelRange(uint8_t new_accel_range);
258 uint8_t readGyroRange(
void);
259 void writeGyroRange(uint8_t new_gyro_range);
274 void fillAccelEvent(sensors_event_t *accel, uint32_t timestamp);
275 void fillGyroEvent(sensors_event_t *gyro, uint32_t timestamp);
276 void fillTempEvent(sensors_event_t *temp, uint32_t timestamp);
277 void fillMagEvent(sensors_event_t *mag, uint32_t timestamp);
278 uint8_t auxillaryRegisterTransaction(
bool read, uint8_t slv_addr,
279 uint8_t reg_addr, uint8_t value = -1);
Definition: Adafruit_ICM20X.h:122
Adafruit_ICM20X_Accelerometer(Adafruit_ICM20X *parent)
Create an Adafruit_Sensor compatible object for the accelerometer sensor.
Definition: Adafruit_ICM20X.h:110
uint8_t current_gyro_range
gyro range cache
Definition: Adafruit_ICM20X.h:251
Definition: Adafruit_ICM20X.h:136
Class that stores state and functions for interacting with the ST ICM20X 6-DoF Accelerometer and Gyro...
Definition: Adafruit_ICM20X.h:168
int16_t rawTemp
temp variables
Definition: Adafruit_ICM20X.h:239
void getSensor(sensor_t *)
Gets the sensor_t data for the ICM20X's accelerometer.
Definition: Adafruit_ICM20X.cpp:845
float temperature
Last reading's temperature (C)
Definition: Adafruit_ICM20X.h:209
uint8_t current_accel_range
accelerometer range cache
Definition: Adafruit_ICM20X.h:250
icm20x_gyro_cutoff_t
Definition: Adafruit_ICM20X.h:90
Definition: Adafruit_ICM20X.h:151
Adafruit_ICM20X_Magnetometer(Adafruit_ICM20X *parent)
Create an Adafruit_Sensor compatible object for the magnetometer sensor.
Definition: Adafruit_ICM20X.h:141
uint16_t _sensorid_temp
ID number for temperature.
Definition: Adafruit_ICM20X.h:229
bool getEvent(sensors_event_t *)
Gets the accelerometer as a standard sensor event.
Definition: Adafruit_ICM20X.cpp:869
Definition: Adafruit_ICM20X.h:105
Adafruit_ICM20X_Gyro(Adafruit_ICM20X *parent)
Create an Adafruit_Sensor compatible object for the gyro sensor.
Definition: Adafruit_ICM20X.h:126
icm20x_accel_cutoff_t
Definition: Adafruit_ICM20X.h:79
Adafruit_ICM20X_Temp(Adafruit_ICM20X *parent)
Create an Adafruit_Sensor compatible object for the temp sensor.
Definition: Adafruit_ICM20X.h:155