| ICM45605 eMD driver Documentation of the eMD Driver API

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

Files | Classes | Macros | Functions
Basic Driver

Basic API to drive the device. More...

## Files
file | inv_imu_driver.h

## Classes
struct | inv_imu_device_t
| Basic driver configuration structure. More...
union | inv_imu_fifo_data_t
| One frame of FIFO header+data. More...
struct | inv_imu_int_state_t
| Interrupts definition. More...
struct | inv_imu_fifo_config_t
| Basic FIFO configuration. More...

## Macros
#define | FORMAT_16_BITS_DATA(is_big_endian, pIn8, pOut16) *(pOut16) = ((is_big_endian) == 1) ? ((pIn8)[0] << 8) | (pIn8)[1] : ((pIn8)[1] << 8) | (pIn8)[0]
| Macro to convert 2 bytes in 1 half-word depending on IMU endianness. More...

## Functions
void | inv_imu_sleep_us (inv_imu_device_t *s, uint32_t us)
| Sleep function. More...
int | inv_imu_soft_reset (inv_imu_device_t *s)
| Performs a soft reset of the device. More...
int | inv_imu_get_who_am_i (inv_imu_device_t *s, uint8_t *who_am_i)
| return WHOAMI value More...
int | inv_imu_set_accel_mode (inv_imu_device_t *s, pwr_mgmt0_accel_mode_t accel_mode)
| Configure accel mode. More...
int | inv_imu_set_gyro_mode (inv_imu_device_t *s, pwr_mgmt0_gyro_mode_t gyro_mode)
| Configure gyro mode. More...
int | inv_imu_set_accel_frequency (inv_imu_device_t *s, const accel_config0_accel_odr_t frequency)
| Configure accel Output Data Rate. More...
int | inv_imu_set_gyro_frequency (inv_imu_device_t *s, const gyro_config0_gyro_odr_t frequency)
| Configure gyro Output Data Rate. More...
int | inv_imu_set_accel_fsr (inv_imu_device_t *s, accel_config0_accel_ui_fs_sel_t accel_fsr)
| Set accel full scale range. More...
int | inv_imu_set_gyro_fsr (inv_imu_device_t *s, gyro_config0_gyro_ui_fs_sel_t gyro_fsr)
| Set gyro full scale range. More...
int | inv_imu_set_accel_lp_avg (inv_imu_device_t *s, ipreg_sys2_reg_129_accel_lp_avg_sel_t acc_avg)
| Set accel Low-Power averaging value. More...
int | inv_imu_set_gyro_lp_avg (inv_imu_device_t *s, ipreg_sys1_reg_170_gyro_lp_avg_sel_t gyr_avg)
| Set gyro Low-Power averaging value. More...
int | inv_imu_set_accel_ln_bw (inv_imu_device_t *s, ipreg_sys2_reg_131_accel_ui_lpfbw_t acc_bw)
| Set accel Low-Noise bandwidth value. More...
int | inv_imu_set_gyro_ln_bw (inv_imu_device_t *s, ipreg_sys1_reg_172_gyro_ui_lpfbw_sel_t gyr_bw)
| Set gyro Low-Noise bandwidth value. More...
int | inv_imu_get_register_data (inv_imu_device_t *s, inv_imu_sensor_data_t *data)
| Get current sensor data from the registers. More...
int | inv_imu_set_fifo_config (inv_imu_device_t *s, const inv_imu_fifo_config_t *fifo_config)
| Configures the FIFO to the specified state. More...
int | inv_imu_get_fifo_config (inv_imu_device_t *s, inv_imu_fifo_config_t *fifo_config)
| Gets the current FIFO configuration. More...
int | inv_imu_flush_fifo (inv_imu_device_t *s)
| Flush FIFO content. More...
int | inv_imu_get_frame_count (inv_imu_device_t *s, uint16_t *frame_count)
| Get FIFO frame count. More...
int | inv_imu_get_fifo_frame (inv_imu_device_t *s, inv_imu_fifo_data_t *data)
| Get one frame of FIFO data. More...
int | inv_imu_set_config_int (inv_imu_device_t *s, const inv_imu_int_num_t num, const inv_imu_int_state_t *it)
| Configure interrupts source. More...
int | inv_imu_get_config_int (inv_imu_device_t *s, const inv_imu_int_num_t num, inv_imu_int_state_t *it)
| Retrieve interrupts configuration. More...
int | inv_imu_set_pin_config_int (inv_imu_device_t *s, const inv_imu_int_num_t num, const inv_imu_int_pin_config_t *conf)
| Configure pin behavior. More...
int | inv_imu_get_int_status (inv_imu_device_t *s, const inv_imu_int_num_t num, inv_imu_int_state_t *it)
| Read interrupt 1 status. More...
int | inv_imu_get_endianness (inv_imu_device_t *s)
| Read the UI endianness and set the inv_device endianness field. More...
int | inv_imu_select_accel_lp_clk (inv_imu_device_t *s, smc_control_0_accel_lp_clk_sel_t clk_sel)
| Select which clock to use when in Low Power mode. More...
const char * | inv_imu_get_version (void)
| Return driver version x.y.z-suffix as a char array. More...

## Detailed Description

Basic API to drive the device.

## Macro Definition Documentation

## ◆ FORMAT_16_BITS_DATA

#define FORMAT_16_BITS_DATA | ( |  | is_big_endian,
|  |  | pIn8,
|  |  | pOut16
| ) |  | *(pOut16) = ((is_big_endian) == 1) ? ((pIn8)[0] << 8) | (pIn8)[1] : ((pIn8)[1] << 8) | (pIn8)[0]

Macro to convert 2 bytes in 1 half-word depending on IMU endianness.

## Function Documentation

## ◆ inv_imu_flush_fifo()

int inv_imu_flush_fifo | ( | inv_imu_device_t * | s | ) |

Flush FIFO content.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_get_config_int()

int inv_imu_get_config_int | ( | inv_imu_device_t * | s,
|  | const inv_imu_int_num_t | num,
|  | inv_imu_int_state_t * | it
| ) |  |

Retrieve interrupts configuration.

Parameters

  [in] | s | Pointer to device.
  [in] | num | Interrupt number
  [out] | it | State of each interrupt

Returns
  0 on success, negative value on error.

## ◆ inv_imu_get_endianness()

int inv_imu_get_endianness | ( | inv_imu_device_t * | s | ) |

Read the UI endianness and set the inv_device endianness field.

Parameters

  [in] | s | Pointer to device.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_get_fifo_config()

int inv_imu_get_fifo_config | ( | inv_imu_device_t * | s,
|  | inv_imu_fifo_config_t * | fifo_config
| ) |  |

Gets the current FIFO configuration.

Parameters

  [in] | s | Pointer to device.
  [in] | fifo_config | Structure containing the FIFO configuration.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_get_fifo_frame()

int inv_imu_get_fifo_frame | ( | inv_imu_device_t * | s,
|  | inv_imu_fifo_data_t * | data
| ) |  |

Get one frame of FIFO data.

Parameters

  [in] | s | Pointer to device.
  [out] | data | Accel, gyro and temperature data from the top frame on the FIFO.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_get_frame_count()

int inv_imu_get_frame_count | ( | inv_imu_device_t * | s,
|  | uint16_t * | frame_count
| ) |  |

Get FIFO frame count.

Parameters

  [in] | s | Pointer to device.
  [out] | frame_count | The number of frames in the FIFO.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_get_int_status()

int inv_imu_get_int_status | ( | inv_imu_device_t * | s,
|  | const inv_imu_int_num_t | num,
|  | inv_imu_int_state_t * | it
| ) |  |

Read interrupt 1 status.

Parameters

  [in] | s | Pointer to device.
  [in] | num | Interrupt number
  [out] | it | Status of each interrupt.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_get_register_data()

int inv_imu_get_register_data | ( | inv_imu_device_t * | s,
|  | inv_imu_sensor_data_t * | data
| ) |  |

Get current sensor data from the registers.

Parameters

  [in] | s | Pointer to device.
  [out] | data | Current accel, gyro and temperature data from the registers.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_get_version()

const char* inv_imu_get_version | ( | void |  | ) |

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

Returns
  Driver version as char array "x.y.z-suffix"

## ◆ inv_imu_get_who_am_i()

int inv_imu_get_who_am_i | ( | inv_imu_device_t * | s,
|  | uint8_t * | who_am_i
| ) |  |

return WHOAMI value

Parameters

  [in] | s | Pointer to device.
  [out] | who_am_i | WHOAMI for device

Returns
  0 on success, negative value on error

## ◆ inv_imu_select_accel_lp_clk()

int inv_imu_select_accel_lp_clk | ( | inv_imu_device_t * | s,
|  | smc_control_0_accel_lp_clk_sel_t | clk_sel
| ) |  |

Select which clock to use when in Low Power mode.

Use `SMC_CONTROL_0_ACCEL_LP_CLK_RCOSC` for Low Power (LP) mode. Use `SMC_CONTROL_0_ACCEL_LP_CLK_WUOSC` for Ultra Low Power (ULP) mode.

Note
  In ULP mode, sensor registers are not available and the host must retrieve data from the FIFO.

Parameters

  [in] | s | Pointer to device.
  [in] | clk_sel | Selected clock.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_accel_frequency()

int inv_imu_set_accel_frequency | ( | inv_imu_device_t * | s,
|  | const accel_config0_accel_odr_t | frequency
| ) |  |

Configure accel Output Data Rate.

Parameters

  [in] | s | Pointer to device.
  [in] | frequency | The requested frequency.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_accel_fsr()

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

Set accel full scale range.

Parameters

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

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_accel_ln_bw()

int inv_imu_set_accel_ln_bw | ( | inv_imu_device_t * | s,
|  | ipreg_sys2_reg_131_accel_ui_lpfbw_t | acc_bw
| ) |  |

Set accel Low-Noise bandwidth value.

Parameters

  [in] | s | Pointer to device.
  [in] | acc_bw | Requested bandwidth value

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_accel_lp_avg()

int inv_imu_set_accel_lp_avg | ( | inv_imu_device_t * | s,
|  | ipreg_sys2_reg_129_accel_lp_avg_sel_t | acc_avg
| ) |  |

Set accel Low-Power averaging value.

Parameters

  [in] | s | Pointer to device.
  [in] | acc_avg | Requested averaging value

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_accel_mode()

int inv_imu_set_accel_mode | ( | inv_imu_device_t * | s,
|  | pwr_mgmt0_accel_mode_t | accel_mode
| ) |  |

Configure accel mode.

Parameters

  [in] | s | Pointer to transport structure.
  [in] | accel_mode | The requested mode.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_config_int()

int inv_imu_set_config_int | ( | inv_imu_device_t * | s,
|  | const inv_imu_int_num_t | num,
|  | const inv_imu_int_state_t * | it
| ) |  |

Configure interrupts source.

Parameters

  [in] | s | Pointer to device.
  [in] | num | Interrupt number
  [in] | it | State of each interrupt

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_fifo_config()

int inv_imu_set_fifo_config | ( | inv_imu_device_t * | s,
|  | const inv_imu_fifo_config_t * | fifo_config
| ) |  |

Configures the FIFO to the specified state.

Parameters

  [in] | s | Pointer to device.
  [in] | fifo_config | Structure containing the FIFO configuration.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_gyro_frequency()

int inv_imu_set_gyro_frequency | ( | inv_imu_device_t * | s,
|  | const gyro_config0_gyro_odr_t | frequency
| ) |  |

Configure gyro Output Data Rate.

Parameters

  [in] | s | Pointer to device.
  [in] | frequency | The requested frequency.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_gyro_fsr()

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

Set gyro full scale range.

Parameters

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

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_gyro_ln_bw()

int inv_imu_set_gyro_ln_bw | ( | inv_imu_device_t * | s,
|  | ipreg_sys1_reg_172_gyro_ui_lpfbw_sel_t | gyr_bw
| ) |  |

Set gyro Low-Noise bandwidth value.

Parameters

  [in] | s | Pointer to device.
  [in] | gyr_bw | Requested bandwidth value

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_gyro_lp_avg()

int inv_imu_set_gyro_lp_avg | ( | inv_imu_device_t * | s,
|  | ipreg_sys1_reg_170_gyro_lp_avg_sel_t | gyr_avg
| ) |  |

Set gyro Low-Power averaging value.

Parameters

  [in] | s | Pointer to device.
  [in] | gyr_avg | Requested averaging value

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_gyro_mode()

int inv_imu_set_gyro_mode | ( | inv_imu_device_t * | s,
|  | pwr_mgmt0_gyro_mode_t | gyro_mode
| ) |  |

Configure gyro mode.

Parameters

  [in] | s | Pointer to transport structure.
  [in] | gyro_mode | The requested mode.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_set_pin_config_int()

int inv_imu_set_pin_config_int | ( | inv_imu_device_t * | s,
|  | const inv_imu_int_num_t | num,
|  | const inv_imu_int_pin_config_t * | conf
| ) |  |

Configure pin behavior.

Parameters

  [in] | s | Pointer to device.
  [in] | num | Interrupt number
  [in] | conf | Structure with the requested configuration.

Returns
  0 on success, negative value on error.

## ◆ inv_imu_sleep_us()

void inv_imu_sleep_us | ( | inv_imu_device_t * | s,
|  | uint32_t | us
| ) |  |

Sleep function.

Parameters

  [in] | s | Pointer to device.
  [in] | us | Time to sleep in microseconds.

## ◆ inv_imu_soft_reset()

int inv_imu_soft_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.