daisy::Icm20948¶
Module: External
Device support for ICM20948 IMU sensor. More...
#include <icm20948.h>
Public Classes¶
Name | |
---|---|
struct | Config |
struct | Icm20948Vect |
Public Types¶
Name | |
---|---|
enum | icm20948_accel_range_t |
enum | icm20948_gyro_range_t |
enum | ak09916_data_rate_t |
enum | Result |
Public Functions¶
Name | |
---|---|
Icm20948() | |
~Icm20948() | |
Result | Init(Config config) |
void | Reset() |
uint8_t | GetMagId() |
Result | SetupMag() |
uint8_t | ReadMagRegister(uint8_t mag_reg_addr) |
bool | WriteMagRegister(uint8_t mag_reg_addr, uint8_t value) |
void | ScaleValues() |
void | SetAccelRateDivisor(uint16_t new_accel_divisor) |
icm20948_accel_range_t | GetAccelRange() |
uint8_t | ReadAccelRange() |
void | WriteAccelRange(uint8_t new_accel_range) |
void | SetAccelRange(icm20948_accel_range_t new_accel_range) |
void | SetGyroRateDivisor(uint8_t new_gyro_divisor) |
icm20948_gyro_range_t | GetGyroRange() |
void | SetGyroRange(icm20948_gyro_range_t new_gyro_range) |
void | WriteGyroRange(uint8_t new_gyro_range) |
uint8_t | ReadGyroRange() |
ak09916_data_rate_t | GetMagDataRate() |
bool | SetMagDataRate(ak09916_data_rate_t rate) |
void | SetBank(uint8_t bank_number) |
uint8_t | ReadExternalRegister(uint8_t slv_addr, uint8_t reg_addr) |
bool | WriteExternalRegister(uint8_t slv_addr, uint8_t reg_addr, uint8_t value) |
uint8_t | AuxillaryRegisterTransaction(bool read, uint8_t slv_addr, uint8_t reg_addr, uint8_t value) |
void | Process() |
Icm20948Vect | GetAccelVect() |
Icm20948Vect | GetGyroVect() |
Icm20948Vect | GetMagVect() |
float | GetTemp() |
uint8_t | Read8(uint8_t reg) |
void | Write8(uint8_t reg, uint8_t value) |
void | Write16(uint8_t reg, uint16_t value) |
void | ReadReg(uint8_t reg, uint8_t * buff, uint8_t size) |
uint8_t | ReadBits(uint8_t reg, uint8_t bits, uint8_t shift) |
void | WriteBits(uint8_t reg, uint8_t data, uint8_t bits, uint8_t shift) |
void | SetI2CBypass(bool bypass_i2c) |
Result | EnableI2CMaster(bool enable_i2c_master) |
Result | ConfigureI2CMaster(void ) |
void | ResetI2CMaster(void ) |
Result | AuxI2CBusSetupFailed(void ) |
Result | GetTransportError() |
Detailed Description¶
Device support for ICM20948 IMU sensor.
Author: beserge
Date: December 2021
Public Types Documentation¶
enum icm20948_accel_range_t¶
Enumerator | Value | Description |
---|---|---|
ICM20948_ACCEL_RANGE_2_G | ||
ICM20948_ACCEL_RANGE_4_G | ||
ICM20948_ACCEL_RANGE_8_G | ||
ICM20948_ACCEL_RANGE_16_G |
The accelerometer data range
enum icm20948_gyro_range_t¶
Enumerator | Value | Description |
---|---|---|
ICM20948_GYRO_RANGE_250_DPS | ||
ICM20948_GYRO_RANGE_500_DPS | ||
ICM20948_GYRO_RANGE_1000_DPS | ||
ICM20948_GYRO_RANGE_2000_DPS |
The gyro data range
enum ak09916_data_rate_t¶
Enumerator | Value | Description |
---|---|---|
AK09916_MAG_DATARATE_SHUTDOWN | 0x0 | Stops measurement updates. |
AK09916_MAG_DATARATE_SINGLE | 0x1 | Takes a single measurement then switches to AK09916_MAG_DATARATE_SHUTDOWN |
AK09916_MAG_DATARATE_10_HZ | 0x2 | updates at 10Hz |
AK09916_MAG_DATARATE_20_HZ | 0x4 | updates at 20Hz |
AK09916_MAG_DATARATE_50_HZ | 0x6 | updates at 50Hz |
AK09916_MAG_DATARATE_100_HZ | 0x8 | updates at 100Hz |
Data rates/modes for the embedded AsahiKASEI AK09916 3-axis magnetometer
enum Result¶
Enumerator | Value | Description |
---|---|---|
OK | 0 | |
ERR |
Public Functions Documentation¶
function Icm20948¶
function ~Icm20948¶
function Init¶
Parameters:
- config Configuration settings
Initialize the Icm20948 device
function Reset¶
Reset the internal registers and restores the default settings
function GetMagId¶
function SetupMag¶
function ReadMagRegister¶
Parameters:
- slv_addr
- mag_reg_addr
- num_finished_checks
Return: uint8_t
function WriteMagRegister¶
function ScaleValues¶
function SetAccelRateDivisor¶
Parameters:
- new_accel_divisor The accelerometer's data rate divisor (
uint16_t
). This 12-bit value must be <= 4095
Sets the accelerometer's data rate divisor.
function GetAccelRange¶
Return: The accelerometer's measurement range (icm20948_accel_range_t
).
Get the accelerometer's measurement range.
function ReadAccelRange¶
Return: The accelerometer's measurement range (icm20x_accel_range_t
).
Get the accelerometer's measurement range.
function WriteAccelRange¶
Parameters:
- new_accel_range Measurement range to be set. Must be an
icm20x_accel_range_t
.
Sets the accelerometer's measurement range.
function SetAccelRange¶
Parameters:
- new_accel_range Measurement range to be set. Must be an
icm20948_accel_range_t
.
Sets the accelerometer's measurement range.
function SetGyroRateDivisor¶
Parameters:
- new_gyro_divisor The gyro's data rate divisor (
uint8_t
).
Sets the gyro's data rate divisor.
function GetGyroRange¶
Return: The gyro's measurement range (icm20948_gyro_range_t
).
Get the gyro's measurement range.
function SetGyroRange¶
Parameters:
- new_gyro_range Measurement range to be set. Must be an
icm20948_gyro_range_t
.
Sets the gyro's measurement range.
function WriteGyroRange¶
Parameters:
- new_gyro_range Measurement range to be set. Must be an
icm20x_gyro_range_t
.
Sets the gyro's measurement range.
function ReadGyroRange¶
Return: The gyro's measurement range (icm20x_gyro_range_t
).
Get the gyro's measurement range.
function GetMagDataRate¶
Return: ak09916_data_rate_t the current rate
Get the current magnetometer measurement rate
function SetMagDataRate¶
Parameters:
- rate The rate to set.
Return: true: success false: failure
Set the magnetometer measurement rate
function SetBank¶
Parameters:
- bank_number The bank to set to active
Sets register bank.
function ReadExternalRegister¶
Parameters:
- slv_addr the 7-bit I2C address of the slave device
- reg_addr the register address to read from
Return: the requested register value
Read a single byte from a given register address for an I2C slave device on the auxiliary I2C bus
function WriteExternalRegister¶
Parameters:
- slv_addr the 7-bit I2C address of the slave device
- reg_addr the register address to write to
- value the value to write
Return:
- true
- false
Write a single byte to a given register address for an I2C slave device on the auxiliary I2C bus
function AuxillaryRegisterTransaction¶
inline uint8_t AuxillaryRegisterTransaction(
bool read,
uint8_t slv_addr,
uint8_t reg_addr,
uint8_t value
)
Parameters:
- slv_addr the 7-bit I2C address of the slave device
- reg_addr the register address to write to
- value the value to write
Return: Read value ( if it's a read operation ), else true or false
Read / Write a single byte to a given register address for an I2C slave device on the auxiliary I2C bus
function Process¶
Updates the measurement data for all sensors simultaneously
function GetAccelVect¶
function GetGyroVect¶
function GetMagVect¶
function GetTemp¶
function Read8¶
Parameters:
- reg the register address to read from
Return: the data uint8_t read from the device
Reads an 8 bit value
function Write8¶
Parameters:
- reg the register address to write to
- value the value to write to the register
Writes an 8 bit value
function Write16¶
Parameters:
- reg the register address to write to
- value the value to write to the register
Writes a 16 bit value MSB first
function ReadReg¶
Read from a reg address a defined number of bytes
function ReadBits¶
function WriteBits¶
function SetI2CBypass¶
Parameters:
- bypass_i2c Set to true to bypass the internal I2C master circuitry, connecting the external I2C bus to the main I2C bus. Set to false to re-connect
Sets the bypass status of the I2C master bus support.
function EnableI2CMaster¶
Parameters:
- enable_i2c_master true: enable false: disable
Return: true: success false: error
Enable or disable the I2C mastercontroller
function ConfigureI2CMaster¶
Return: true: success false: failure
Set the I2C clock rate for the auxillary I2C bus to 345.60kHz and disable repeated start
function ResetI2CMaster¶
Reset the I2C master
function AuxI2CBusSetupFailed¶
function GetTransportError¶
Return: Whether the transport has errored since the last check
Get and reset the transport error flag
---¶
Updated on 2024-01-03 at 19:41:01 +0000