| ICM45686 eMD driver Documentation of the eMD Driver API

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

- File List
- File Members

inv_imu_driver_advanced.h
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) [2020] by InvenSense, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 *
16 */
17
25 #ifndef _INV_IMU_DRIVER_ADVANCED_H_
26 #define _INV_IMU_DRIVER_ADVANCED_H_
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #include "imu/inv_imu_driver.h"
33
34 #include <stdint.h>
35 #include <string.h>
36
38 #define FIFO_MIRRORING_SIZE 16 * 258 /* packet size * max_count = 4kB */
39
40 /*
41 * Driver's structures definitions
42 */
43
45 typedef struct {
49 int sensor_mask;
50
52 uint16_t timestamp_fsync;
53
55 int16_t accel[3];
56
58 int16_t gyro[3];
59
61 int16_t temperature;
62
64 int8_t accel_high_res[3];
65
67 int8_t gyro_high_res[3];
68
70 uint8_t es0[9];
71
73 uint8_t es1[6];
74 } inv_imu_sensor_event_t;
75
77 typedef struct {
81 void (*sensor_event_cb)(inv_imu_sensor_event_t *event);
82
83 /* The following fields will be initialized by inv_imu_adv_init() */
84 uint8_t fifo_is_used;
85 uint8_t fifo_comp_en;
86 fifo_config0_fifo_mode_t fifo_mode;
88 /* Variables related to FIFO compression */
89 int16_t accel_baseline[3];
90 int16_t gyro_baseline[3];
91 int16_t temp_baseline;
92 uint8_t accel_baseline_found;
93 uint8_t gyro_baseline_found;
94 uint8_t temp_baseline_found;
96 #if INV_IMU_FSYNC_SUPPORTED
97 /* Variables related to FSYNC tag */
98 fsync_config0_ap_fsync_sel_t fsync_tag;
99 #endif
100 } inv_imu_adv_var_t;
101
103 typedef enum {
104 INV_SENSOR_ACCEL,
105 INV_SENSOR_GYRO,
106 INV_SENSOR_FSYNC_EVENT,
107 INV_SENSOR_TEMPERATURE,
108 INV_SENSOR_EDMP_PEDOMETER_EVENT,
109 INV_SENSOR_EDMP_PEDOMETER_COUNT,
110 INV_SENSOR_EDMP_TILT,
111 INV_SENSOR_EDMP_FF,
112 INV_SENSOR_EDMP_LOWG,
113 INV_SENSOR_EDMP_HIGHG,
114 INV_SENSOR_EDMP_SMD,
115 INV_SENSOR_EDMP_TAP,
116 INV_SENSOR_EDMP_R2W_WAKE,
117 INV_SENSOR_EDMP_R2W_SLEEP,
118 INV_SENSOR_ES0,
119 INV_SENSOR_ES1,
120 INV_SENSOR_MAX
121 } inv_imu_sensor_id_t;
122
124 typedef struct {
126 inv_imu_fifo_config_t base_conf;
127
129 fifo_config2_fifo_wr_wm_gt_th_t fifo_wr_wm_gt_th;
130
131 /* FIFO content */
132 uint8_t tmst_fsync_en;
134 /* External Sensor(s) */
135 uint8_t es1_en;
136 uint8_t es0_en;
139 fifo_config4_fifo_es0_6b_9b_t es0_6b_9b;
140
141 /* FIFO Compression */
142
144 uint8_t comp_en;
145
147 fifo_config4_fifo_comp_nc_flow_cfg_t comp_nc_flow_cfg;
148
149 /* FIFO Decimation */
150
152 odr_decimate_config_gyro_fifo_odr_dec_t gyro_dec;
153
155 odr_decimate_config_accel_fifo_odr_dec_t accel_dec;
156 } inv_imu_adv_fifo_config_t;
157
158 /*
159 * API definitions
160 */
161
166 int inv_imu_adv_init(inv_imu_device_t *s);
167
172 int inv_imu_adv_device_reset(inv_imu_device_t *s);
173
178 int inv_imu_adv_enable_accel_lp(inv_imu_device_t *s);
179
184 int inv_imu_adv_enable_accel_ln(inv_imu_device_t *s);
185
190 int inv_imu_adv_disable_accel(inv_imu_device_t *s);
191
196 int inv_imu_adv_enable_gyro_ln(inv_imu_device_t *s);
197
202 int inv_imu_adv_enable_gyro_lp(inv_imu_device_t *s);
203
208 int inv_imu_adv_disable_gyro(inv_imu_device_t *s);
209
210 #if INV_IMU_INT2_PIN_SUPPORTED
217 int inv_imu_adv_set_int2_pin_usage(inv_imu_device_t * s,
218 ioc_pad_scenario_ovrd_pads_int2_cfg_ovrd_val_t usage);
219 #endif /* INV_IMU_INT2_PIN_SUPPORTED */
220
221 #if INV_IMU_FSYNC_SUPPORTED
227 int inv_imu_adv_configure_fsync_ap_tag(inv_imu_device_t * s,
228 fsync_config0_ap_fsync_sel_t sensor_tag);
229
240 int inv_imu_adv_enable_fsync(inv_imu_device_t *s);
241
252 int inv_imu_adv_disable_fsync(inv_imu_device_t *s);
253 #endif
254
261 int inv_imu_adv_get_data_from_registers(inv_imu_device_t *s);
262
267 int inv_imu_adv_reset_fifo(inv_imu_device_t *s);
268
274 int inv_imu_adv_get_fifo_config(inv_imu_device_t *s, inv_imu_adv_fifo_config_t *conf);
275
281 int inv_imu_adv_set_fifo_config(inv_imu_device_t *s, const inv_imu_adv_fifo_config_t *conf);
282
289 int inv_imu_adv_get_data_from_fifo(inv_imu_device_t *s, uint8_t fifo_data[FIFO_MIRRORING_SIZE],
290 uint16_t *fifo_count);
291
301 int inv_imu_adv_parse_fifo_data(inv_imu_device_t *s, const uint8_t fifo_data[FIFO_MIRRORING_SIZE],
302 const uint16_t fifo_count);
303
308 uint32_t inv_imu_adv_convert_odr_bitfield_to_us(uint32_t odr_bitfield);
309
315 int inv_imu_adv_get_accel_fsr(inv_imu_device_t *s, accel_config0_accel_ui_fs_sel_t *accel_fsr);
316
322 int inv_imu_adv_get_gyro_fsr(inv_imu_device_t *s, gyro_config0_gyro_ui_fs_sel_t *gyro_fsr);
323
329 int inv_imu_adv_set_timestamp_resolution(inv_imu_device_t * s,
330 const tmst_wom_config_tmst_resol_t timestamp_resol);
331
336 uint32_t inv_imu_adv_get_timestamp_resolution_us(inv_imu_device_t *s);
337
338 #if INV_IMU_CLKIN_SUPPORTED
347 int inv_imu_adv_enable_clkin_rtc(inv_imu_device_t *s);
348
353 int inv_imu_adv_disable_clkin_rtc(inv_imu_device_t *s);
354 #endif /* INV_IMU_CLKIN_SUPPORTED */
355
365 int inv_imu_adv_configure_wom(inv_imu_device_t *s, const uint8_t wom_x_th, const uint8_t wom_y_th,
366 const uint8_t wom_z_th, tmst_wom_config_wom_int_mode_t wom_int,
367 tmst_wom_config_wom_int_dur_t wom_dur);
368
377 int inv_imu_adv_enable_wom(inv_imu_device_t *s);
378
384 int inv_imu_adv_disable_wom(inv_imu_device_t *s);
385
391 int inv_imu_adv_set_endianness(inv_imu_device_t *s, sreg_ctrl_sreg_data_endian_sel_t endianness);
392
397 int inv_imu_adv_power_up_sram(inv_imu_device_t *s);
398
403 int inv_imu_adv_power_down_sram(inv_imu_device_t *s);
404
405 #ifdef __cplusplus
406 }
407 #endif
408
409 #endif /* _INV_IMU_DRIVER_ADVANCED_H_ */
410
inv_imu_driver.h
odr_decimate_config_gyro_fifo_odr_dec_t
odr_decimate_config_gyro_fifo_odr_dec_t
Definition: inv_imu_defs.h:440
fifo_config0_fifo_mode_t
fifo_config0_fifo_mode_t
Definition: inv_imu_defs.h:316
odr_decimate_config_accel_fifo_odr_dec_t
odr_decimate_config_accel_fifo_odr_dec_t
Definition: inv_imu_defs.h:457
fifo_config2_fifo_wr_wm_gt_th_t
fifo_config2_fifo_wr_wm_gt_th_t
Definition: inv_imu_defs.h:338
fsync_config0_ap_fsync_sel_t
fsync_config0_ap_fsync_sel_t
Definition: inv_imu_defs.h:398
fifo_config4_fifo_comp_nc_flow_cfg_t
fifo_config4_fifo_comp_nc_flow_cfg_t
Definition: inv_imu_defs.h:348
fifo_config4_fifo_es0_6b_9b_t
fifo_config4_fifo_es0_6b_9b_t
Definition: inv_imu_defs.h:358
sreg_ctrl_sreg_data_endian_sel_t
sreg_ctrl_sreg_data_endian_sel_t
Definition: inv_imu_defs.h:588
ioc_pad_scenario_ovrd_pads_int2_cfg_ovrd_val_t
ioc_pad_scenario_ovrd_pads_int2_cfg_ovrd_val_t
Definition: inv_imu_defs.h:515
accel_config0_accel_ui_fs_sel_t
accel_config0_accel_ui_fs_sel_t
Definition: inv_imu_defs.h:248
tmst_wom_config_wom_int_dur_t
tmst_wom_config_wom_int_dur_t
Definition: inv_imu_defs.h:386
tmst_wom_config_wom_int_mode_t
tmst_wom_config_wom_int_mode_t
Definition: inv_imu_defs.h:380
tmst_wom_config_tmst_resol_t
tmst_wom_config_tmst_resol_t
Definition: inv_imu_defs.h:368
gyro_config0_gyro_ui_fs_sel_t
gyro_config0_gyro_ui_fs_sel_t
Definition: inv_imu_defs.h:280
inv_imu_sensor_id_t
inv_imu_sensor_id_t
Sensor identifier enumeration.
Definition: inv_imu_driver_advanced.h:103
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).
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.
inv_imu_adv_power_down_sram
int inv_imu_adv_power_down_sram(inv_imu_device_t *s)
Power-down the SRAM.
inv_imu_adv_device_reset
int inv_imu_adv_device_reset(inv_imu_device_t *s)
Performs a soft reset of the device.
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.
inv_imu_adv_disable_wom
int inv_imu_adv_disable_wom(inv_imu_device_t *s)
Disable Wake On Motion.
inv_imu_adv_enable_wom
int inv_imu_adv_enable_wom(inv_imu_device_t *s)
Enable Wake On Motion.
inv_imu_adv_enable_accel_ln
int inv_imu_adv_enable_accel_ln(inv_imu_device_t *s)
Enable accel in low noise mode.
inv_imu_adv_power_up_sram
int inv_imu_adv_power_up_sram(inv_imu_device_t *s)
Power-up the SRAM.
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.
inv_imu_adv_enable_gyro_ln
int inv_imu_adv_enable_gyro_ln(inv_imu_device_t *s)
Enable gyro in low noise mode.
inv_imu_adv_reset_fifo
int inv_imu_adv_reset_fifo(inv_imu_device_t *s)
reset IMU fifo
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.
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.
inv_imu_adv_disable_accel
int inv_imu_adv_disable_accel(inv_imu_device_t *s)
Disable accel.
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.
inv_imu_adv_enable_accel_lp
int inv_imu_adv_enable_accel_lp(inv_imu_device_t *s)
Enable accel in low power mode.
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.
inv_imu_adv_init
int inv_imu_adv_init(inv_imu_device_t *s)
Initializes device.
inv_imu_adv_get_timestamp_resolution_us
uint32_t inv_imu_adv_get_timestamp_resolution_us(inv_imu_device_t *s)
Get timestamp resolution.
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.
FIFO_MIRRORING_SIZE
#define FIFO_MIRRORING_SIZE
Maximum buffer size mirrored from FIFO.
Definition: inv_imu_driver_advanced.h:38
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.
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.
inv_imu_adv_disable_gyro
int inv_imu_adv_disable_gyro(inv_imu_device_t *s)
Disable gyro.
inv_imu_adv_enable_gyro_lp
int inv_imu_adv_enable_gyro_lp(inv_imu_device_t *s)
Enable gyro in low power mode.
INV_SENSOR_EDMP_SMD
@ INV_SENSOR_EDMP_SMD
Definition: inv_imu_driver_advanced.h:114
INV_SENSOR_EDMP_R2W_SLEEP
@ INV_SENSOR_EDMP_R2W_SLEEP
Definition: inv_imu_driver_advanced.h:117
INV_SENSOR_ACCEL
@ INV_SENSOR_ACCEL
Definition: inv_imu_driver_advanced.h:104
INV_SENSOR_EDMP_LOWG
@ INV_SENSOR_EDMP_LOWG
Definition: inv_imu_driver_advanced.h:112
INV_SENSOR_TEMPERATURE
@ INV_SENSOR_TEMPERATURE
Definition: inv_imu_driver_advanced.h:107
INV_SENSOR_FSYNC_EVENT
@ INV_SENSOR_FSYNC_EVENT
Definition: inv_imu_driver_advanced.h:106
INV_SENSOR_EDMP_FF
@ INV_SENSOR_EDMP_FF
Definition: inv_imu_driver_advanced.h:111
INV_SENSOR_EDMP_HIGHG
@ INV_SENSOR_EDMP_HIGHG
Definition: inv_imu_driver_advanced.h:113
INV_SENSOR_EDMP_TILT
@ INV_SENSOR_EDMP_TILT
Definition: inv_imu_driver_advanced.h:110
INV_SENSOR_EDMP_PEDOMETER_COUNT
@ INV_SENSOR_EDMP_PEDOMETER_COUNT
Definition: inv_imu_driver_advanced.h:109
INV_SENSOR_EDMP_PEDOMETER_EVENT
@ INV_SENSOR_EDMP_PEDOMETER_EVENT
Definition: inv_imu_driver_advanced.h:108
INV_SENSOR_ES0
@ INV_SENSOR_ES0
Definition: inv_imu_driver_advanced.h:118
INV_SENSOR_ES1
@ INV_SENSOR_ES1
Definition: inv_imu_driver_advanced.h:119
INV_SENSOR_GYRO
@ INV_SENSOR_GYRO
Definition: inv_imu_driver_advanced.h:105
INV_SENSOR_MAX
@ INV_SENSOR_MAX
Definition: inv_imu_driver_advanced.h:120
INV_SENSOR_EDMP_TAP
@ INV_SENSOR_EDMP_TAP
Definition: inv_imu_driver_advanced.h:115
INV_SENSOR_EDMP_R2W_WAKE
@ INV_SENSOR_EDMP_R2W_WAKE
Definition: inv_imu_driver_advanced.h:116
inv_imu_device_t
Basic driver configuration structure.
Definition: inv_imu_driver.h:43
inv_imu_fifo_config_t
Basic FIFO configuration.
Definition: inv_imu_driver.h:111
inv_imu_sensor_event_t
Sensor event structure definition.
Definition: inv_imu_driver_advanced.h:45
inv_imu_sensor_event_t::temperature
int16_t temperature
Temperature raw data.
Definition: inv_imu_driver_advanced.h:61
inv_imu_sensor_event_t::sensor_mask
int sensor_mask
Specifies which sensors are available in the event (defined by inv_imu_sensor_id_t as a mask)
Definition: inv_imu_driver_advanced.h:49
inv_imu_sensor_event_t::timestamp_fsync
uint16_t timestamp_fsync
Value of the FIFO timestamp (if FIFO is used)
Definition: inv_imu_driver_advanced.h:52
inv_imu_adv_var_t
Definition of extended variables.
Definition: inv_imu_driver_advanced.h:77
inv_imu_adv_var_t::fifo_mode
fifo_config0_fifo_mode_t fifo_mode
Current fifo mode.
Definition: inv_imu_driver_advanced.h:86
inv_imu_adv_var_t::temp_baseline
int16_t temp_baseline
Baseline for the temperature sensor.
Definition: inv_imu_driver_advanced.h:91
inv_imu_adv_var_t::temp_baseline_found
uint8_t temp_baseline_found
Flag indicating temperature baseline has been found.
Definition: inv_imu_driver_advanced.h:94
inv_imu_adv_var_t::fifo_is_used
uint8_t fifo_is_used
Keeps track of FIFO usage.
Definition: inv_imu_driver_advanced.h:84
inv_imu_adv_var_t::gyro_baseline_found
uint8_t gyro_baseline_found
Flag indicating gyro baseline has been found.
Definition: inv_imu_driver_advanced.h:93
inv_imu_adv_var_t::accel_baseline_found
uint8_t accel_baseline_found
Flag indicating accel baseline has been found.
Definition: inv_imu_driver_advanced.h:92
inv_imu_adv_var_t::fifo_comp_en
uint8_t fifo_comp_en
Indicates if FIFO compression is enabled.
Definition: inv_imu_driver_advanced.h:85
inv_imu_adv_fifo_config_t
FIFO configuration structure.
Definition: inv_imu_driver_advanced.h:124
inv_imu_adv_fifo_config_t::base_conf
inv_imu_fifo_config_t base_conf
Basic FIFO configuration.
Definition: inv_imu_driver_advanced.h:126
inv_imu_adv_fifo_config_t::gyro_dec
odr_decimate_config_gyro_fifo_odr_dec_t gyro_dec
Decimation rate for gyro.
Definition: inv_imu_driver_advanced.h:152
inv_imu_adv_fifo_config_t::es1_en
uint8_t es1_en
Enable External Sensor 1 to be pushed in FIFO.
Definition: inv_imu_driver_advanced.h:135
inv_imu_adv_fifo_config_t::comp_en
uint8_t comp_en
Enable FIFO compression.
Definition: inv_imu_driver_advanced.h:144
inv_imu_adv_fifo_config_t::es0_6b_9b
fifo_config4_fifo_es0_6b_9b_t es0_6b_9b
Size of the External Sensor 0 data (6 bytes or 9 bytes)
Definition: inv_imu_driver_advanced.h:139
inv_imu_adv_fifo_config_t::fifo_wr_wm_gt_th
fifo_config2_fifo_wr_wm_gt_th_t fifo_wr_wm_gt_th
Condition to trig watermark interrupt.
Definition: inv_imu_driver_advanced.h:129
inv_imu_adv_fifo_config_t::accel_dec
odr_decimate_config_accel_fifo_odr_dec_t accel_dec
Decimation rate for accel.
Definition: inv_imu_driver_advanced.h:155
inv_imu_adv_fifo_config_t::tmst_fsync_en
uint8_t tmst_fsync_en
Enable Timestamp or FSYNC delay in FIFO.
Definition: inv_imu_driver_advanced.h:132
inv_imu_adv_fifo_config_t::es0_en
uint8_t es0_en
Enable External Sensor 0 to be pushed in FIFO.
Definition: inv_imu_driver_advanced.h:136
inv_imu_adv_fifo_config_t::comp_nc_flow_cfg
fifo_config4_fifo_comp_nc_flow_cfg_t comp_nc_flow_cfg
Rate at which an uncompressed frame is generated.
Definition: inv_imu_driver_advanced.h:147