ICM40627 Motion Sensor#

Introduction#

The ICM40627 motion sensor driver provides a set of functions for interacting with the ICM40627 6-axis motion sensor over the SPI interface. It enables integration of the sensor by offering APIs for initialization, configuration, data acquisition, and calibration. The driver supports reading acceleration, gyroscope, and temperature data, as well as configuring output data rates, full-scale ranges, and interrupt handling.

Usage#

After initializing the SSI (SPI) peripheral and configuring the ICM40627 sensor, the following common operations are available:

  1. Initialize the ICM40627 sensor:sl_si91x_icm40627_init

  2. Read the device ID to verify sensor presence:sl_si91x_icm40627_get_device_id

  3. Read acceleration data (in g):sl_si91x_icm40627_get_accel_data

  4. Read gyroscope data (in deg/sec):sl_si91x_icm40627_get_gyro_data

  5. Read temperature data (in Celsius):sl_si91x_icm40627_get_temperature_data

  6. Set output data rates and bandwidths for accelerometer and gyroscope:sl_si91x_icm40627_set_sample_rate, sl_si91x_icm40627_set_accel_bandwidth, sl_si91x_icm40627_set_gyro_bandwidth

  7. Configure full-scale ranges for accelerometer and gyroscope:sl_si91x_icm40627_set_accel_full_scale, sl_si91x_icm40627_set_gyro_full_scale

  8. Enable or disable sensor interrupts:sl_si91x_icm40627_enable_interrupt

  9. Calibrate accelerometer and gyroscope biases:sl_si91x_icm40627_calibrate_accel_and_gyro

  • See the Function Documentation for detailed usage information of all APIs.

Functions#

sl_status_t
icm40627_select_register_bank(sl_ssi_handle_t ssi_driver_handle, uint8_t bank)

Select the desired Register bank.

sl_status_t
sl_si91x_icm40627_software_reset(sl_ssi_handle_t ssi_driver_handle)

Perform soft reset on the ICM40627 chip.

sl_status_t
sl_si91x_icm40627_set_gyro_bandwidth(sl_ssi_handle_t ssi_driver_handle, uint8_t gyro_ODR)

Set the bandwidth of the gyroscope.

sl_status_t
sl_si91x_icm40627_set_accel_bandwidth(sl_ssi_handle_t ssi_driver_handle, uint8_t accel_ODR)

Set the bandwidth of the accelerometer.

sl_status_t
sl_si91x_icm40627_enable_sleep_mode(sl_ssi_handle_t ssi_driver_handle, bool enable)

Enable or disable the sleep mode of the ICM40627 device.

float
sl_si91x_icm40627_set_sample_rate(sl_ssi_handle_t ssi_driver_handle, float sample_rate)

Sets the sample rate for both the accelerometer and the gyroscope.

sl_status_t
sl_si91x_icm40627_accel_set_sample_rate(sl_ssi_handle_t ssi_driver_handle, uint8_t accel_ODR)

Set the sample rate(Output Data Rate) of the accelerometer.

sl_status_t
sl_si91x_icm40627_gyro_set_sample_rate(sl_ssi_handle_t ssi_driver_handle, uint8_t gyro_ODR)

Set the sample rate(Output Data Rate) of the gyroscope.

sl_status_t
sl_si91x_icm40627_get_accel_data(sl_ssi_handle_t ssi_driver_handle, float accel[3])

Read the raw acceleration value and convert to g value based on the actual resolution.

sl_status_t
sl_si91x_icm40627_get_gyro_data(sl_ssi_handle_t ssi_driver_handle, float gyro[3])

Read the raw gyroscope value and convert to deg/sec value based on the actual resolution.

sl_status_t
sl_si91x_icm40627_get_accel_resolution(sl_ssi_handle_t ssi_driver_handle, float *accel_res)

Get the actual resolution of the accelerometer.

sl_status_t
sl_si91x_icm40627_get_gyro_resolution(sl_ssi_handle_t ssi_driver_handle, float *gyro_res)

Get the actual resolution of the gyroscope.

sl_status_t
sl_si91x_icm40627_set_accel_full_scale(sl_ssi_handle_t ssi_driver_handle, uint8_t accelFs)

Set the full scale value of the accelerometer.

sl_status_t
sl_si91x_icm40627_set_gyro_full_scale(sl_ssi_handle_t ssi_driver_handle, uint8_t accelFs)

Set the full scale value of the gyroscope.

sl_status_t
sl_si91x_icm40627_enable_interrupt(sl_ssi_handle_t ssi_driver_handle, bool dataReadyEnable, bool womEnable)

Enable or disable the interrupts in the ICM40627 chip.

sl_status_t
sl_si91x_icm40627_read_interrupt_status(sl_ssi_handle_t ssi_driver_handle, uint32_t *int_status)

Read the interrupt status registers of the ICM40627 chip.

bool
sl_si91x_icm40627_is_data_ready(sl_ssi_handle_t ssi_driver_handle)

Check if new data is available to read.

sl_status_t
sl_si91x_icm40627_enable_sensor(sl_ssi_handle_t ssi_driver_handle, bool accel, bool gyro, bool temp)

Enable or disable the sensors in the ICM40627 chip.

sl_status_t
sl_si91x_icm40627_init(sl_ssi_handle_t ssi_driver_handle)

Initialize the ICM40627 sensor.

sl_status_t

De-initialize the ICM40627 sensor by disconnecting the supply and SPI lines.

sl_status_t
sl_si91x_icm40627_calibrate_accel_and_gyro(sl_ssi_handle_t ssi_driver_handle, float *accel_bias_scaled, float *gyro_bias_scaled)

Accelerometer and gyroscope calibration function.

sl_status_t
sl_si91x_icm40627_get_temperature_data(sl_ssi_handle_t ssi_driver_handle, float *temp_data)

Read the temperature sensor raw value and convert to Celsius.

sl_status_t
sl_si91x_icm40627_get_device_id(sl_ssi_handle_t ssi_driver_handle, uint8_t *dev_id)

Read the device ID of the ICM40627.

Function Documentation#

icm40627_select_register_bank#

sl_status_t icm40627_select_register_bank (sl_ssi_handle_t ssi_driver_handle, uint8_t bank)

Select the desired Register bank.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

uint8_t[in]bank

The address of the Register bank (0..3)


sl_si91x_icm40627_software_reset#

sl_status_t sl_si91x_icm40627_software_reset (sl_ssi_handle_t ssi_driver_handle)

Perform soft reset on the ICM40627 chip.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_set_gyro_bandwidth#

sl_status_t sl_si91x_icm40627_set_gyro_bandwidth (sl_ssi_handle_t ssi_driver_handle, uint8_t gyro_ODR)

Set the bandwidth of the gyroscope.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

uint8_t[in]gyro_ODR

The desired ODR value. Use the ICM40627_GYRO_BW_xHZ macros, which are defined in the icm40627.h file. The value of x can be 6, 12, 24, 51, 120, 150, 200, 360 or 12100.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_set_accel_bandwidth#

sl_status_t sl_si91x_icm40627_set_accel_bandwidth (sl_ssi_handle_t ssi_driver_handle, uint8_t accel_ODR)

Set the bandwidth of the accelerometer.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

uint8_t[in]accel_ODR

The desired ODR value. Use the ICM40627_ACCEL_BW_yHZ macros, which are defined in the icm40627.h file. The value of y can be 6, 12, 24, 50, 111, 246, 470 or 1210.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_enable_sleep_mode#

sl_status_t sl_si91x_icm40627_enable_sleep_mode (sl_ssi_handle_t ssi_driver_handle, bool enable)

Enable or disable the sleep mode of the ICM40627 device.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor.

bool[in]enable

If true, sleep mode is enabled to reduce power consumption by disabling the accelerometer and gyroscope while retaining essential functions for quick wake-up. Set to false to disable sleep mode and resume normal operation.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_set_sample_rate#

float sl_si91x_icm40627_set_sample_rate (sl_ssi_handle_t ssi_driver_handle, float sample_rate)

Sets the sample rate for both the accelerometer and the gyroscope.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor.

float[in]sample_rate

The desired sample rate in Hz. The function will set the closest available sample rate to the requested value if an exact match is not possible. Available sample rates (in Hz) are:

  • 8000.0, 4000.0, 2000.0, 1000.0, 500.0, 200.0, 100.0, 50.0, 25.0, 12.5

  • 6.25 (accelerometer only)

  • 3.125 (accelerometer only)

The accelerometer supports rates down to 3.125 Hz, while the gyroscope supports rates down to 12.5 Hz. Requests below 12.5 Hz will set only the accelerometer rate, with the gyroscope defaulting to 12.5 Hz.

Returns

  • The actual sample rate set, which may differ from the requested rate due to available sample rate options.


sl_si91x_icm40627_accel_set_sample_rate#

sl_status_t sl_si91x_icm40627_accel_set_sample_rate (sl_ssi_handle_t ssi_driver_handle, uint8_t accel_ODR)

Set the sample rate(Output Data Rate) of the accelerometer.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

uint8_t[in]accel_ODR

The desired sample rate value. Use the sl_accel_ODR_t enum, which are defined in the icm40627.h file. The value can be 8 kHz, 4 kHz, 2 kHz, 1 kHz, 500 Hz, 200 Hz, 100 Hz, 50 Hz 25 Hz, 12.5 Hz, 6.25 Hz, 3.125 Hz, 1.5625 Hz.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_gyro_set_sample_rate#

sl_status_t sl_si91x_icm40627_gyro_set_sample_rate (sl_ssi_handle_t ssi_driver_handle, uint8_t gyro_ODR)

Set the sample rate(Output Data Rate) of the gyroscope.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

uint8_t[in]gyro_ODR

The desired sample rate value. Use the sl_gyro_ODR_t enum, which are defined in the icm40627.h file. The value can be 8 kHz, 4 kHz, 2 kHz, 1 kHz, 500 Hz, 200 Hz, 100 Hz, 50 Hz 25 Hz, 12.5 Hz.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_get_accel_data#

sl_status_t sl_si91x_icm40627_get_accel_data (sl_ssi_handle_t ssi_driver_handle, float accel)

Read the raw acceleration value and convert to g value based on the actual resolution.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

float[out]accel

A 3-element array of float numbers containing the acceleration values for the x, y and z axes in g units.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_get_gyro_data#

sl_status_t sl_si91x_icm40627_get_gyro_data (sl_ssi_handle_t ssi_driver_handle, float gyro)

Read the raw gyroscope value and convert to deg/sec value based on the actual resolution.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

float[out]gyro

A 3-element array of float numbers containing the gyroscope values for the x, y and z axes in deg/sec units.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_get_accel_resolution#

sl_status_t sl_si91x_icm40627_get_accel_resolution (sl_ssi_handle_t ssi_driver_handle, float * accel_res)

Get the actual resolution of the accelerometer.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

float *[out]accel_res

The resolution in g/bit units

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_get_gyro_resolution#

sl_status_t sl_si91x_icm40627_get_gyro_resolution (sl_ssi_handle_t ssi_driver_handle, float * gyro_res)

Get the actual resolution of the gyroscope.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

float *[out]gyro_res

The actual resolution in (deg/sec)/bit units

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_set_accel_full_scale#

sl_status_t sl_si91x_icm40627_set_accel_full_scale (sl_ssi_handle_t ssi_driver_handle, uint8_t accelFs)

Set the full scale value of the accelerometer.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

uint8_t[in]accelFs

The desired full scale value. Use the ICM40627_ACCEL_FULLSCALE_xG macros, which are defined in the icm40627.h file. The value of x can be 2, 4, 8 or 16.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_set_gyro_full_scale#

sl_status_t sl_si91x_icm40627_set_gyro_full_scale (sl_ssi_handle_t ssi_driver_handle, uint8_t accelFs)

Set the full scale value of the gyroscope.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

uint8_t[in]accelFs

The desired full scale value. Use the ICM40627_GYRO_FULLSCALE_yDPS macros, which are defined in the icm40627.h file. The value of y can be 250, 500, 1000 or 2000.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_enable_interrupt#

sl_status_t sl_si91x_icm40627_enable_interrupt (sl_ssi_handle_t ssi_driver_handle, bool dataReadyEnable, bool womEnable)

Enable or disable the interrupts in the ICM40627 chip.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

bool[in]dataReadyEnable

If true, enables the Raw Data Ready interrupt, otherwise disables.

bool[in]womEnable

If true, enables the Wake-up On Motion interrupt, otherwise disables.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_read_interrupt_status#

sl_status_t sl_si91x_icm40627_read_interrupt_status (sl_ssi_handle_t ssi_driver_handle, uint32_t * int_status)

Read the interrupt status registers of the ICM40627 chip.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

uint32_t *[out]int_status

A 32-bit value that represents the combined status of the three interrupt registers: INT_STATUS, INT_STATUS2, and INT_STATUS3. Each bit in this value corresponds to a specific interrupt flag, as follows:

  • Bits 0-7 : INT_STATUS - Primary interrupt flags.

  • Bits 8-15 : INT_STATUS2 - Secondary interrupt flags.

  • Bits 16-23: INT_STATUS3 - Additional interrupt flags.

  • Bits 24-31: Reserved for future use (set to 0).

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_is_data_ready#

bool sl_si91x_icm40627_is_data_ready (sl_ssi_handle_t ssi_driver_handle)

Check if new data is available to read.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

Returns

  • Returns true if the Raw Data Ready interrupt bit is set, false otherwise.


sl_si91x_icm40627_enable_sensor#

sl_status_t sl_si91x_icm40627_enable_sensor (sl_ssi_handle_t ssi_driver_handle, bool accel, bool gyro, bool temp)

Enable or disable the sensors in the ICM40627 chip.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

bool[in]accel

If true, enables the acceleration sensor

bool[in]gyro

If true, enables the gyroscope sensor

bool[in]temp

If true, enables the temperature sensor

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_init#

sl_status_t sl_si91x_icm40627_init (sl_ssi_handle_t ssi_driver_handle)

Initialize the ICM40627 sensor.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

Enable the power supply and SPI lines, set up the host SPI controller, configure the chip control interface, clock generator, and interrupt line.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_deinit#

sl_status_t sl_si91x_icm40627_deinit (void )

De-initialize the ICM40627 sensor by disconnecting the supply and SPI lines.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_calibrate_accel_and_gyro#

sl_status_t sl_si91x_icm40627_calibrate_accel_and_gyro (sl_ssi_handle_t ssi_driver_handle, float * accel_bias_scaled, float * gyro_bias_scaled)

Accelerometer and gyroscope calibration function.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

float *[out]accel_bias_scaled

The mesured acceleration sensor bias in mg

float *[out]gyro_bias_scaled

The mesured gyro sensor bias in deg/sec

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.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_get_temperature_data#

sl_status_t sl_si91x_icm40627_get_temperature_data (sl_ssi_handle_t ssi_driver_handle, float * temp_data)

Read the temperature sensor raw value and convert to Celsius.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

float *[out]temp_data

The mesured temperature in Celsius

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.


sl_si91x_icm40627_get_device_id#

sl_status_t sl_si91x_icm40627_get_device_id (sl_ssi_handle_t ssi_driver_handle, uint8_t * dev_id)

Read the device ID of the ICM40627.

Parameters
TypeDirectionArgument NameDescription
sl_ssi_handle_t[in]ssi_driver_handle

The handle to the SSI driver used for communication with the ICM40627 sensor

uint8_t *[out]dev_id

The ID of the device read from the WHO_AM_I Register. Expected value 0xE0.

Returns

  • sl_status_t Status code indicating the result:

    • SL_STATUS_OK - Success.

    • SL_STATUS_INVALID_PARAMETER - The parameter is an invalid argument.

For more information on status codes, see SL STATUS DOCUMENTATION.