|
ICM42670 Portable Driver
Public API reference for the ICM-42670-P IMU driver
|
Core ICM-42670-P initialization, configuration, and read functions. More...

Functions | |
| ICM42670_Status_t | ICM42670_SetPowerState (ICM42670_Config *config, ICM42670_PowerState_t state) |
| Switch the ICM-42670-P to one of the standard datasheet power modes. | |
| ICM42670_Status_t | ICM42670_SetAccelRange (ICM42670_Config *config, ICM42670_AccelFS_t accel_fs) |
| Set the accelerometer full-scale range. | |
| ICM42670_Status_t | ICM42670_SetGyroRange (ICM42670_Config *config, ICM42670_GyroFS_t gyro_fs) |
| Set the gyroscope full-scale range. | |
| ICM42670_Status_t | ICM42670_SetAccelOdr (ICM42670_Config *config, ICM42670_Odr_t odr) |
| Set the accelerometer output data rate. | |
| ICM42670_Status_t | ICM42670_SetGyroOdr (ICM42670_Config *config, ICM42670_Odr_t odr) |
| Set the gyroscope output data rate. | |
| ICM42670_Status_t | ICM42670_SetAccelLpf (ICM42670_Config *config, ICM42670_Lpf_t lpf) |
| Set the accelerometer UI low-pass filter bandwidth. | |
| ICM42670_Status_t | ICM42670_SetGyroLpf (ICM42670_Config *config, ICM42670_Lpf_t lpf) |
| Set the gyroscope UI low-pass filter bandwidth. | |
| ICM42670_Status_t | ICM42670_Init (ICM42670_Config *config) |
| Initialize the device and enter 6-axis low-noise mode. | |
| ICM42670_Status_t | ICM42670_ReadAccelRaw (const ICM42670_Config *config, int16_t accel_raw[3]) |
| Read raw accelerometer counts. | |
| ICM42670_Status_t | ICM42670_ReadGyroRaw (const ICM42670_Config *config, int16_t gyro_raw[3]) |
| Read raw gyroscope counts. | |
| ICM42670_Status_t | ICM42670_ReadTempRaw (const ICM42670_Config *config, int16_t *temp_raw) |
| Read the raw temperature register value. | |
| ICM42670_Status_t | ICM42670_ReadAccelG (const ICM42670_Config *config, ICM42670_Accel_t *accel) |
| Read accelerometer data converted to g. | |
| ICM42670_Status_t | ICM42670_ReadGyroDps (const ICM42670_Config *config, ICM42670_Gyro_t *gyro) |
| Read gyroscope data converted to degrees per second. | |
| ICM42670_Status_t | ICM42670_ReadTempC (const ICM42670_Config *config, float *temp_c) |
| Read temperature converted to degrees Celsius. | |
| ICM42670_Status_t | ICM42670_Gyro_Calibration (ICM42670_Config *config) |
| Estimate gyroscope bias while the board is stationary. | |
Core ICM-42670-P initialization, configuration, and read functions.
| ICM42670_Status_t ICM42670_Gyro_Calibration | ( | ICM42670_Config * | config | ) |
Estimate gyroscope bias while the board is stationary.
This averages raw gyro samples and stores the offsets in config.
| config | Driver configuration with read and delay callbacks. |
References ICM42670_Config::delay_ms, ICM42670_Config::gyro_offsets, ICM42670_ERROR, ICM42670_OK, ICM42670_ReadGyroRaw(), ICM42670_Gyro_Offsets_t::x_raw_offset, ICM42670_Gyro_Offsets_t::y_raw_offset, and ICM42670_Gyro_Offsets_t::z_raw_offset.
| ICM42670_Status_t ICM42670_Init | ( | ICM42670_Config * | config | ) |
Initialize the device and enter 6-axis low-noise mode.
The function validates callbacks, checks WHO_AM_I, normalizes invalid range/ODR values to defaults, writes accel/gyro configuration, and enables both sensors.
| config | Driver configuration with valid callbacks. |
References ICM42670_Config::accel_fs, ICM42670_Config::accel_odr, ICM42670_Config::delay_ms, ICM42670_Config::gyro_fs, ICM42670_Config::gyro_odr, ICM42670_Config::handle, ICM42670_ERROR, ICM42670_OK, ICM42670_POWER_6AXIS_LN, ICM42670_SetPowerState(), ICM42670_Config::read_reg, and ICM42670_Config::write_reg.
| ICM42670_Status_t ICM42670_ReadAccelG | ( | const ICM42670_Config * | config, |
| ICM42670_Accel_t * | accel | ||
| ) |
Read accelerometer data converted to g.
| config | Driver configuration with current accel_fs value. |
| accel | Destination for scaled acceleration. |
References ICM42670_Config::accel_fs, ICM42670_ERROR, ICM42670_OK, ICM42670_ReadAccelRaw(), ICM42670_Accel_t::x_g, ICM42670_Accel_t::y_g, and ICM42670_Accel_t::z_g.
| ICM42670_Status_t ICM42670_ReadAccelRaw | ( | const ICM42670_Config * | config, |
| int16_t | accel_raw[3] | ||
| ) |
Read raw accelerometer counts.
| config | Driver configuration with a read callback. |
| accel_raw | Destination array: X, Y, Z raw counts. |
References ICM42670_Config::handle, ICM42670_ERROR, ICM42670_OK, and ICM42670_Config::read_reg.
Referenced by ICM42670_ReadAccelG().
| ICM42670_Status_t ICM42670_ReadGyroDps | ( | const ICM42670_Config * | config, |
| ICM42670_Gyro_t * | gyro | ||
| ) |
Read gyroscope data converted to degrees per second.
Configured gyro_offsets are subtracted before scaling.
| config | Driver configuration with current gyro_fs value. |
| gyro | Destination for scaled angular rate. |
References ICM42670_Config::gyro_fs, ICM42670_Config::gyro_offsets, ICM42670_ERROR, ICM42670_OK, ICM42670_ReadGyroRaw(), ICM42670_Gyro_t::x_dps, ICM42670_Gyro_Offsets_t::x_raw_offset, ICM42670_Gyro_t::y_dps, ICM42670_Gyro_Offsets_t::y_raw_offset, ICM42670_Gyro_t::z_dps, and ICM42670_Gyro_Offsets_t::z_raw_offset.
| ICM42670_Status_t ICM42670_ReadGyroRaw | ( | const ICM42670_Config * | config, |
| int16_t | gyro_raw[3] | ||
| ) |
Read raw gyroscope counts.
| config | Driver configuration with a read callback. |
| gyro_raw | Destination array: X, Y, Z raw counts. |
References ICM42670_Config::handle, ICM42670_ERROR, ICM42670_OK, and ICM42670_Config::read_reg.
Referenced by ICM42670_Gyro_Calibration(), and ICM42670_ReadGyroDps().
| ICM42670_Status_t ICM42670_ReadTempC | ( | const ICM42670_Config * | config, |
| float * | temp_c | ||
| ) |
Read temperature converted to degrees Celsius.
| config | Driver configuration with a read callback. |
| temp_c | Destination for temperature in degrees Celsius. |
References ICM42670_ERROR, ICM42670_OK, and ICM42670_ReadTempRaw().
| ICM42670_Status_t ICM42670_ReadTempRaw | ( | const ICM42670_Config * | config, |
| int16_t * | temp_raw | ||
| ) |
Read the raw temperature register value.
| config | Driver configuration with a read callback. |
| temp_raw | Destination for the signed raw temperature count. |
References ICM42670_Config::handle, ICM42670_ERROR, ICM42670_OK, ICM42670_REG_TEMP_DATA1, and ICM42670_Config::read_reg.
Referenced by ICM42670_ReadTempC().
| ICM42670_Status_t ICM42670_SetAccelLpf | ( | ICM42670_Config * | config, |
| ICM42670_Lpf_t | lpf | ||
| ) |
Set the accelerometer UI low-pass filter bandwidth.
| config | Driver configuration with read and write callbacks. |
| lpf | Low-pass filter selection. |
| ICM42670_Status_t ICM42670_SetAccelOdr | ( | ICM42670_Config * | config, |
| ICM42670_Odr_t | odr | ||
| ) |
Set the accelerometer output data rate.
| config | Driver configuration with read and write callbacks. |
| odr | Accelerometer output data rate. |
References ICM42670_Config::accel_odr, ICM42670_ERROR, and ICM42670_OK.
| ICM42670_Status_t ICM42670_SetAccelRange | ( | ICM42670_Config * | config, |
| ICM42670_AccelFS_t | accel_fs | ||
| ) |
Set the accelerometer full-scale range.
| config | Driver configuration with read and write callbacks. |
| accel_fs | Accelerometer range selection. |
References ICM42670_Config::accel_fs, ICM42670_ERROR, and ICM42670_OK.
| ICM42670_Status_t ICM42670_SetGyroLpf | ( | ICM42670_Config * | config, |
| ICM42670_Lpf_t | lpf | ||
| ) |
Set the gyroscope UI low-pass filter bandwidth.
| config | Driver configuration with read and write callbacks. |
| lpf | Low-pass filter selection. |
| ICM42670_Status_t ICM42670_SetGyroOdr | ( | ICM42670_Config * | config, |
| ICM42670_Odr_t | odr | ||
| ) |
Set the gyroscope output data rate.
| config | Driver configuration with read and write callbacks. |
| odr | Gyroscope output data rate. |
References ICM42670_Config::gyro_odr, ICM42670_ERROR, and ICM42670_OK.
| ICM42670_Status_t ICM42670_SetGyroRange | ( | ICM42670_Config * | config, |
| ICM42670_GyroFS_t | gyro_fs | ||
| ) |
Set the gyroscope full-scale range.
| config | Driver configuration with read and write callbacks. |
| gyro_fs | Gyroscope range selection. |
References ICM42670_Config::gyro_fs, ICM42670_ERROR, and ICM42670_OK.
| ICM42670_Status_t ICM42670_SetPowerState | ( | ICM42670_Config * | config, |
| ICM42670_PowerState_t | state | ||
| ) |
Switch the ICM-42670-P to one of the standard datasheet power modes.
This writes PWR_MGMT0 and then waits 1 ms so the datasheet's 200 us no-register-write window is respected when either sensor transitions from off to an active mode. Gyro off/on timing and accel LP ODR/filter restrictions remain caller responsibilities.
| config | Driver configuration with write and delay callbacks. |
| state | Target power state. |
References ICM42670_Config::delay_ms, ICM42670_Config::handle, ICM42670_ERROR, ICM42670_OK, and ICM42670_Config::write_reg.
Referenced by ICM42670_Init().