| ICM45605 eMD driver Documentation of the eMD Driver API

- Main Page
- Related Pages
- Modules
- Classes
- Files

Files | Classes | Macros | Enumerations | Functions
Driver Advanced

High-level API for advanced functionalities. More...

## Files
file | inv_imu_driver_advanced.h

## Classes
struct | inv_imu_sensor_event_t
| Sensor event structure definition. More...
struct | inv_imu_adv_var_t
| Definition of extended variables. More...
struct | inv_imu_adv_fifo_config_t
| FIFO configuration structure. More...

## Macros
#define | FIFO_MIRRORING_SIZE 16 * 258 /* packet size * max_count = 4kB */
| Maximum buffer size mirrored from FIFO. More...

## Enumerations
enum | inv_imu_sensor_id_t { INV_SENSOR_ACCEL , INV_SENSOR_GYRO , INV_SENSOR_FSYNC_EVENT , INV_SENSOR_TEMPERATURE , INV_SENSOR_EDMP_PEDOMETER_EVENT , INV_SENSOR_EDMP_PEDOMETER_COUNT , INV_SENSOR_EDMP_TILT , INV_SENSOR_EDMP_FF , INV_SENSOR_EDMP_LOWG , INV_SENSOR_EDMP_HIGHG , INV_SENSOR_EDMP_SMD , INV_SENSOR_EDMP_TAP , INV_SENSOR_EDMP_R2W_WAKE , INV_SENSOR_EDMP_R2W_SLEEP , INV_SENSOR_ES0 , INV_SENSOR_ES1 , INV_SENSOR_MAX }
| Sensor identifier enumeration. More...

## Functions
int | inv_imu_adv_init (inv_imu_device_t *s)
| Initializes device. More...
int | inv_imu_adv_device_reset (inv_imu_device_t *s)
| Performs a soft reset of the device. More...
int | inv_imu_adv_enable_accel_lp (inv_imu_device_t *s)
| Enable accel in low power mode. More...
int | inv_imu_adv_enable_accel_ln (inv_imu_device_t *s)
| Enable accel in low noise mode. More...
int | inv_imu_adv_disable_accel (inv_imu_device_t *s)
| Disable accel. More...
int | inv_imu_adv_enable_gyro_ln (inv_imu_device_t *s)
| Enable gyro in low noise mode. More...
int | inv_imu_adv_enable_gyro_lp (inv_imu_device_t *s)
| Enable gyro in low power mode. More...
int | inv_imu_adv_disable_gyro (inv_imu_device_t *s)
| Disable gyro. More...
int | inv_imu_adv_get_data_from_registers (inv_imu_device_t *s)
| Read all registers containing data (temperature, accelerometer and gyroscope). More...
int | inv_imu_adv_reset_fifo (inv_imu_device_t *s)
| reset IMU fifo More...
int | inv_imu_adv_get_fifo_config (inv_imu_device_t *s, inv_imu_adv_fifo_config_t *conf)
| Retrieve FIFO configuration. More...
int | inv_imu_adv_set_fifo_config (inv_imu_device_t *s, const inv_imu_adv_fifo_config_t *conf)
| Set FIFO configuration. More...
int | inv_imu_adv_get_data_from_fifo (inv_imu_device_t *s, uint8_t fifo_data[FIFO_MIRRORING_SIZE], uint16_t *fifo_count)
| Read all available packets from the FIFO. More...
int | inv_imu_adv_parse_fifo_data (inv_imu_device_t *s, const uint8_t fifo_data[FIFO_MIRRORING_SIZE], const uint16_t fifo_count)
| Parse packets from FIFO buffer. More...
uint32_t | inv_imu_adv_convert_odr_bitfield_to_us (uint32_t odr_bitfield)
| Converts accel_config0_accel_odr_t or gyro_config0_gyro_odr_t enums to period expressed in us. More...
int | inv_imu_adv_get_accel_fsr (inv_imu_device_t *s, accel_config0_accel_ui_fs_sel_t *accel_fsr)
| Access accel full scale range. More...
int | inv_imu_adv_get_gyro_fsr (inv_imu_device_t *s, gyro_config0_gyro_ui_fs_sel_t *gyro_fsr)
| Access gyro full scale range. More...
int | inv_imu_adv_set_timestamp_resolution (inv_imu_device_t *s, const tmst_wom_config_tmst_resol_t timestamp_resol)
| Set timestamp resolution. More...
uint32_t | inv_imu_adv_get_timestamp_resolution_us (inv_imu_device_t *s)
| Get timestamp resolution. More...
int | inv_imu_adv_configure_wom (inv_imu_device_t *s, const uint8_t wom_x_th, const uint8_t wom_y_th, const uint8_t wom_z_th, tmst_wom_config_wom_int_mode_t wom_int, tmst_wom_config_wom_int_dur_t wom_dur)
| Enable Wake On Motion. More...
int | inv_imu_adv_enable_wom (inv_imu_device_t *s)
| Enable Wake On Motion. More...
int | inv_imu_adv_disable_wom (inv_imu_device_t *s)
| Disable Wake On Motion. More...
int | inv_imu_adv_set_endianness (inv_imu_device_t *s, sreg_ctrl_sreg_data_endian_sel_t endianness)
| Set the UI endianness and set the inv_device endianness field. More...
int | inv_imu_adv_power_up_sram (inv_imu_device_t *s)
| Power-up the SRAM. More...
int | inv_imu_adv_power_down_sram (inv_imu_device_t *s)
| Power-down the SRAM. More...

## Detailed Description

High-level API for advanced functionalities.

## Macro Definition Documentation

## ◆ FIFO_MIRRORING_SIZE

#define FIFO_MIRRORING_SIZE 16 * 258 /* packet size * max_count = 4kB */

Maximum buffer size mirrored from FIFO.

## Enumeration Type Documentation

## ◆ inv_imu_sensor_id_t

enum inv_imu_sensor_id_t

Sensor identifier enumeration.

Enumerator
INV_SENSOR_ACCEL |
INV_SENSOR_GYRO |
INV_SENSOR_FSYNC_EVENT |
INV_SENSOR_TEMPERATURE |
INV_SENSOR_EDMP_PEDOMETER_EVENT |
INV_SENSOR_EDMP_PEDOMETER_COUNT |
INV_SENSOR_EDMP_TILT |
INV_SENSOR_EDMP_FF |
INV_SENSOR_EDMP_LOWG |
INV_SENSOR_EDMP_HIGHG |
INV_SENSOR_EDMP_SMD |
INV_SENSOR_EDMP_TAP |
INV_SENSOR_EDMP_R2W_WAKE |
INV_SENSOR_EDMP_R2W_SLEEP |
INV_SENSOR_ES0 |
INV_SENSOR_ES1 |
INV_SENSOR_MAX |

## Function Documentation

## ◆ inv_imu_adv_configure_wom()

int inv_imu_adv_configure_wom | ( | inv_imu_device_t * | s,
|  | const uint8_t | wom_x_th,
|  | const uint8_t | wom_y_th,
|  | const uint8_t | wom_z_th,
|  | tmst_wom_config_wom_int_mode_t | wom_int,
|  | tmst_wom_config_wom_int_dur_t | wom_dur
| ) |  |

Enable Wake On Motion.

Parameters

  [in] | s | Pointer to device.
  [in] | wom_x_th | Threshold for X axis with 1g/256 resolution (wom_x_th = mg * 256 / 1000).
  [in] | wom_y_th | Threshold for Y axis with 1g/256 resolution (wom_y_th = mg * 256 / 1000).
  [in] | wom_z_th | Threshold for Z axis with 1g/256 resolution (wom_z_th = mg * 256 / 1000).
  [in] | wom_int | Mode used to generate interrupt (AND/OR).
  [in] | wom_dur | Number of overthreshold events to wait before generating interrupt.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_convert_odr_bitfield_to_us()

uint32_t inv_imu_adv_convert_odr_bitfield_to_us | ( | uint32_t | odr_bitfield | ) |

Converts accel_config0_accel_odr_t or gyro_config0_gyro_odr_t enums to period expressed in us.

Parameters

  [in] | odr_bitfield | An accel_config0_accel_odr_t or gyro_config0_gyro_odr_t enum

Returns
  The corresponding period expressed in us

## ◆ inv_imu_adv_device_reset()

int inv_imu_adv_device_reset | ( | inv_imu_device_t * | s | ) |

Performs a soft reset of the device.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_disable_accel()

int inv_imu_adv_disable_accel | ( | inv_imu_device_t * | s | ) |

Disable accel.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_disable_gyro()

int inv_imu_adv_disable_gyro | ( | inv_imu_device_t * | s | ) |

Disable gyro.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_disable_wom()

int inv_imu_adv_disable_wom | ( | inv_imu_device_t * | s | ) |

Disable Wake On Motion.

note : Fifo water-mark interrupt is re-enabled when WoM is disabled.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_enable_accel_ln()

int inv_imu_adv_enable_accel_ln | ( | inv_imu_device_t * | s | ) |

Enable accel in low noise mode.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_enable_accel_lp()

int inv_imu_adv_enable_accel_lp | ( | inv_imu_device_t * | s | ) |

Enable accel in low power mode.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_enable_gyro_ln()

int inv_imu_adv_enable_gyro_ln | ( | inv_imu_device_t * | s | ) |

Enable gyro in low noise mode.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_enable_gyro_lp()

int inv_imu_adv_enable_gyro_lp | ( | inv_imu_device_t * | s | ) |

Enable gyro in low power mode.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_enable_wom()

int inv_imu_adv_enable_wom | ( | inv_imu_device_t * | s | ) |

Enable Wake On Motion.

note : WoM requests to have the accelerometer enabled to work. As a consequence Fifo water-mark interrupt is disabled to only trigger WoM interrupts. To have good performance, it's recommended to set accelerometer ODR (Output Data Rate) to 20ms and the accelerometer in Low Power Mode.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_get_accel_fsr()

int inv_imu_adv_get_accel_fsr | ( | inv_imu_device_t * | s,
|  | accel_config0_accel_ui_fs_sel_t * | accel_fsr
| ) |  |

Access accel full scale range.

Parameters

  [in] | s | Pointer to device.
  [out] | accel_fsr | Current full scale range.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_get_data_from_fifo()

int inv_imu_adv_get_data_from_fifo | ( | inv_imu_device_t * | s,
|  | uint8_t | fifo_data[FIFO_MIRRORING_SIZE],
|  | uint16_t * | fifo_count
| ) |  |

Read all available packets from the FIFO.

Parameters

  [in] | s | Pointer to device.
  [out] | fifo_data | Pointer to FIFO data buffer.
  [out] | fifo_count | Number of packet read in FIFO.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_get_data_from_registers()

int inv_imu_adv_get_data_from_registers | ( | inv_imu_device_t * | s | ) |

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

It will then call `sensor_event_cb` function provided in the `inv_imu_device_t` for each packet.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_get_fifo_config()

int inv_imu_adv_get_fifo_config | ( | inv_imu_device_t * | s,
|  | inv_imu_adv_fifo_config_t * | conf
| ) |  |

Retrieve FIFO configuration.

Parameters

  [in] | s | Pointer to device.
  [in] | conf | Structure that will be filled with current configuration.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_get_gyro_fsr()

int inv_imu_adv_get_gyro_fsr | ( | inv_imu_device_t * | s,
|  | gyro_config0_gyro_ui_fs_sel_t * | gyro_fsr
| ) |  |

Access gyro full scale range.

Parameters

  [in] | s | Pointer to device.
  [out] | gyro_fsr | Current full scale range.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_get_timestamp_resolution_us()

uint32_t inv_imu_adv_get_timestamp_resolution_us | ( | inv_imu_device_t * | s | ) |

Get timestamp resolution.

Parameters

  [in] | s | Pointer to device.

Returns
  Timestamp resolution in us, negative value on error

## ◆ inv_imu_adv_init()

int inv_imu_adv_init | ( | inv_imu_device_t * | s | ) |

Initializes device.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_parse_fifo_data()

int inv_imu_adv_parse_fifo_data | ( | inv_imu_device_t * | s,
|  | const uint8_t | fifo_data[FIFO_MIRRORING_SIZE],
|  | const uint16_t | fifo_count
| ) |  |

Parse packets from FIFO buffer.

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

Parameters

  [in] | s | Pointer to device.
  [in] | fifo_data | Pointer to FIFO data buffer.
  [in] | fifo_count | Number of packet read in FIFO.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_power_down_sram()

int inv_imu_adv_power_down_sram | ( | inv_imu_device_t * | s | ) |

Power-down the SRAM.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_power_up_sram()

int inv_imu_adv_power_up_sram | ( | inv_imu_device_t * | s | ) |

Power-up the SRAM.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_reset_fifo()

int inv_imu_adv_reset_fifo | ( | inv_imu_device_t * | s | ) |

reset IMU fifo

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_set_endianness()

int inv_imu_adv_set_endianness | ( | inv_imu_device_t * | s,
|  | sreg_ctrl_sreg_data_endian_sel_t | endianness
| ) |  |

Set the UI endianness and set the inv_device endianness field.

Parameters

  [in] | s | Pointer to device.
  [in] | endianness | Requested endianness value.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_set_fifo_config()

int inv_imu_adv_set_fifo_config | ( | inv_imu_device_t * | s,
|  | const inv_imu_adv_fifo_config_t * | conf
| ) |  |

Set FIFO configuration.

Parameters

  [in] | s | Pointer to device.
  [in] | conf | Structure containing the requested configuration.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_adv_set_timestamp_resolution()

int inv_imu_adv_set_timestamp_resolution | ( | inv_imu_device_t * | s,
|  | const tmst_wom_config_tmst_resol_t | timestamp_resol
| ) |  |

Set timestamp resolution.

Parameters

  [in] | s | Pointer to device.
  [in] | timestamp_resol | Requested timestamp resolution

Returns
  0 on success, negative value on error.