Master Thesis
V1.0
Research and Design of Sensor Node for NMSD Treatment
|
Advanced funcions to control and read data from the ICM-20948. More...
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
Functions | |
void | ICM_20948_power (bool enable) |
Turns the GPIO pin high to provide power to the ICM20948. More... | |
void | ICM_20948_Init () |
Init function for ICM20948. More... | |
void | ICM_20948_Init2 () |
Second init function for ICM20948, use when waking from sleep. More... | |
void | ICM_20948_Init_SPI () |
Initiate SPI functionality for ICM20948. More... | |
void | ICM_20948_enable_SPI (bool enable) |
Enables the necessary SPI interface to communicate with ICM20948. More... | |
void | ICM_20948_chipSelectSet (bool enable) |
Set chipselect pin for SPI functionality. More... | |
void | ICM_20948_bankSelect (uint8_t bank) |
Select appropriate bank in ICM20948 based on first bits of address. More... | |
uint8_t | ICM_20948_read (uint16_t addr) |
Read single register from IMU using SPI. More... | |
void | ICM_20948_registerRead (uint16_t addr, int numBytes, uint8_t *data) |
Read registers from IMU. More... | |
void | ICM_20948_printAllData () |
Print all gyro + accel + magn data using dbprint. More... | |
void | ICM_20948_write (uint16_t addr, uint8_t data) |
uint32_t | ICM_20948_sleepModeEnable (bool enable) |
Sleep mode enable function. More... | |
uint32_t | ICM_20948_reset (void) |
Reset IMU. More... | |
uint32_t | ICM_20948_gyroDataRead (float *gyro) |
Read gyroscope data from IMU. More... | |
uint32_t | ICM_20948_gyroResolutionGet (float *gyroRes) |
Set gyro resolution. More... | |
uint32_t | ICM_20948_gyroFullscaleSet (uint8_t gyroFs) |
Set gyroscope full scale range. More... | |
uint32_t | ICM_20948_gyroBandwidthSet (uint8_t gyroBw) |
Set gyroscope bandwidth. More... | |
float | ICM_20948_gyroSampleRateSet (float sampleRate) |
Sets the gyro sample rate. More... | |
uint32_t | ICM_20948_accelDataRead (float *accel) |
Read RAW accelerometer data. More... | |
uint32_t | ICM_20948_accelResolutionGet (float *accelRes) |
Get accelerometer resultion. More... | |
uint32_t | ICM_20948_accelFullscaleSet (uint8_t accelFs) |
Set accelerometer full scale range. More... | |
uint32_t | ICM_20948_accelBandwidthSet (uint8_t accelBw) |
Set acceleromter bandwidth. More... | |
float | ICM_20948_accelSampleRateSet (float sampleRate) |
Sets the accelerometer sample rate. More... | |
uint32_t | ICM_20948_interruptEnable (bool dataReadyEnable, bool womEnable) |
Enable interrupt for data ready or wake on motion. More... | |
uint32_t | ICM_20948_interruptStatusRead (uint32_t *intStatus) |
Read staus of interrupt IMU. More... | |
uint32_t | ICM_20948_wakeOnMotionITEnable (bool enable, uint8_t womThreshold, float sampleRate) |
Set wake on motion interrupt. More... | |
uint32_t | ICM_20948_latchEnable (bool enable) |
Enables / disables the 50 micro seconds interrupt pin functionality. More... | |
uint32_t | ICM_20948_sampleRateSet (float sampleRate) |
Combination function to set sample rate of gyro and accel at once. More... | |
uint32_t | ICM_20948_lowPowerModeEnter (bool enAccel, bool enGyro, bool enTemp) |
Enter low power mode for selected sensors. More... | |
uint32_t | ICM_20948_sensorEnable (bool accel, bool gyro, bool temp) |
Enable selected sensors. More... | |
uint32_t | ICM_20948_cycleModeEnable (bool enable) |
Enable cycle mode on IMU. More... | |
void | ICM_20948_set_mag_transfer (bool read) |
Set magnetometer data transfer on integrated I2C controller inside ICM20948. More... | |
void | ICM_20948_read_mag_register (uint8_t addr, uint8_t numBytes, uint8_t *data) |
Read register in the AK09916 magnetometer device. More... | |
void | ICM_20948_write_mag_register (uint8_t addr, uint8_t data) |
Writes a uint8_t to the I2C address of the magnetometer of the ICM_20948. More... | |
uint32_t | ICM_20948_set_mag_mode (uint8_t magMode) |
Set magnetometer mode (sample rate / on-off) More... | |
void | ICM_20948_magRawDataRead (float *raw_magn) |
Read magnetometer raw values. More... | |
void | ICM_20948_magDataRead (float *magn) |
Convert raw magnetometer values to calibrated and scaled ones. More... | |
uint32_t | ICM_20948_reset_mag (void) |
Reset magnetometer. More... | |
void | ICM_20948_registerWrite (uint16_t addr, uint8_t data) |
Writes registers from IMU. More... | |
void | ICM_20948_magn_to_angle (float *magn, float *angle) |
Test function for non-tilt compensated compass. More... | |
uint32_t | ICM_20948_accelGyroCalibrate (float *accelBiasScaled, float *gyroBiasScaled) |
Accelerometer and gyroscope calibration function. Reads the gyroscope and accelerometer values while the device is at rest and in level. The resulting values are loaded to the accel and gyro bias registers to cancel the static offset error. More... | |
uint32_t | ICM_20948_gyroCalibrate (float *gyroBiasScaled) |
Gyroscope calibration function. Reads the gyroscope values while the device is at rest and in level. The resulting values are loaded to the gyro bias registers to cancel the static offset error. More... | |
uint32_t | ICM_20948_min_max_mag (int16_t *minMag, int16_t *maxMag) |
Calculate minimum and maximum magnetometer values, which are used for calibration. More... | |
bool | ICM_20948_calibrate_mag (float *offset, float *scale) |
Magnetometer calibration function. Get magnetometer minimum and maximum values, while moving the device in a figure eight. Those values are then used to cancel out hard and soft iron distortions. More... | |
Advanced funcions to control and read data from the ICM-20948.
Partly copied from silabs thunderboard code for ICM-20689, partly self written
Definition in file ICM20948.h.
uint32_t ICM_20948_accelBandwidthSet | ( | uint8_t | accelBw | ) |
Set acceleromter bandwidth.
[in] | accelBw | bandwidth, see datasheet for permitted values |
Definition at line 1376 of file ICM20948.c.
References ICM_20948_MASK_ACCEL_BW, ICM_20948_OK, ICM_20948_REG_ACCEL_CONFIG, ICM_20948_registerRead(), and ICM_20948_registerWrite().
Referenced by ICM_20948_accelGyroCalibrate(), and ICM_20948_wakeOnMotionITEnable().
uint32_t ICM_20948_accelDataRead | ( | float * | accel | ) |
Read RAW accelerometer data.
[out] | accel | pointer to resulting memory locaion |
Definition at line 1170 of file ICM20948.c.
References ICM_20948_accelResolutionGet(), ICM_20948_OK, ICM_20948_REG_ACCEL_XOUT_H_SH, and ICM_20948_registerRead().
Referenced by measure_send().
uint32_t ICM_20948_accelFullscaleSet | ( | uint8_t | accelFs | ) |
Set accelerometer full scale range.
[in] | accelFs | full scale range, see datasheet for permitted values |
Definition at line 1242 of file ICM20948.c.
References ICM_20948_MASK_ACCEL_FULLSCALE, ICM_20948_OK, ICM_20948_REG_ACCEL_CONFIG, ICM_20948_registerRead(), and ICM_20948_registerWrite().
Referenced by ICM_20948_accelGyroCalibrate(), ICM_20948_Init2(), and ICM_20948_wakeOnMotionITEnable().
uint32_t ICM_20948_accelGyroCalibrate | ( | float * | accelBiasScaled, |
float * | gyroBiasScaled | ||
) |
Accelerometer and gyroscope calibration function. Reads the gyroscope and accelerometer values while the device is at rest and in level. The resulting values are loaded to the accel and gyro bias registers to cancel the static offset error.
[out] | accelBiasScaled | The mesured acceleration sensor bias in mg |
[out] | gyroBiasScaled | The mesured gyro sensor bias in deg/sec |
Definition at line 1820 of file ICM20948.c.
References data, delay(), ICM_20948_ACCEL_BW_246HZ, ICM_20948_ACCEL_FULLSCALE_2G, ICM_20948_accelBandwidthSet(), ICM_20948_accelFullscaleSet(), ICM_20948_accelResolutionGet(), ICM_20948_BIT_ACCEL_FIFO_EN, ICM_20948_BIT_FIFO_EN, ICM_20948_BITS_GYRO_FIFO_EN, ICM_20948_GYRO_BW_12HZ, ICM_20948_GYRO_FULLSCALE_250DPS, ICM_20948_gyroBandwidthSet(), ICM_20948_gyroFullscaleSet(), ICM_20948_gyroResolutionGet(), ICM_20948_OK, ICM_20948_REG_FIFO_COUNT_H, ICM_20948_REG_FIFO_EN_2, ICM_20948_REG_FIFO_MODE, ICM_20948_REG_FIFO_R_W, ICM_20948_REG_FIFO_RST, ICM_20948_REG_USER_CTRL, ICM_20948_REG_XA_OFFSET_H, ICM_20948_REG_XA_OFFSET_L, ICM_20948_REG_XG_OFFS_USRH, ICM_20948_REG_XG_OFFS_USRL, ICM_20948_REG_YA_OFFSET_H, ICM_20948_REG_YA_OFFSET_L, ICM_20948_REG_YG_OFFS_USRH, ICM_20948_REG_YG_OFFS_USRL, ICM_20948_REG_ZA_OFFSET_H, ICM_20948_REG_ZA_OFFSET_L, ICM_20948_REG_ZG_OFFS_USRH, ICM_20948_REG_ZG_OFFS_USRL, ICM_20948_registerRead(), ICM_20948_registerWrite(), ICM_20948_sampleRateSet(), and ICM_20948_sensorEnable().
Referenced by ICM_20948_Init().
uint32_t ICM_20948_accelResolutionGet | ( | float * | accelRes | ) |
Get accelerometer resultion.
[out] | accelRes | pointer to accelerometer resulution |
Definition at line 1202 of file ICM20948.c.
References ICM_20948_ACCEL_FULLSCALE_16G, ICM_20948_ACCEL_FULLSCALE_2G, ICM_20948_ACCEL_FULLSCALE_4G, ICM_20948_ACCEL_FULLSCALE_8G, ICM_20948_MASK_ACCEL_FULLSCALE, ICM_20948_OK, ICM_20948_REG_ACCEL_CONFIG, and ICM_20948_registerRead().
Referenced by ICM_20948_accelDataRead(), and ICM_20948_accelGyroCalibrate().
float ICM_20948_accelSampleRateSet | ( | float | sampleRate | ) |
Sets the accelerometer sample rate.
will automatically calculate a sample rate that fits the sample rate divider register
[in/out] | sampleRate desired sample rate |
Definition at line 988 of file ICM20948.c.
References ICM_20948_REG_ACCEL_SMPLRT_DIV_1, ICM_20948_REG_ACCEL_SMPLRT_DIV_2, and ICM_20948_registerWrite().
Referenced by ICM_20948_sampleRateSet().
void ICM_20948_bankSelect | ( | uint8_t | bank | ) |
Select appropriate bank in ICM20948 based on first bits of address.
wBuffer[0] = ICM_20948_REG_BANK_SEL; wBuffer[1] = (bank << 4);
[in] | bank | Register to be read |
Definition at line 528 of file ICM20948.c.
References ICM_20948_I2C_ADDRESS, ICM_20948_REG_BANK_SEL, and IIC_WriteBuffer().
Referenced by ICM_20948_read(), ICM_20948_registerRead(), and ICM_20948_registerWrite().
bool ICM_20948_calibrate_mag | ( | float * | offset, |
float * | scale | ||
) |
Magnetometer calibration function. Get magnetometer minimum and maximum values, while moving the device in a figure eight. Those values are then used to cancel out hard and soft iron distortions.
Magnetometer calibration function. Get magnetometer minimum and maximum values, while moving the device in a figure eight. Those values are then used to cancel out hard and soft iron distortions.
[out] | offset | Magnetometer XYZ axis hard iron distortion correction. |
[out] | scale | Magnetometer XYZ axis soft iron distortion correction. |
Definition at line 2289 of file ICM20948.c.
Referenced by ICM_20948_Init().
void ICM_20948_chipSelectSet | ( | bool | enable | ) |
Set chipselect pin for SPI functionality.
Only when using SPI
[in] | enable |
|
Definition at line 480 of file ICM20948.c.
References ICM_20948_CS_PIN, and ICM_20948_CS_PORT.
Referenced by ICM_20948_read().
uint32_t ICM_20948_cycleModeEnable | ( | bool | enable | ) |
Enable cycle mode on IMU.
[in/out] | enable
|
Definition at line 1142 of file ICM20948.c.
References ICM_20948_BIT_ACCEL_CYCLE, ICM_20948_BIT_GYRO_CYCLE, ICM_20948_OK, ICM_20948_REG_LP_CONFIG, and ICM_20948_registerWrite().
Referenced by ICM_20948_lowPowerModeEnter(), and ICM_20948_wakeOnMotionITEnable().
void ICM_20948_enable_SPI | ( | bool | enable | ) |
Enables the necessary SPI interface to communicate with ICM20948.
[in] | enable |
|
Definition at line 344 of file ICM20948.c.
References ICM_20948_CLK_PIN, ICM_20948_CLK_PORT, ICM_20948_CS_PIN, ICM_20948_CS_PORT, ICM_20948_MISO_PIN, ICM_20948_MISO_PORT, ICM_20948_MOSI_PIN, and ICM_20948_MOSI_PORT.
uint32_t ICM_20948_gyroBandwidthSet | ( | uint8_t | gyroBw | ) |
Set gyroscope bandwidth.
[in] | gyroBw | bandwidth, see datasheet for permitted values |
Definition at line 1352 of file ICM20948.c.
References ICM_20948_MASK_GYRO_BW, ICM_20948_OK, ICM_20948_REG_GYRO_CONFIG_1, ICM_20948_registerRead(), and ICM_20948_registerWrite().
Referenced by ICM_20948_accelGyroCalibrate(), and ICM_20948_gyroCalibrate().
uint32_t ICM_20948_gyroCalibrate | ( | float * | gyroBiasScaled | ) |
Gyroscope calibration function. Reads the gyroscope values while the device is at rest and in level. The resulting values are loaded to the gyro bias registers to cancel the static offset error.
[out] | gyroBiasScaled | The mesured gyro sensor bias in deg/sec |
Definition at line 2031 of file ICM20948.c.
References data, delay(), ICM_20948_BIT_FIFO_EN, ICM_20948_BITS_GYRO_FIFO_EN, ICM_20948_GYRO_BW_12HZ, ICM_20948_GYRO_FULLSCALE_250DPS, ICM_20948_gyroBandwidthSet(), ICM_20948_gyroFullscaleSet(), ICM_20948_gyroResolutionGet(), ICM_20948_OK, ICM_20948_REG_FIFO_COUNT_H, ICM_20948_REG_FIFO_EN_2, ICM_20948_REG_FIFO_MODE, ICM_20948_REG_FIFO_R_W, ICM_20948_REG_FIFO_RST, ICM_20948_REG_USER_CTRL, ICM_20948_REG_XG_OFFS_USRH, ICM_20948_REG_XG_OFFS_USRL, ICM_20948_REG_YG_OFFS_USRH, ICM_20948_REG_YG_OFFS_USRL, ICM_20948_REG_ZG_OFFS_USRH, ICM_20948_REG_ZG_OFFS_USRL, ICM_20948_registerRead(), ICM_20948_registerWrite(), ICM_20948_sampleRateSet(), and ICM_20948_sensorEnable().
uint32_t ICM_20948_gyroDataRead | ( | float * | gyro | ) |
Read gyroscope data from IMU.
[out] | gyro | pointer to store data |
Definition at line 783 of file ICM20948.c.
References GYRO_XOUT_H, ICM_20948_gyroResolutionGet(), ICM_20948_OK, and ICM_20948_registerRead().
Referenced by measure_send().
uint32_t ICM_20948_gyroFullscaleSet | ( | uint8_t | gyroFs | ) |
Set gyroscope full scale range.
[in] | gyroFs | full scale range, see datasheet for permitted values |
Definition at line 1265 of file ICM20948.c.
References ICM_20948_MASK_GYRO_FULLSCALE, ICM_20948_OK, ICM_20948_REG_GYRO_CONFIG_1, ICM_20948_registerRead(), and ICM_20948_registerWrite().
Referenced by ICM_20948_accelGyroCalibrate(), ICM_20948_gyroCalibrate(), and ICM_20948_Init2().
uint32_t ICM_20948_gyroResolutionGet | ( | float * | gyroRes | ) |
Set gyro resolution.
[in/out] | gyroRes gyro resulution input gyro actual resolution output |
Definition at line 817 of file ICM20948.c.
References ICM_20948_GYRO_FULLSCALE_1000DPS, ICM_20948_GYRO_FULLSCALE_2000DPS, ICM_20948_GYRO_FULLSCALE_250DPS, ICM_20948_GYRO_FULLSCALE_500DPS, ICM_20948_MASK_GYRO_FULLSCALE, ICM_20948_OK, ICM_20948_REG_GYRO_CONFIG_1, and ICM_20948_registerRead().
Referenced by ICM_20948_accelGyroCalibrate(), ICM_20948_gyroCalibrate(), and ICM_20948_gyroDataRead().
float ICM_20948_gyroSampleRateSet | ( | float | sampleRate | ) |
Sets the gyro sample rate.
will automatically calculate a sample rate that fits the sample rate divider register
[in/out] | sampleRate desired sample rate |
Definition at line 947 of file ICM20948.c.
References ICM_20948_REG_GYRO_SMPLRT_DIV, and ICM_20948_registerWrite().
Referenced by ICM_20948_sampleRateSet().
void ICM_20948_Init | ( | ) |
Init function for ICM20948.
I2C init Power on IMU Reset IMU Init 2 Calibrate Gyro + Accel Calibrate Magn
Definition at line 85 of file ICM20948.c.
References AK09916_MODE_100HZ, delay(), ICM_20948_accelGyroCalibrate(), ICM_20948_calibrate_mag(), ICM_20948_Init2(), ICM_20948_Initialized, ICM_20948_power(), ICM_20948_read_mag_register(), ICM_20948_reset(), ICM_20948_set_mag_mode(), IIC_Init(), LED_PIN, and LED_PORT.
void ICM_20948_Init2 | ( | ) |
Second init function for ICM20948, use when waking from sleep.
Set sample rates, bandwidths, check whoAmI, enable sensors
Definition at line 169 of file ICM20948.c.
References AK09916_DEVICE_ID, AK09916_MODE_50HZ, AK09916_REG_WHO_AM_I, dbprint(), delay(), ICM20948_DEVICE_ID, ICM_20948_ACCEL_FULLSCALE_4G, ICM_20948_accelFullscaleSet(), ICM_20948_BIT_CLK_PLL, ICM_20948_GYRO_FULLSCALE_2000DPS, ICM_20948_gyroFullscaleSet(), ICM_20948_latchEnable(), ICM_20948_read_mag_register(), ICM_20948_REG_INT_PIN_CFG, ICM_20948_REG_PWR_MGMT_1, ICM_20948_REG_WHO_AM_I, ICM_20948_registerRead(), ICM_20948_registerWrite(), ICM_20948_sampleRateSet(), ICM_20948_sensorEnable(), ICM_20948_set_mag_mode(), ICM_20948_sleepModeEnable(), and ICM_20948_write_mag_register().
Referenced by ICM_20948_Init().
void ICM_20948_Init_SPI | ( | ) |
Initiate SPI functionality for ICM20948.
Definition at line 273 of file ICM20948.c.
References ICM_20948_CLK_PIN, ICM_20948_CLK_PORT, ICM_20948_CS_PIN, ICM_20948_CS_PORT, ICM_20948_MISO_PIN, ICM_20948_MISO_PORT, ICM_20948_MOSI_PIN, and ICM_20948_MOSI_PORT.
uint32_t ICM_20948_interruptEnable | ( | bool | dataReadyEnable, |
bool | womEnable | ||
) |
Enable interrupt for data ready or wake on motion.
[in] | dataReadyEnable |
|
[in] | womEnable |
|
Definition at line 885 of file ICM20948.c.
References ICM_20948_BIT_RAW_DATA_0_RDY_EN, ICM_20948_BIT_WOM_INT_EN, ICM_20948_OK, ICM_20948_REG_INT_ENABLE, ICM_20948_REG_INT_ENABLE_1, and ICM_20948_registerWrite().
Referenced by CheckIMUidle(), and ICM_20948_wakeOnMotionITEnable().
uint32_t ICM_20948_interruptStatusRead | ( | uint32_t * | intStatus | ) |
Read staus of interrupt IMU.
[out] | intStatus | pointer to store status |
Definition at line 857 of file ICM20948.c.
References ICM_20948_OK, ICM_20948_REG_INT_STATUS, and ICM_20948_registerRead().
uint32_t ICM_20948_latchEnable | ( | bool | enable | ) |
Enables / disables the 50 micro seconds interrupt pin functionality.
[in] | enable |
|
Definition at line 1403 of file ICM20948.c.
References ICM_20948_OK, ICM_20948_REG_INT_PIN_CFG, ICM_20948_registerRead(), and ICM_20948_registerWrite().
Referenced by ICM_20948_Init2().
uint32_t ICM_20948_lowPowerModeEnter | ( | bool | enAccel, |
bool | enGyro, | ||
bool | enTemp | ||
) |
Enter low power mode for selected sensors.
[in] | enAccel |
|
[in] | enGyro |
|
[in] | enTemp |
|
Definition at line 1037 of file ICM20948.c.
References data, delay(), ICM_20948_BIT_LP_EN, ICM_20948_cycleModeEnable(), ICM_20948_OK, ICM_20948_REG_PWR_MGMT_1, ICM_20948_registerRead(), ICM_20948_registerWrite(), ICM_20948_sensorEnable(), and ICM_20948_sleepModeEnable().
Referenced by ICM_20948_wakeOnMotionITEnable().
void ICM_20948_magDataRead | ( | float * | magn | ) |
Convert raw magnetometer values to calibrated and scaled ones.
[out] | magn | calibrated values in µT |
Definition at line 1745 of file ICM20948.c.
References _hxcounts, _hycounts, _hzcounts, _magScale, data, ICM_20948_read_mag_register(), and tX.
Referenced by ICM_20948_min_max_mag(), and measure_send().
void ICM_20948_magn_to_angle | ( | float * | magn, |
float * | angle | ||
) |
Test function for non-tilt compensated compass.
[in] | magn | magnetometer values |
[out] | angle | angle in degrees |
Definition at line 1793 of file ICM20948.c.
References M_PI.
void ICM_20948_magRawDataRead | ( | float * | raw_magn | ) |
Read magnetometer raw values.
[out] | raw_magn | output magnetometer raw values |
Definition at line 1707 of file ICM20948.c.
References _hxcounts, _hycounts, _hzcounts, data, dbprint(), dbprintInt(), dbprintln(), ICM_20948_read_mag_register(), tX, tY, and tZ.
uint32_t ICM_20948_min_max_mag | ( | int16_t * | minMag, |
int16_t * | maxMag | ||
) |
Calculate minimum and maximum magnetometer values, which are used for calibration.
[out] | minMag | pointer to minima from each axis |
[out] | maxMag | pointer to maxima from each axis |
Definition at line 2186 of file ICM20948.c.
References dbprint(), dbprintInt(), dbprintln(), ICM_20948_magDataRead(), mag_minimumRange, millis(), and OK.
void ICM_20948_power | ( | bool | enable | ) |
Turns the GPIO pin high to provide power to the ICM20948.
[in] | enable |
|
Definition at line 392 of file ICM20948.c.
References ICM_20948_POWER_PIN, and ICM_20948_POWER_PORT.
Referenced by ICM_20948_Init().
void ICM_20948_printAllData | ( | ) |
Print all gyro + accel + magn data using dbprint.
Definition at line 414 of file ICM20948.c.
References dbprint(), dbprintInt(), and dbprintlnInt().
uint8_t ICM_20948_read | ( | uint16_t | addr | ) |
Read single register from IMU using SPI.
[in] | addr | address 16 bits - first bits are bank, the rest of the bits is the address |
Definition at line 545 of file ICM20948.c.
References data, ICM_20948_bankSelect(), ICM_20948_chipSelectSet(), and SPI.
Referenced by ICM_20948_check_WhoAmI(), readMagRegister(), and waitForSlave4().
void ICM_20948_read_mag_register | ( | uint8_t | addr, |
uint8_t | numBytes, | ||
uint8_t * | data | ||
) |
Read register in the AK09916 magnetometer device.
[in] | addr | Register address to read from Bit[6:0] - register address |
[in] | numBytes | Number of bytes to read |
[out] | data | Data read from register |
Definition at line 1594 of file ICM20948.c.
References AK09916_BIT_I2C_SLV_ADDR, data, and IIC_WriteReadBuffer().
Referenced by ICM_20948_Init(), ICM_20948_Init2(), ICM_20948_magDataRead(), and ICM_20948_magRawDataRead().
void ICM_20948_registerRead | ( | uint16_t | addr, |
int | numBytes, | ||
uint8_t * | data | ||
) |
Read registers from IMU.
Using I2C
[in] | addr | address |
[in] | numBytes | numer of bytes to read |
[out] | data | pointer to store data |
Definition at line 654 of file ICM20948.c.
References data, ICM_20948_bankSelect(), ICM_20948_I2C_ADDRESS, and IIC_WriteReadBuffer().
Referenced by ICM_20948_accelBandwidthSet(), ICM_20948_accelDataRead(), ICM_20948_accelFullscaleSet(), ICM_20948_accelGyroCalibrate(), ICM_20948_accelResolutionGet(), ICM_20948_gyroBandwidthSet(), ICM_20948_gyroCalibrate(), ICM_20948_gyroDataRead(), ICM_20948_gyroFullscaleSet(), ICM_20948_gyroResolutionGet(), ICM_20948_Init2(), ICM_20948_interruptStatusRead(), ICM_20948_latchEnable(), ICM_20948_lowPowerModeEnter(), ICM_20948_sensorEnable(), and ICM_20948_sleepModeEnable().
void ICM_20948_registerWrite | ( | uint16_t | addr, |
uint8_t | data | ||
) |
Writes registers from IMU.
Using I2C
[in] | addr | address |
[out] | data | data to be written |
Definition at line 697 of file ICM20948.c.
References data, ICM_20948_bankSelect(), ICM_20948_I2C_ADDRESS, and IIC_WriteBuffer().
Referenced by ICM_20948_accelBandwidthSet(), ICM_20948_accelFullscaleSet(), ICM_20948_accelGyroCalibrate(), ICM_20948_accelSampleRateSet(), ICM_20948_cycleModeEnable(), ICM_20948_gyroBandwidthSet(), ICM_20948_gyroCalibrate(), ICM_20948_gyroFullscaleSet(), ICM_20948_gyroSampleRateSet(), ICM_20948_Init2(), ICM_20948_interruptEnable(), ICM_20948_latchEnable(), ICM_20948_lowPowerModeEnter(), ICM_20948_reset(), ICM_20948_sensorEnable(), ICM_20948_set_mag_transfer(), ICM_20948_sleepModeEnable(), ICM_20948_wakeOnMotionITEnable(), readMagRegister(), and writeMagRegister().
uint32_t ICM_20948_reset | ( | void | ) |
Reset IMU.
Definition at line 762 of file ICM20948.c.
References delay(), ICM_20948_BIT_H_RESET, ICM_20948_OK, ICM_20948_REG_PWR_MGMT_1, and ICM_20948_registerWrite().
Referenced by ICM_20948_Init().
uint32_t ICM_20948_reset_mag | ( | void | ) |
Reset magnetometer.
Definition at line 1768 of file ICM20948.c.
References AK09916_BIT_SRST, AK09916_REG_CONTROL_3, delay(), ICM_20948_write_mag_register(), and OK.
uint32_t ICM_20948_sampleRateSet | ( | float | sampleRate | ) |
Combination function to set sample rate of gyro and accel at once.
will automatically calculate a sample rate that fits the sample rate divider register
[in/out] | sampleRate desired sample rate |
Definition at line 924 of file ICM20948.c.
References ICM_20948_accelSampleRateSet(), ICM_20948_gyroSampleRateSet(), and ICM_20948_OK.
Referenced by ICM_20948_accelGyroCalibrate(), ICM_20948_gyroCalibrate(), ICM_20948_Init2(), and ICM_20948_wakeOnMotionITEnable().
uint32_t ICM_20948_sensorEnable | ( | bool | accel, |
bool | gyro, | ||
bool | temp | ||
) |
Enable selected sensors.
[in] | accel |
|
[in] | gyro |
|
[in] | temp |
|
Definition at line 1095 of file ICM20948.c.
References ICM_20948_BIT_PWR_ACCEL_STBY, ICM_20948_BIT_PWR_GYRO_STBY, ICM_20948_BIT_TEMP_DIS, ICM_20948_OK, ICM_20948_REG_PWR_MGMT_1, ICM_20948_REG_PWR_MGMT_2, ICM_20948_registerRead(), and ICM_20948_registerWrite().
Referenced by ICM_20948_accelGyroCalibrate(), ICM_20948_gyroCalibrate(), ICM_20948_Init2(), ICM_20948_lowPowerModeEnter(), and ICM_20948_wakeOnMotionITEnable().
uint32_t ICM_20948_set_mag_mode | ( | uint8_t | magMode | ) |
Set magnetometer mode (sample rate / on-off)
[in] | magMode | Magnetometer mode |
Definition at line 1670 of file ICM20948.c.
References AK09916_BIT_MODE_POWER_DOWN, AK09916_MODE_100HZ, AK09916_MODE_10HZ, AK09916_MODE_20HZ, AK09916_MODE_50HZ, AK09916_MODE_SINGLE, AK09916_MODE_ST, AK09916_REG_CONTROL_2, ERROR, ICM_20948_write_mag_register(), and OK.
Referenced by ICM_20948_Init(), and ICM_20948_Init2().
void ICM_20948_set_mag_transfer | ( | bool | read | ) |
Set magnetometer data transfer on integrated I2C controller inside ICM20948.
[in] | read |
|
Definition at line 1443 of file ICM20948.c.
References AK09916_BIT_I2C_SLV_ADDR, ICM_20948_BIT_I2C_SLV_READ, ICM_20948_REG_I2C_SLV0_ADDR, and ICM_20948_registerWrite().
uint32_t ICM_20948_sleepModeEnable | ( | bool | enable | ) |
Sleep mode enable function.
[in] | enable |
|
Definition at line 728 of file ICM20948.c.
References ICM_20948_BIT_SLEEP, ICM_20948_OK, ICM_20948_REG_PWR_MGMT_1, ICM_20948_registerRead(), and ICM_20948_registerWrite().
Referenced by ICM_20948_Init2(), ICM_20948_lowPowerModeEnter(), and ICM_20948_wakeOnMotionITEnable().
uint32_t ICM_20948_wakeOnMotionITEnable | ( | bool | enable, |
uint8_t | womThreshold, | ||
float | sampleRate | ||
) |
Set wake on motion interrupt.
[in] | enable |
|
[in] | womThreshold | value above which an interrupt is generated |
[in] | sampleRate | sample rate of accel in duty cycle mode (low power mode) |
Definition at line 1295 of file ICM20948.c.
References delay(), ICM_20948_ACCEL_BW_1210HZ, ICM_20948_ACCEL_FULLSCALE_2G, ICM_20948_accelBandwidthSet(), ICM_20948_accelFullscaleSet(), ICM_20948_BIT_ACCEL_INTEL_EN, ICM_20948_BIT_ACCEL_INTEL_MODE, ICM_20948_cycleModeEnable(), ICM_20948_interruptEnable(), ICM_20948_lowPowerModeEnter(), ICM_20948_OK, ICM_20948_REG_ACCEL_INTEL_CTRL, ICM_20948_REG_ACCEL_WOM_THR, ICM_20948_registerWrite(), ICM_20948_sampleRateSet(), ICM_20948_sensorEnable(), and ICM_20948_sleepModeEnable().
void ICM_20948_write | ( | uint16_t | addr, |
uint8_t | data | ||
) |
void ICM_20948_write_mag_register | ( | uint8_t | addr, |
uint8_t | data | ||
) |
Writes a uint8_t to the I2C address of the magnetometer of the ICM_20948.
[in] | addr | The address that needs to be written to. |
[in] | data | The data that needs to be written. |
Definition at line 1648 of file ICM20948.c.
References AK09916_BIT_I2C_SLV_ADDR, data, and IIC_WriteBuffer().
Referenced by ICM_20948_Init2(), ICM_20948_reset_mag(), and ICM_20948_set_mag_mode().