ICM42670 Portable Driver
Public API reference for the ICM-42670-P IMU driver
Loading...
Searching...
No Matches
ICM42670_apex.h File Reference

Optional APEX motion feature API for the ICM-42670-P. More...

#include "ICM42670_driver.h"
Include dependency graph for ICM42670_apex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ICM42670_PedoConfig_t
 Pedometer configuration. More...
 
struct  ICM42670_PedoData_t
 Pedometer output data. More...
 
struct  ICM42670_TiltConfig_t
 Tilt detection configuration. More...
 
struct  ICM42670_LowGConfig_t
 Low-g detection configuration. More...
 
struct  ICM42670_FreeFallConfig_t
 Freefall detection configuration. More...
 
struct  ICM42670_FreeFallData_t
 Freefall output data. More...
 
struct  ICM42670_WakeOnMotionConfig_t
 Wake-on-motion threshold configuration. More...
 
struct  ICM42670_WakeOnMotionData_t
 Wake-on-motion output flags. More...
 
struct  ICM42670_SignificantMotionConfig_t
 Significant-motion sensitivity configuration. More...
 
struct  ICM42670_ApexData_t
 Combined APEX snapshot data. More...
 

Enumerations

enum  ICM42670_ApexActivity_t { ICM42670_APEX_ACTIVITY_UNKNOWN = 0U , ICM42670_APEX_ACTIVITY_WALK = 1U , ICM42670_APEX_ACTIVITY_RUN = 2U }
 Pedometer activity classification.
 

Functions

ICM42670_Status_t ICM42670_Init_Apex (const ICM42670_Config *config)
 Initialize the APEX DMP block before enabling tilt/pedometer features.
 
ICM42670_Status_t ICM42670_Enable_Pedo (const ICM42670_Config *config, const ICM42670_PedoConfig_t *pedo_config)
 Pedometer tracks step count and issues a step detect interrupt.
 
ICM42670_Status_t ICM42670_Disable_Pedo (const ICM42670_Config *config)
 Disable pedometer reporting.
 
ICM42670_Status_t ICM42670_Read_Pedo (const ICM42670_Config *config, ICM42670_PedoData_t *pedo_data)
 Read pedometer data and read-clear step status flags.
 
ICM42670_Status_t ICM42670_Enable_Tilt (const ICM42670_Config *config, const ICM42670_TiltConfig_t *tilt_config)
 Tilt detection issues an interrupt when the tilt angle exceeds 35 degrees for more than a programmable time.
 
ICM42670_Status_t ICM42670_Disable_Tilt (const ICM42670_Config *config)
 Disable tilt detection.
 
ICM42670_Status_t ICM42670_Read_Tilt (const ICM42670_Config *config, uint8_t *tilt_detected)
 Read and clear the tilt event flag.
 
ICM42670_Status_t ICM42670_Enable_Low_G (const ICM42670_Config *config, const ICM42670_LowGConfig_t *low_g_config)
 Low-g detection triggers an interrupt when the absolute value of the accelerometer combined axis falls below a programmable threshold and stays below the threshold for a programmable time.
 
ICM42670_Status_t ICM42670_Disable_Low_G (const ICM42670_Config *config)
 Disable low-g detection.
 
ICM42670_Status_t ICM42670_Read_Low_G (const ICM42670_Config *config, uint8_t *low_g_detected)
 Read and clear the low-g event flag.
 
ICM42670_Status_t ICM42670_Enable_Free_Fall (const ICM42670_Config *config, const ICM42670_FreeFallConfig_t *free_fall_config)
 Freefall detection triggers an interrupt when device freefall is detected and outputs freefall duration.
 
ICM42670_Status_t ICM42670_Disable_Free_Fall (const ICM42670_Config *config)
 Disable freefall detection.
 
ICM42670_Status_t ICM42670_Read_Free_Fall (const ICM42670_Config *config, ICM42670_FreeFallData_t *free_fall_data)
 Read freefall data and read-clear the freefall event flag.
 
ICM42670_Status_t ICM42670_Enable_Wake_On_Motion (const ICM42670_Config *config, const ICM42670_WakeOnMotionConfig_t *wake_on_motion_config)
 Wake on Motion detects motion when accelerometer samples exceed a programmable threshold. This motion event can be used to enable device operation from sleep mode.
 
ICM42670_Status_t ICM42670_Disable_Wake_On_Motion (const ICM42670_Config *config)
 Disable wake-on-motion detection.
 
ICM42670_Status_t ICM42670_Read_Wake_On_Motion (const ICM42670_Config *config, ICM42670_WakeOnMotionData_t *wake_on_motion_data)
 Read and clear wake-on-motion axis flags.
 
ICM42670_Status_t ICM42670_Enable_Significant_Motion (const ICM42670_Config *config, const ICM42670_SignificantMotionConfig_t *significant_motion_config)
 Significant Motion Detector detects significant motion based on accelerometer data.
 
ICM42670_Status_t ICM42670_Disable_Significant_Motion (const ICM42670_Config *config)
 Disable significant-motion detection.
 
ICM42670_Status_t ICM42670_Read_Significant_Motion (const ICM42670_Config *config, uint8_t *significant_motion_detected)
 Read and clear the significant-motion event flag.
 
ICM42670_Status_t ICM42670_Read_Apex (const ICM42670_Config *config, ICM42670_ApexData_t *apex_data)
 Read a combined APEX data snapshot.
 

Detailed Description

Optional APEX motion feature API for the ICM-42670-P.

APEX features use the device's internal DMP. Call ICM42670_Init_Apex() before enabling pedometer, tilt, low-g, freefall, wake-on-motion, or significant-motion features.

Function Documentation

◆ ICM42670_Disable_Free_Fall()

ICM42670_Status_t ICM42670_Disable_Free_Fall ( const ICM42670_Config config)

Disable freefall detection.

Parameters
configDriver configuration with read and write callbacks.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

◆ ICM42670_Disable_Low_G()

ICM42670_Status_t ICM42670_Disable_Low_G ( const ICM42670_Config config)

Disable low-g detection.

Parameters
configDriver configuration with read and write callbacks.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

◆ ICM42670_Disable_Pedo()

ICM42670_Status_t ICM42670_Disable_Pedo ( const ICM42670_Config config)

Disable pedometer reporting.

Parameters
configDriver configuration with read and write callbacks.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

◆ ICM42670_Disable_Significant_Motion()

ICM42670_Status_t ICM42670_Disable_Significant_Motion ( const ICM42670_Config config)

Disable significant-motion detection.

Parameters
configDriver configuration with read and write callbacks.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

◆ ICM42670_Disable_Tilt()

ICM42670_Status_t ICM42670_Disable_Tilt ( const ICM42670_Config config)

Disable tilt detection.

Parameters
configDriver configuration with read and write callbacks.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

◆ ICM42670_Disable_Wake_On_Motion()

ICM42670_Status_t ICM42670_Disable_Wake_On_Motion ( const ICM42670_Config config)

Disable wake-on-motion detection.

Parameters
configDriver configuration with read and write callbacks.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

◆ ICM42670_Enable_Free_Fall()

ICM42670_Status_t ICM42670_Enable_Free_Fall ( const ICM42670_Config config,
const ICM42670_FreeFallConfig_t free_fall_config 
)

Freefall detection triggers an interrupt when device freefall is detected and outputs freefall duration.

Parameters
configDriver configuration with read and write callbacks.
free_fall_configFreefall setup values.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR or ICM42670_BUSY.

References ICM42670_FreeFallConfig_t::debounce_ms, ICM42670_ERROR, ICM42670_OK, ICM42670_FreeFallConfig_t::max_distance_cm, and ICM42670_FreeFallConfig_t::min_distance_cm.

◆ ICM42670_Enable_Low_G()

ICM42670_Status_t ICM42670_Enable_Low_G ( const ICM42670_Config config,
const ICM42670_LowGConfig_t low_g_config 
)

Low-g detection triggers an interrupt when the absolute value of the accelerometer combined axis falls below a programmable threshold and stays below the threshold for a programmable time.

Parameters
configDriver configuration with read and write callbacks.
low_g_configLow-g setup values.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR or ICM42670_BUSY.

References ICM42670_ERROR, ICM42670_OK, ICM42670_LowGConfig_t::sample_count, and ICM42670_LowGConfig_t::threshold_mg.

◆ ICM42670_Enable_Pedo()

ICM42670_Status_t ICM42670_Enable_Pedo ( const ICM42670_Config config,
const ICM42670_PedoConfig_t pedo_config 
)

Pedometer tracks step count and issues a step detect interrupt.

Parameters
configDriver configuration with read and write callbacks.
pedo_configPedometer setup values.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR or ICM42670_BUSY.

References ICM42670_ERROR, ICM42670_OK, and ICM42670_PedoConfig_t::slow_walk_enable.

◆ ICM42670_Enable_Significant_Motion()

ICM42670_Status_t ICM42670_Enable_Significant_Motion ( const ICM42670_Config config,
const ICM42670_SignificantMotionConfig_t significant_motion_config 
)

Significant Motion Detector detects significant motion based on accelerometer data.

Parameters
configDriver configuration with read and write callbacks.
significant_motion_configSignificant-motion setup values.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR or ICM42670_BUSY.

References ICM42670_ERROR, ICM42670_OK, and ICM42670_SignificantMotionConfig_t::sensitivity_level.

◆ ICM42670_Enable_Tilt()

ICM42670_Status_t ICM42670_Enable_Tilt ( const ICM42670_Config config,
const ICM42670_TiltConfig_t tilt_config 
)

Tilt detection issues an interrupt when the tilt angle exceeds 35 degrees for more than a programmable time.

Parameters
configDriver configuration with read and write callbacks.
tilt_configTilt setup values.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR or ICM42670_BUSY.

References ICM42670_ERROR, ICM42670_OK, and ICM42670_TiltConfig_t::wait_time_s.

◆ ICM42670_Enable_Wake_On_Motion()

ICM42670_Status_t ICM42670_Enable_Wake_On_Motion ( const ICM42670_Config config,
const ICM42670_WakeOnMotionConfig_t wake_on_motion_config 
)

Wake on Motion detects motion when accelerometer samples exceed a programmable threshold. This motion event can be used to enable device operation from sleep mode.

Parameters
configDriver configuration with read and write callbacks.
wake_on_motion_configWake-on-motion threshold setup.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR or ICM42670_BUSY.

References ICM42670_ERROR, ICM42670_OK, ICM42670_WakeOnMotionConfig_t::x_threshold_mg, ICM42670_WakeOnMotionConfig_t::y_threshold_mg, and ICM42670_WakeOnMotionConfig_t::z_threshold_mg.

◆ ICM42670_Init_Apex()

ICM42670_Status_t ICM42670_Init_Apex ( const ICM42670_Config config)

Initialize the APEX DMP block before enabling tilt/pedometer features.

This sets DMP_ODR to 50 Hz, disables DMP power-save for direct polling use, resets APEX memory, and runs the DMP initialization command.

Parameters
configDriver configuration with read, write, and delay callbacks.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR or ICM42670_BUSY.

References ICM42670_Config::delay_ms, ICM42670_ERROR, and ICM42670_OK.

◆ ICM42670_Read_Apex()

ICM42670_Status_t ICM42670_Read_Apex ( const ICM42670_Config config,
ICM42670_ApexData_t apex_data 
)

◆ ICM42670_Read_Free_Fall()

ICM42670_Status_t ICM42670_Read_Free_Fall ( const ICM42670_Config config,
ICM42670_FreeFallData_t free_fall_data 
)

Read freefall data and read-clear the freefall event flag.

Parameters
configDriver configuration with a read callback.
free_fall_dataDestination for freefall data.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

References ICM42670_FreeFallData_t::detected, ICM42670_FreeFallData_t::duration_samples, ICM42670_ERROR, and ICM42670_OK.

◆ ICM42670_Read_Low_G()

ICM42670_Status_t ICM42670_Read_Low_G ( const ICM42670_Config config,
uint8_t *  low_g_detected 
)

Read and clear the low-g event flag.

Parameters
configDriver configuration with a read callback.
low_g_detectedDestination flag, nonzero when low-g was reported.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

References ICM42670_ERROR, and ICM42670_OK.

◆ ICM42670_Read_Pedo()

ICM42670_Status_t ICM42670_Read_Pedo ( const ICM42670_Config config,
ICM42670_PedoData_t pedo_data 
)

Read pedometer data and read-clear step status flags.

Parameters
configDriver configuration with a read callback.
pedo_dataDestination for pedometer data.
Returns
ICM42670_OK on success, ICM42670_BUSY if data is invalid, otherwise ICM42670_ERROR.

References ICM42670_PedoData_t::activity, ICM42670_PedoData_t::cadence_raw, ICM42670_BUSY, ICM42670_ERROR, ICM42670_OK, ICM42670_PedoData_t::overflow, ICM42670_PedoData_t::step_count, and ICM42670_PedoData_t::step_detected.

◆ ICM42670_Read_Significant_Motion()

ICM42670_Status_t ICM42670_Read_Significant_Motion ( const ICM42670_Config config,
uint8_t *  significant_motion_detected 
)

Read and clear the significant-motion event flag.

Parameters
configDriver configuration with a read callback.
significant_motion_detectedDestination flag, nonzero when reported.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

References ICM42670_ERROR, and ICM42670_OK.

◆ ICM42670_Read_Tilt()

ICM42670_Status_t ICM42670_Read_Tilt ( const ICM42670_Config config,
uint8_t *  tilt_detected 
)

Read and clear the tilt event flag.

Parameters
configDriver configuration with a read callback.
tilt_detectedDestination flag, nonzero when tilt was reported.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

References ICM42670_ERROR, and ICM42670_OK.

◆ ICM42670_Read_Wake_On_Motion()

ICM42670_Status_t ICM42670_Read_Wake_On_Motion ( const ICM42670_Config config,
ICM42670_WakeOnMotionData_t wake_on_motion_data 
)

Read and clear wake-on-motion axis flags.

Parameters
configDriver configuration with a read callback.
wake_on_motion_dataDestination for axis flags.
Returns
ICM42670_OK on success, otherwise ICM42670_ERROR.

References ICM42670_ERROR, ICM42670_OK, ICM42670_WakeOnMotionData_t::x_detected, ICM42670_WakeOnMotionData_t::y_detected, and ICM42670_WakeOnMotionData_t::z_detected.