| ICM-4268x-V Driver API 1.0.1 ICM-4268x-V Driver API

Files | Classes | Macros | Enumerations | Functions
Icm426xx driver high level functions

High-level function to setup an Icm426xx device. More...

## Files
file | Icm426xxDriver_HL.h
| High-level function to setup an Icm426xx device.

## Classes
struct | inv_icm426xx_sensor_event_t
| Sensor event structure definition. More...
struct | inv_icm426xx
| Icm426xx driver states definition. More...
struct | inv_icm426xx_interrupt_parameter_t
| Icm426xx set of interrupt enable flag. More...

## Macros
#define | INV_ICM426XX_LIGHTWEIGHT_DRIVER 0
| Lighten driver logic by stripping out procedures on transitions. More...
#define | PLL_SCALE_FACTOR_Q24 (1UL<<24)
| Scale factor and max ODR Dependant of chip.
#define | ACCEL_CONFIG0_FS_SEL_MAX ICM426XX_ACCEL_CONFIG0_FS_SEL_16g
| Max FSR values for accel and gyro Dependant of chip.
#define | RTC_SUPPORTED 0
| RTC Support flag Define whether the RTC mode is supported Dependant of chip.
#define | ICM426XX_FIFO_MIRRORING_SIZE 16 * 129
| Icm426xx maximum buffer size mirrored from FIFO at polling time. More...
#define | ICM426XX_DEFAULT_WOM_THS_MG 52>>2 /* = 52mg/4 */
| Default value for the WOM threshold Resolution of the threshold is ~= 4mg.
#define | ICM426XX_ACC_STARTUP_TIME_US 20000U
| Icm426xx Accelerometer start-up time before having correct data.
#define | ICM426XX_GYR_STARTUP_TIME_US 60000U
| Icm426xx Gyroscope start-up time before having correct data.

## Enumerations
enum | inv_icm426xx_sensor { INV_ICM426XX_SENSOR_ACCEL , INV_ICM426XX_SENSOR_GYRO , INV_ICM426XX_SENSOR_FSYNC_EVENT , INV_ICM426XX_SENSOR_OIS , INV_ICM426XX_SENSOR_TEMPERATURE , INV_ICM426XX_SENSOR_TAP , INV_ICM426XX_SENSOR_DMP_PEDOMETER_EVENT , INV_ICM426XX_SENSOR_DMP_PEDOMETER_COUNT , INV_ICM426XX_SENSOR_DMP_TILT , INV_ICM426XX_SENSOR_MAX }
| Sensor identifier for UI control and OIS function. More...
enum | INV_ICM426XX_FIFO_CONFIG_t { INV_ICM426XX_FIFO_DISABLED = 0 , INV_ICM426XX_FIFO_ENABLED = 1 }
| Configure Fifo usage. More...

## Functions
int | inv_icm426xx_set_reg_bank (struct inv_icm426xx *s, uint8_t bank)
| Set register bank index. More...
int | inv_icm426xx_init (struct inv_icm426xx *s, struct inv_icm426xx_serif *serif, void(*sensor_event_cb)(inv_icm426xx_sensor_event_t *event))
| Configure the serial interface used to access the device and execute hardware initialization. More...
int | inv_icm426xx_device_reset (struct inv_icm426xx *s)
| Perform a soft reset of the device. More...
int | inv_icm426xx_get_who_am_i (struct inv_icm426xx *s, uint8_t *who_am_i)
| return WHOAMI value More...
int | inv_icm426xx_force_clock_source (struct inv_icm426xx *s, ICM426XX_INTF_CONFIG1_ACCEL_LP_CLK_t clk_src)
| Configure Accel clock source. More...
int | inv_icm426xx_enable_accel_low_power_mode (struct inv_icm426xx *s)
| Enable/put accel in low power mode. More...
int | inv_icm426xx_enable_accel_low_noise_mode (struct inv_icm426xx *s)
| Enable/put accel in low noise mode. More...
int | inv_icm426xx_disable_accel (struct inv_icm426xx *s)
| Disable all 3 axes of accel. More...
int | inv_icm426xx_enable_gyro_low_noise_mode (struct inv_icm426xx *s)
| Enable/put gyro in low noise mode. More...
int | inv_icm426xx_disable_gyro (struct inv_icm426xx *s)
| Disable all 3 axes of gyro. More...
int | inv_icm426xx_enable_fsync (struct inv_icm426xx *s)
| Enable fsync tagging functionality. More...
int | inv_icm426xx_disable_fsync (struct inv_icm426xx *s)
| Disable fsync tagging functionality. More...
int | inv_icm426xx_configure_timestamp_resolution (struct inv_icm426xx *s, ICM426XX_TMST_CONFIG_RESOL_t resol)
| Configure timestamp resolution from FIFO. More...
int | inv_icm426xx_set_config_ibi (struct inv_icm426xx *s, inv_icm426xx_interrupt_parameter_t *interrupt_to_configure)
| Configure which interrupt source can trigger ibi interruptions. More...
int | inv_icm426xx_get_config_ibi (struct inv_icm426xx *s, inv_icm426xx_interrupt_parameter_t *interrupt_to_configure)
| Retrieve interrupts configuration. More...
int | inv_icm426xx_set_config_int1 (struct inv_icm426xx *s, inv_icm426xx_interrupt_parameter_t *interrupt_to_configure)
| Configure which interrupt source can trigger INT1. More...
int | inv_icm426xx_get_config_int1 (struct inv_icm426xx *s, inv_icm426xx_interrupt_parameter_t *interrupt_to_configure)
| Retrieve interrupts configuration. More...
int | inv_icm426xx_set_config_int2 (struct inv_icm426xx *s, inv_icm426xx_interrupt_parameter_t *interrupt_to_configure)
| Configure which interrupt source can trigger INT2. More...
int | inv_icm426xx_get_config_int2 (struct inv_icm426xx *s, inv_icm426xx_interrupt_parameter_t *interrupt_to_configure)
| Retrieve interrupts configuration. More...
int | inv_icm426xx_get_data_from_registers (struct inv_icm426xx *s)
| Read all registers containing data (temperature, accelerometer and gyroscope). More...
int | inv_icm426xx_get_data_from_fifo (struct inv_icm426xx *s)
| Read all available packets from the FIFO. More...
uint32_t | inv_icm426xx_convert_odr_bitfield_to_us (uint32_t odr_bitfield)
| Converts ICM426XX_ACCEL_CONFIG0_ODR_t or ICM426XX_GYRO_CONFIG0_ODR_t enums to period expressed in us. More...
int | inv_icm426xx_set_accel_frequency (struct inv_icm426xx *s, const ICM426XX_ACCEL_CONFIG0_ODR_t frequency)
| Configure accel Output Data Rate. More...
int | inv_icm426xx_set_gyro_frequency (struct inv_icm426xx *s, const ICM426XX_GYRO_CONFIG0_ODR_t frequency)
| Configure gyro Output Data Rate. More...
int | inv_icm426xx_set_accel_fsr (struct inv_icm426xx *s, ICM426XX_ACCEL_CONFIG0_FS_SEL_t accel_fsr_g)
| Set accel full scale range. More...
int | inv_icm426xx_get_accel_fsr (struct inv_icm426xx *s, ICM426XX_ACCEL_CONFIG0_FS_SEL_t *accel_fsr_g)
| Access accel full scale range. More...
int | inv_icm426xx_set_gyro_fsr (struct inv_icm426xx *s, ICM426XX_GYRO_CONFIG0_FS_SEL_t gyro_fsr_dps)
| Set gyro full scale range. More...
int | inv_icm426xx_get_gyro_fsr (struct inv_icm426xx *s, ICM426XX_GYRO_CONFIG0_FS_SEL_t *gyro_fsr_dps)
| Access gyro full scale range. More...
int | inv_icm426xx_set_accel_lp_avg (struct inv_icm426xx *s, ICM426XX_GYRO_ACCEL_CONFIG0_ACCEL_FILT_AVG_t acc_avg)
| Set accel Low-Power averaging value. More...
int | inv_icm426xx_set_accel_ln_bw (struct inv_icm426xx *s, ICM426XX_GYRO_ACCEL_CONFIG0_ACCEL_FILT_BW_t acc_bw)
| Set accel Low-Noise bandwidth value. More...
int | inv_icm426xx_set_gyro_ln_bw (struct inv_icm426xx *s, ICM426XX_GYRO_ACCEL_CONFIG0_GYRO_FILT_BW_t gyr_bw)
| Set gyro Low-Noise bandwidth value. More...
int | inv_icm426xx_reset_fifo (struct inv_icm426xx *s)
| reset ICM426XX fifo More...
int | inv_icm426xx_enable_timestamp_to_register (struct inv_icm426xx *s)
| Enable the 20bits-timestamp register access to read in a reliable way the strobed timestamp. More...
int | inv_icm426xx_disable_timestamp_to_register (struct inv_icm426xx *s)
| Disable the 20bits-timestamp register access. More...
int | inv_icm426xx_get_current_timestamp (struct inv_icm426xx *s, uint32_t *icm_time)
| Get the timestamp value of icm426xx from register. More...
int | inv_icm426xx_enable_clkin_rtc (struct inv_icm426xx *s, uint8_t enable)
| Enable or disable CLKIN/RTC capability. More...
int | inv_icm426xx_get_clkin_rtc_status (struct inv_icm426xx *s)
| Get CLKIN/RTC feature status. More...
int | inv_icm426xx_enable_high_resolution_fifo (struct inv_icm426xx *s)
| Enable 20 bits raw acc and raw gyr data in fifo. More...
int | inv_icm426xx_disable_high_resolution_fifo (struct inv_icm426xx *s)
| Disable 20 bits raw acc and raw gyr data in fifo. More...
int | inv_icm426xx_configure_fifo (struct inv_icm426xx *s, INV_ICM426XX_FIFO_CONFIG_t fifo_config)
| Configure Fifo to select the way data are gathered. More...
int | inv_icm426xx_configure_fifo_wm (struct inv_icm426xx *s, uint16_t wm)
| Configure Fifo watermark (also referred to as fifo threshold) More...
uint32_t | inv_icm426xx_get_fifo_timestamp_resolution_us_q24 (struct inv_icm426xx *s)
| Get FIFO timestamp resolution. More...
uint32_t | inv_icm426xx_get_reg_timestamp_resolution_us_q24 (struct inv_icm426xx *s)
| Get register timestamp resolution. More...
const char * | inv_icm426xx_get_version (void)
| Return driver version x.y.z-suffix as a char array. More...

## Detailed Description

High-level function to setup an Icm426xx device.

## Macro Definition Documentation

## ◆ ICM426XX_FIFO_MIRRORING_SIZE

#define ICM426XX_FIFO_MIRRORING_SIZE 16 * 129

Icm426xx maximum buffer size mirrored from FIFO at polling time.

Warning
  fifo_idx type variable must be large enough to parse the FIFO_MIRRORING_SIZE

## ◆ INV_ICM426XX_LIGHTWEIGHT_DRIVER

#define INV_ICM426XX_LIGHTWEIGHT_DRIVER 0

Lighten driver logic by stripping out procedures on transitions.

In the nominal case, ie. when sensors are enabled and their output has settled, ICM-426XX will not need the logic to handle each transition. They are part of each API function so this code will be linked in regardless. This might not be desirable for the most size-constrained platforms and it can be avoided by setting this define to 1.

## Enumeration Type Documentation

## ◆ INV_ICM426XX_FIFO_CONFIG_t

enum INV_ICM426XX_FIFO_CONFIG_t

Configure Fifo usage.

Enumerator
INV_ICM426XX_FIFO_DISABLED | Fifo is disabled and data source is sensors registers.
INV_ICM426XX_FIFO_ENABLED | Fifo is used as data source.

## ◆ inv_icm426xx_sensor

enum inv_icm426xx_sensor

Sensor identifier for UI control and OIS function.

Enumerator
INV_ICM426XX_SENSOR_ACCEL | Accelerometer (UI control path)
INV_ICM426XX_SENSOR_GYRO | Gyroscope (UI control path)
INV_ICM426XX_SENSOR_FSYNC_EVENT | Used by OIS and UI control layers.
INV_ICM426XX_SENSOR_OIS | Only used by OIS layer.
INV_ICM426XX_SENSOR_TEMPERATURE | Chip temperature, enabled by default. However, it will be reported only if Accel and/or Gyro are also enabled. The Temperature's ODR (Output Data Rate) will match the ODR of Accel or Gyro, or the fastest if both are enabled
INV_ICM426XX_SENSOR_TAP | Tap and Double tap.
INV_ICM426XX_SENSOR_DMP_PEDOMETER_EVENT | Pedometer: step is detected.
INV_ICM426XX_SENSOR_DMP_PEDOMETER_COUNT | Pedometer: step counter.
INV_ICM426XX_SENSOR_DMP_TILT | Tilt.

## Function Documentation

## ◆ inv_icm426xx_configure_fifo()

int inv_icm426xx_configure_fifo | ( | struct inv_icm426xx * | s,
|  | INV_ICM426XX_FIFO_CONFIG_t | fifo_config
| ) |  |

Configure Fifo to select the way data are gathered.

Parameters

  [in] | fifo_config | Fifo configuration method : if enabled data are coming from fifo and Interrupt is configured on Fifo Watermark if disabled data are coming from sensor registers and Interrupt is configured on Data ready

See also
  INV_ICM426XX_FIFO_CONFIG_t

## ◆ inv_icm426xx_configure_fifo_wm()

int inv_icm426xx_configure_fifo_wm | ( | struct inv_icm426xx * | s,
|  | uint16_t | wm
| ) |  |

Configure Fifo watermark (also referred to as fifo threshold)

Parameters

  [in] | wm | Watermark value

## ◆ inv_icm426xx_configure_timestamp_resolution()

int inv_icm426xx_configure_timestamp_resolution | ( | struct inv_icm426xx * | s,
|  | ICM426XX_TMST_CONFIG_RESOL_t | resol
| ) |  |

Configure timestamp resolution from FIFO.

Parameters

  [in] | resol | The expected resolution of the timestamp. See enum ICM426XX_TMST_CONFIG_RESOL_t.

Returns
  0 on success, negative value on error.

Warning
  The resolution will have no effect if RTC is enabled

## ◆ inv_icm426xx_convert_odr_bitfield_to_us()

uint32_t inv_icm426xx_convert_odr_bitfield_to_us | ( | uint32_t | odr_bitfield | ) |

Converts ICM426XX_ACCEL_CONFIG0_ODR_t or ICM426XX_GYRO_CONFIG0_ODR_t enums to period expressed in us.

Parameters

  [in] | odr_bitfield | An ICM426XX_ACCEL_CONFIG0_ODR_t or ICM426XX_GYRO_CONFIG0_ODR_t enum

Returns
  The corresponding period expressed in us

## ◆ inv_icm426xx_device_reset()

int inv_icm426xx_device_reset | ( | struct inv_icm426xx * | s | ) |

Perform a soft reset of the device.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_disable_accel()

int inv_icm426xx_disable_accel | ( | struct inv_icm426xx * | s | ) |

Disable all 3 axes of accel.

Returns
  0 on success, negative value on error.

If both accel and gyro are turned off as a result of this function, they will also be removed from the FIFO and a FIFO reset will be performed (to guarantee no side effects until the next enable sensor call)

Warning
  inv_icm426xx::register_cache::pwr_mngt_0_reg is modified by this function

## ◆ inv_icm426xx_disable_fsync()

int inv_icm426xx_disable_fsync | ( | struct inv_icm426xx * | s | ) |

Disable fsync tagging functionality.

In details it:

- disables fsync
- disables timestamp to registers. Once fysnc is disabled timestamp is pushed to fifo instead of fsync counter. So in order to decrease power consumption, timestamp is no more available in registers.
- disables fsync related interrupt
  Returns
    0 on success, negative value on error.

## ◆ inv_icm426xx_disable_gyro()

int inv_icm426xx_disable_gyro | ( | struct inv_icm426xx * | s | ) |

Disable all 3 axes of gyro.

Returns
  0 on success, negative value on error.

If both accel and gyro are turned off as a result of this function, they will also be removed from the FIFO and a FIFO reset will be performed (to guarantee no side effects until the next enable sensor call)

Warning
  inv_icm426xx::register_cache::pwr_mngt_0_reg is modified by this function

## ◆ inv_icm426xx_disable_high_resolution_fifo()

int inv_icm426xx_disable_high_resolution_fifo | ( | struct inv_icm426xx * | s | ) |

Disable 20 bits raw acc and raw gyr data in fifo.

Returns
  0 on success, negative return code otherwise

## ◆ inv_icm426xx_disable_timestamp_to_register()

int inv_icm426xx_disable_timestamp_to_register | ( | struct inv_icm426xx * | s | ) |

Disable the 20bits-timestamp register access.

Register read always return 0's.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_enable_accel_low_noise_mode()

int inv_icm426xx_enable_accel_low_noise_mode | ( | struct inv_icm426xx * | s | ) |

Enable/put accel in low noise mode.

Returns
  0 on success, negative value on error.

It enables accel and gyro data in the FIFO (so the packet format is 16 bytes). If called first, the configuration will be applied, otherwise it will be ignored if the FIFO is not empty (but since the new configuration is identical it is not a issue).

Warning
  inv_icm426xx::register_cache::pwr_mngt_0_reg is modified by this function

## ◆ inv_icm426xx_enable_accel_low_power_mode()

int inv_icm426xx_enable_accel_low_power_mode | ( | struct inv_icm426xx * | s | ) |

Enable/put accel in low power mode.

Returns
  0 on success, negative value on error.

It enables accel and gyro data in the FIFO (so the packet format is 16 bytes). If called first, the configuration will be applied, otherwise it will be ignored if the FIFO is not empty (but since the new configuration is identical it is not a issue).

Warning
  inv_icm426xx::register_cache::pwr_mngt_0_reg is modified by this function

## ◆ inv_icm426xx_enable_clkin_rtc()

int inv_icm426xx_enable_clkin_rtc | ( | struct inv_icm426xx * | s,
|  | uint8_t | enable
| ) |  |

Enable or disable CLKIN/RTC capability.

Parameters

  [in] | enable | 1 if external 32kHz is provided to ICM, 0 otherwise

Returns
  0 on success, negative value on error.

Warning
  In case CLKIN is disabled, it is recommended to call inv_icm426xx_configure_timestamp_resolution() just afterwards so that timestamp resolution is in line with system request
  inv_icm426xx::register_cache::intf_cfg_1_reg is modified by this function

## ◆ inv_icm426xx_enable_fsync()

int inv_icm426xx_enable_fsync | ( | struct inv_icm426xx * | s | ) |

Enable fsync tagging functionality.

In details it:

- enables fsync
- enables timestamp to registers. Once fysnc is enabled fsync counter is pushed to fifo instead of timestamp. So timestamp is made available in registers. Note that this increase power consumption.
- enables fsync related interrupt
  Returns
    0 on success, negative value on error.

## ◆ inv_icm426xx_enable_gyro_low_noise_mode()

int inv_icm426xx_enable_gyro_low_noise_mode | ( | struct inv_icm426xx * | s | ) |

Enable/put gyro in low noise mode.

Returns
  0 on success, negative value on error.

It enables gyro and accel data in the FIFO (so the packet format is 16 bytes). If called first, the configuration will be applied, otherwise it will be ignored if the FIFO is not empty (but since the new configuration is identical it is not a issue).

Warning
  inv_icm426xx::register_cache::pwr_mngt_0_reg is modified by this function

## ◆ inv_icm426xx_enable_high_resolution_fifo()

int inv_icm426xx_enable_high_resolution_fifo | ( | struct inv_icm426xx * | s | ) |

Enable 20 bits raw acc and raw gyr data in fifo.

Returns
  0 on success, negative return code otherwise

## ◆ inv_icm426xx_enable_timestamp_to_register()

int inv_icm426xx_enable_timestamp_to_register | ( | struct inv_icm426xx * | s | ) |

Enable the 20bits-timestamp register access to read in a reliable way the strobed timestamp.

To do that, the fine clock is forced enabled at some power cost.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_force_clock_source()

int inv_icm426xx_force_clock_source | ( | struct inv_icm426xx * | s,
|  | ICM426XX_INTF_CONFIG1_ACCEL_LP_CLK_t | clk_src
| ) |  |

Configure Accel clock source.

Parameters

  [in] | new | clock source to use

Returns
  0 on success, negative value on error

Note
  Transitions when enabling/disabling sensors are already handled by the driver. This function is here only to force a specific clock source and shall be used with care.

## ◆ inv_icm426xx_get_accel_fsr()

int inv_icm426xx_get_accel_fsr | ( | struct inv_icm426xx * | s,
|  | ICM426XX_ACCEL_CONFIG0_FS_SEL_t * | accel_fsr_g
| ) |  |

Access accel full scale range.

Parameters

  [out] | accel_fsr_g | current full scale range.

See also
  ICM426XX_ACCEL_CONFIG0_FS_SEL_t.

Returns
  0 on success, negative value on error.

Warning
  inv_icm426xx::register_cache::accel_cfg_0_reg is relied upon by this function

## ◆ inv_icm426xx_get_clkin_rtc_status()

int inv_icm426xx_get_clkin_rtc_status | ( | struct inv_icm426xx * | s | ) |

Get CLKIN/RTC feature status.

Returns
  0 if CLKIN is disabled, 1 if enabled.

Warning
  In case CLKIN is disabled, it is recommended to call inv_icm426xx_configure_timestamp_resolution() just afterwards so that timestamp resolution is in line with system request
  inv_icm426xx::register_cache::intf_cfg_1_reg is relied upon by this function

## ◆ inv_icm426xx_get_config_ibi()

int inv_icm426xx_get_config_ibi | ( | struct inv_icm426xx * | s,
|  | inv_icm426xx_interrupt_parameter_t * | interrupt_to_configure
| ) |  |

Retrieve interrupts configuration.

Parameters

  [in] | interrupt_to_configure | structure with the corresponding state to manage IBI interruptions.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_get_config_int1()

int inv_icm426xx_get_config_int1 | ( | struct inv_icm426xx * | s,
|  | inv_icm426xx_interrupt_parameter_t * | interrupt_to_configure
| ) |  |

Retrieve interrupts configuration.

Parameters

  [in] | interrupt_to_configure | structure with the corresponding state to manage INT1.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_get_config_int2()

int inv_icm426xx_get_config_int2 | ( | struct inv_icm426xx * | s,
|  | inv_icm426xx_interrupt_parameter_t * | interrupt_to_configure
| ) |  |

Retrieve interrupts configuration.

Parameters

  [in] | interrupt_to_configure | structure with the corresponding state to manage INT2.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_get_current_timestamp()

int inv_icm426xx_get_current_timestamp | ( | struct inv_icm426xx * | s,
|  | uint32_t * | icm_time
| ) |  |

Get the timestamp value of icm426xx from register.

Parameters

  [in] | icm_time | timestamp read from register

Returns
  0 on success, negative value on error.

Warning
  Prior to call this API, the read access to timestamp register must be enabled (see inv_icm426xx_enable_timestamp_to_register() function)

## ◆ inv_icm426xx_get_data_from_fifo()

int inv_icm426xx_get_data_from_fifo | ( | struct inv_icm426xx * | s | ) |

Read all available packets from the FIFO.

For each packet function builds a sensor event containing packet data and validity information. Then it calls sensor_event_cb function passed in parameter of inv_icm426xx_init function for each packet.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_get_data_from_registers()

int inv_icm426xx_get_data_from_registers | ( | struct inv_icm426xx * | s | ) |

Read all registers containing data (temperature, accelerometer and gyroscope).

Then it calls sensor_event_cb function passed in parameter of inv_icm426xx_init function for each packet

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_get_fifo_timestamp_resolution_us_q24()

uint32_t inv_icm426xx_get_fifo_timestamp_resolution_us_q24 | ( | struct inv_icm426xx * | s | ) |

Get FIFO timestamp resolution.

Returns
  the timestamp resolution in us as a q24 or 0 in case of error

## ◆ inv_icm426xx_get_gyro_fsr()

int inv_icm426xx_get_gyro_fsr | ( | struct inv_icm426xx * | s,
|  | ICM426XX_GYRO_CONFIG0_FS_SEL_t * | gyro_fsr_dps
| ) |  |

Access gyro full scale range.

Parameters

  [out] | gyro_fsr_dps | current full scale range.

See also
  ICM426XX_GYRO_CONFIG0_FS_SEL_t.

Returns
  0 on success, negative value on error.

Warning
  inv_icm426xx::register_cache::gyro_cfg_0_reg is relied upon by this function

## ◆ inv_icm426xx_get_reg_timestamp_resolution_us_q24()

uint32_t inv_icm426xx_get_reg_timestamp_resolution_us_q24 | ( | struct inv_icm426xx * | s | ) |

Get register timestamp resolution.

Returns
  the timestamp resolution in us as a q24 or 0 in case of error

## ◆ inv_icm426xx_get_version()

const char* inv_icm426xx_get_version | ( | void |  | ) |

Return driver version x.y.z-suffix as a char array.

Return values

  driver | version a char array "x.y.z-suffix"

## ◆ inv_icm426xx_get_who_am_i()

int inv_icm426xx_get_who_am_i | ( | struct inv_icm426xx * | s,
|  | uint8_t * | who_am_i
| ) |  |

return WHOAMI value

Parameters

  [out] | who_am_i | WHOAMI for device

Returns
  0 on success, negative value on error

## ◆ inv_icm426xx_init()

int inv_icm426xx_init | ( | struct inv_icm426xx * | s,
|  | struct inv_icm426xx_serif * | serif,
|  | void(*)(inv_icm426xx_sensor_event_t *event) | sensor_event_cb
| ) |  |

Configure the serial interface used to access the device and execute hardware initialization.

This functions first configures serial interface passed in parameter to make sure device is accessible both in read and write. Thus no serial access should be done before successfully executing the present function.

Then if requested serial interface is a primary interface (aka UI interface or AP interface), this function initializes the device using the following hardware settings:

- gyroscope fsr = 2000dps
- accelerometer fsr = 4g
- set timestamp resolution to 16us
- enable FIFO mechanism with the following configuration:
  - FIFO record mode i.e FIFO count unit is packet
  - FIFO snapshot mode i.e drop the data when the FIFO overflows
  - Timestamp is logged in FIFO
  - Little Endian fifo_count and fifo_data
  - generate FIFO threshold interrupt when packet count reaches FIFO watermark
  - set FIFO watermark to 1 packet
  - enable temperature and timestamp data to go to FIFO

In case requested serial interface is an auxiliary interface (i.e. AUX1 or AUX2) this function returns an error.

Parameters

  [in] | s | driver structure. Note that first field of this structure MUST be a struct inv_icm426xx_serif.
  [in] | serif | pointer on serial interface structure to be used to access icm426xx.
  [in] | sensor_event_cb | callback executed by inv_icm426xx_get_data_from_fifo function each time it extracts some valid data from fifo. Or inv_icm426xx_get_data_from_registers read data from register. Thus this parameter is optional as long as inv_icm426xx_get_data_from_fifo/inv_icm426xx_get_data_from_registers function is not used.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_reset_fifo()

int inv_icm426xx_reset_fifo | ( | struct inv_icm426xx * | s | ) |

reset ICM426XX fifo

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_set_accel_frequency()

int inv_icm426xx_set_accel_frequency | ( | struct inv_icm426xx * | s,
|  | const ICM426XX_ACCEL_CONFIG0_ODR_t | frequency
| ) |  |

Configure accel Output Data Rate.

Parameters

  [in] | frequency | The requested frequency.

See also
  ICM426XX_ACCEL_CONFIG0_ODR_t

Returns
  0 on success, negative value on error.

Warning
  inv_icm426xx::register_cache::accel_cfg_0_reg is modified by this function

## ◆ inv_icm426xx_set_accel_fsr()

int inv_icm426xx_set_accel_fsr | ( | struct inv_icm426xx * | s,
|  | ICM426XX_ACCEL_CONFIG0_FS_SEL_t | accel_fsr_g
| ) |  |

Set accel full scale range.

Parameters

  [in] | accel_fsr_g | requested full scale range.

See also
  ICM426XX_ACCEL_CONFIG0_FS_SEL_t.

Returns
  0 on success, negative value on error.

Warning
  inv_icm426xx::register_cache::accel_cfg_0_reg is modified by this function

## ◆ inv_icm426xx_set_accel_ln_bw()

int inv_icm426xx_set_accel_ln_bw | ( | struct inv_icm426xx * | s,
|  | ICM426XX_GYRO_ACCEL_CONFIG0_ACCEL_FILT_BW_t | acc_bw
| ) |  |

Set accel Low-Noise bandwidth value.

Parameters

  [in] | acc_bw | requested averaging value

See also
  ICM426XX_GYRO_ACCEL_CONFIG0_ACCEL_FILT_BW_t

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_set_accel_lp_avg()

int inv_icm426xx_set_accel_lp_avg | ( | struct inv_icm426xx * | s,
|  | ICM426XX_GYRO_ACCEL_CONFIG0_ACCEL_FILT_AVG_t | acc_avg
| ) |  |

Set accel Low-Power averaging value.

Parameters

  [in] | acc_avg | requested averaging value

See also
  ICM426XX_GYRO_ACCEL_CONFIG0_ACCEL_FILT_AVG_t

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_set_config_ibi()

int inv_icm426xx_set_config_ibi | ( | struct inv_icm426xx * | s,
|  | inv_icm426xx_interrupt_parameter_t * | interrupt_to_configure
| ) |  |

Configure which interrupt source can trigger ibi interruptions.

Parameters

  [in] | interrupt_to_configure | structure with the corresponding state to manage ibi interruptions.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_set_config_int1()

int inv_icm426xx_set_config_int1 | ( | struct inv_icm426xx * | s,
|  | inv_icm426xx_interrupt_parameter_t * | interrupt_to_configure
| ) |  |

Configure which interrupt source can trigger INT1.

Parameters

  [in] | interrupt_to_configure | structure with the corresponding state to manage INT1.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_set_config_int2()

int inv_icm426xx_set_config_int2 | ( | struct inv_icm426xx * | s,
|  | inv_icm426xx_interrupt_parameter_t * | interrupt_to_configure
| ) |  |

Configure which interrupt source can trigger INT2.

Parameters

  [in] | interrupt_to_configure | structure with the corresponding state to INT2.

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_set_gyro_frequency()

int inv_icm426xx_set_gyro_frequency | ( | struct inv_icm426xx * | s,
|  | const ICM426XX_GYRO_CONFIG0_ODR_t | frequency
| ) |  |

Configure gyro Output Data Rate.

Parameters

  [in] | frequency | The requested frequency.

See also
  ICM426XX_GYRO_CONFIG0_ODR_t

Returns
  0 on success, negative value on error.

Warning
  inv_icm426xx::register_cache::gyro_cfg_0_reg is modified by this function

## ◆ inv_icm426xx_set_gyro_fsr()

int inv_icm426xx_set_gyro_fsr | ( | struct inv_icm426xx * | s,
|  | ICM426XX_GYRO_CONFIG0_FS_SEL_t | gyro_fsr_dps
| ) |  |

Set gyro full scale range.

Parameters

  [in] | gyro_fsr_dps | requested full scale range.

See also
  ICM426XX_GYRO_CONFIG0_FS_SEL_t.

Returns
  0 on success, negative value on error.

Warning
  inv_icm426xx::register_cache::gyro_cfg_0_reg is modified by this function

## ◆ inv_icm426xx_set_gyro_ln_bw()

int inv_icm426xx_set_gyro_ln_bw | ( | struct inv_icm426xx * | s,
|  | ICM426XX_GYRO_ACCEL_CONFIG0_GYRO_FILT_BW_t | gyr_bw
| ) |  |

Set gyro Low-Noise bandwidth value.

Parameters

  [in] | gyr_bw | requested averaging value

See also
  ICM426XX_GYRO_ACCEL_CONFIG0_GYRO_FILT_BW_t

Returns
  0 on success, negative value on error.

## ◆ inv_icm426xx_set_reg_bank()

int inv_icm426xx_set_reg_bank | ( | struct inv_icm426xx * | s,
|  | uint8_t | bank
| ) |  |

Set register bank index.

Parameters

  bank | new bank to be set

Returns
  0 on success, negative value otherwise