| ICM40609D eMD Driver 2.0.0 Documentation of the eMD Driver API

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

Icm406xxDriver_HL.h
Go to the documentation of this file.
1 /*
2 * ________________________________________________________________________________________________________
3 * Copyright (c) 2017 InvenSense Inc. All rights reserved.
4 *
5 * This software, related documentation and any modifications thereto (collectively “Software”) is subject
6 * to InvenSense and its licensors' intellectual property rights under U.S. and international copyright
7 * and other intellectual property rights laws.
8 *
9 * InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
10 * and any use, reproduction, disclosure or distribution of the Software without an express license agreement
11 * from InvenSense is strictly prohibited.
12 *
13 * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE SOFTWARE IS
14 * PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15 * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
16 * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
17 * INVENSENSE BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
18 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
19 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THE SOFTWARE.
21 * ________________________________________________________________________________________________________
22 */
23
34 #ifndef _INV_ICM406xx_DRIVER_HL_H_
35 #define _INV_ICM406xx_DRIVER_HL_H_
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 #include "Icm406xxDefs.h"
42 #include "Icm406xxTransport.h"
43
44 #include "Invn/InvError.h"
45
46 #include <stdint.h>
47 #include <string.h>
48
52 #define ICM406XX_FIFO_MIRRORING_SIZE 1041 // packet size * max_count + 1 = 16 * 65 + 1
53
56 enum inv_icm406xx_sensor {
57 INV_ICM406XX_SENSOR_ACCEL,
58 INV_ICM406XX_SENSOR_GYRO,
59 INV_ICM406XX_SENSOR_FSYNC_EVENT,
60 INV_ICM406XX_SENSOR_OIS,
61 INV_ICM406XX_SENSOR_TEMPERATURE,
64 INV_ICM406XX_SENSOR_MAX
65 };
66
69 typedef struct {
70 int sensor_mask;
71 uint16_t timestamp_fsync;
72 int16_t accel[3];
73 int16_t gyro[3];
74 int16_t temperature;
75 } inv_icm406xx_sensor_event_t;
76
79 struct inv_icm406xx {
80 struct inv_icm406xx_serif serif;
83 void (*sensor_event_cb)(
84 inv_icm406xx_sensor_event_t
85 *event);
90 int gyro_ois_st_bias[3];
91 int accel_ois_st_bias[3];
92 int gyro_lp_st_bias[3];
93 int accel_lp_st_bias[3];
94 int gyro_st_bias[3];
95 int accel_st_bias[3];
96
97 uint8_t fifo_data[ICM406XX_FIFO_MIRRORING_SIZE];
99 uint8_t
100 tmst_to_reg_en_cnt;
101 uint32_t gyro_start_time_us;
102 uint8_t endianess_data;
103 uint8_t is_wom_enabled;
104 uint64_t
105 gyro_power_off_tmst;
106 };
107
145 int inv_icm406xx_init(struct inv_icm406xx *s, struct inv_icm406xx_serif *serif,
146 void (*sensor_event_cb)(inv_icm406xx_sensor_event_t *event));
147
151 int inv_icm406xx_device_reset(struct inv_icm406xx *s);
152
157 int inv_icm406xx_get_who_am_i(struct inv_icm406xx *s, uint8_t *who_am_i);
158
168 int inv_icm406xx_enable_accel_low_power_mode(struct inv_icm406xx *s);
169
179 int inv_icm406xx_enable_accel_low_noise_mode(struct inv_icm406xx *s);
180
189 int inv_icm406xx_disable_accel(struct inv_icm406xx *s);
190
200 int inv_icm406xx_enable_gyro_low_noise_mode(struct inv_icm406xx *s);
201
210 int inv_icm406xx_disable_gyro(struct inv_icm406xx *s);
211
221 int inv_icm406xx_enable_fsync(struct inv_icm406xx *s);
222
232 int inv_icm406xx_disable_fsync(struct inv_icm406xx *s);
233
240 int inv_icm406xx_configure_wom(struct inv_icm406xx *s, const uint8_t wom_x_th,
241 const uint8_t wom_y_th, const uint8_t wom_z_th);
242
250 int inv_icm406xx_enable_wom(struct inv_icm406xx *s);
251
256 int inv_icm406xx_disable_wom(struct inv_icm406xx *s);
257
264 int inv_icm406xx_get_data_from_fifo(struct inv_icm406xx *s);
265
270 int inv_icm406xx_set_accel_frequency(struct inv_icm406xx * s,
271 const ICM406XX_ACCEL_CONFIG0_ODR_t frequency);
272
277 int inv_icm406xx_set_gyro_frequency(struct inv_icm406xx * s,
278 const ICM406XX_GYRO_CONFIG0_ODR_t frequency);
279
284 int inv_icm406xx_set_accel_fsr(struct inv_icm406xx *s, ICM406XX_ACCEL_CONFIG0_FS_SEL_t accel_fsr_g);
285
290 int inv_icm406xx_set_gyro_fsr(struct inv_icm406xx *s, ICM406XX_GYRO_CONFIG0_FS_SEL_t gyro_fsr_dps);
291
295 int inv_icm406xx_reset_fifo(struct inv_icm406xx *s);
296
300 int inv_icm406xx_enable_timestamp_to_register(struct inv_icm406xx *s);
301
305 int inv_icm406xx_disable_timestamp_to_register(struct inv_icm406xx *s);
306
312 int inv_icm406xx_get_current_timestamp(struct inv_icm406xx *s, uint32_t *icm_time);
313
314 #ifdef __cplusplus
315 }
316 #endif
317
318 #endif /* _INV_ICM406xx_DRIVER_HL_H_ */
319
Icm406xxDefs.h
File exposing the device register map.
ICM406XX_GYRO_CONFIG0_ODR_t
ICM406XX_GYRO_CONFIG0_ODR_t
Gyroscope ODR selection.
Definition: Icm406xxDefs.h:582
ICM406XX_ACCEL_CONFIG0_FS_SEL_t
ICM406XX_ACCEL_CONFIG0_FS_SEL_t
Accelerometer FSR selection.
Definition: Icm406xxDefs.h:625
ICM406XX_ACCEL_CONFIG0_ODR_t
ICM406XX_ACCEL_CONFIG0_ODR_t
Accelerometer ODR selection.
Definition: Icm406xxDefs.h:664
ICM406XX_GYRO_CONFIG0_FS_SEL_t
ICM406XX_GYRO_CONFIG0_FS_SEL_t
Gyroscope FSR selection.
Definition: Icm406xxDefs.h:560
Icm406xxTransport.h
Low-level Icm406xx register access.
inv_icm406xx_set_accel_frequency
int inv_icm406xx_set_accel_frequency(struct inv_icm406xx *s, const ICM406XX_ACCEL_CONFIG0_ODR_t frequency)
Configure accel Output Data Rate.
Definition: Icm406xxDriver_HL.c:547
inv_icm406xx_disable_timestamp_to_register
int inv_icm406xx_disable_timestamp_to_register(struct inv_icm406xx *s)
Disable the 20bits-timestamp register access.
Definition: Icm406xxDriver_HL.c:644
inv_icm406xx_set_gyro_frequency
int inv_icm406xx_set_gyro_frequency(struct inv_icm406xx *s, const ICM406XX_GYRO_CONFIG0_ODR_t frequency)
Configure gyro Output Data Rate.
Definition: Icm406xxDriver_HL.c:553
inv_icm406xx_enable_gyro_low_noise_mode
int inv_icm406xx_enable_gyro_low_noise_mode(struct inv_icm406xx *s)
Put gyro in low noise mode.
Definition: Icm406xxDriver_HL.c:205
inv_icm406xx_device_reset
int inv_icm406xx_device_reset(struct inv_icm406xx *s)
Perform a soft reset of the device.
Definition: Icm406xxDriver_HL.c:63
inv_icm406xx_disable_fsync
int inv_icm406xx_disable_fsync(struct inv_icm406xx *s)
Disable fsync tagging functionnality.
Definition: Icm406xxDriver_HL.c:314
inv_icm406xx_enable_accel_low_noise_mode
int inv_icm406xx_enable_accel_low_noise_mode(struct inv_icm406xx *s)
Put accel in low noise mode.
Definition: Icm406xxDriver_HL.c:141
inv_icm406xx_get_current_timestamp
int inv_icm406xx_get_current_timestamp(struct inv_icm406xx *s, uint32_t *icm_time)
Get the timestamp value of icm406xx from register.
Definition: Icm406xxDriver_HL.c:659
inv_icm406xx_enable_wom
int inv_icm406xx_enable_wom(struct inv_icm406xx *s)
Enable Wake On Motion.
Definition: Icm406xxDriver_HL.c:338
ICM406XX_FIFO_MIRRORING_SIZE
#define ICM406XX_FIFO_MIRRORING_SIZE
Icm406xx maximum buffer size mirrored from FIFO at polling time.
Definition: Icm406xxDriver_HL.h:52
inv_icm406xx_set_gyro_fsr
int inv_icm406xx_set_gyro_fsr(struct inv_icm406xx *s, ICM406XX_GYRO_CONFIG0_FS_SEL_t gyro_fsr_dps)
Set gyro full scale range.
Definition: Icm406xxDriver_HL.c:564
inv_icm406xx_reset_fifo
int inv_icm406xx_reset_fifo(struct inv_icm406xx *s)
reset ICM406XX fifo
Definition: Icm406xxDriver_HL.c:569
inv_icm406xx_disable_wom
int inv_icm406xx_disable_wom(struct inv_icm406xx *s)
Disable Wake On Motion.
Definition: Icm406xxDriver_HL.c:368
inv_icm406xx_sensor
inv_icm406xx_sensor
Sensor identifier for UI control and OIS function.
Definition: Icm406xxDriver_HL.h:56
inv_icm406xx_enable_accel_low_power_mode
int inv_icm406xx_enable_accel_low_power_mode(struct inv_icm406xx *s)
Put accel in low power mode.
Definition: Icm406xxDriver_HL.c:115
inv_icm406xx_disable_gyro
int inv_icm406xx_disable_gyro(struct inv_icm406xx *s)
Disable all 3 axes of gyro.
Definition: Icm406xxDriver_HL.c:262
inv_icm406xx_enable_timestamp_to_register
int inv_icm406xx_enable_timestamp_to_register(struct inv_icm406xx *s)
Enable the 20bits-timestamp register access to read in a reliable way the strobed timestamp.
Definition: Icm406xxDriver_HL.c:626
inv_icm406xx_set_accel_fsr
int inv_icm406xx_set_accel_fsr(struct inv_icm406xx *s, ICM406XX_ACCEL_CONFIG0_FS_SEL_t accel_fsr_g)
Set accel full scale range.
Definition: Icm406xxDriver_HL.c:559
inv_icm406xx_disable_accel
int inv_icm406xx_disable_accel(struct inv_icm406xx *s)
Disable all 3 axes of accel.
Definition: Icm406xxDriver_HL.c:167
inv_icm406xx_enable_fsync
int inv_icm406xx_enable_fsync(struct inv_icm406xx *s)
Enable fsync tagging functionnality.
Definition: Icm406xxDriver_HL.c:303
inv_icm406xx_get_who_am_i
int inv_icm406xx_get_who_am_i(struct inv_icm406xx *s, uint8_t *who_am_i)
return WHOAMI value
Definition: Icm406xxDriver_HL.c:110
inv_icm406xx_get_data_from_fifo
int inv_icm406xx_get_data_from_fifo(struct inv_icm406xx *s)
Read all available packets from the FIFO.
Definition: Icm406xxDriver_HL.c:391
inv_icm406xx_init
int inv_icm406xx_init(struct inv_icm406xx *s, struct inv_icm406xx_serif *serif, void(*sensor_event_cb)(inv_icm406xx_sensor_event_t *event))
Configure the serial interface used to access the device and execute hardware initialization.
Definition: Icm406xxDriver_HL.c:31
inv_icm406xx_configure_wom
int inv_icm406xx_configure_wom(struct inv_icm406xx *s, const uint8_t wom_x_th, const uint8_t wom_y_th, const uint8_t wom_z_th)
Enable Wake On Motion.
Definition: Icm406xxDriver_HL.c:325
INV_ICM406XX_SENSOR_TEMPERATURE
@ INV_ICM406XX_SENSOR_TEMPERATURE
Chip temperature, enabled by default.
Definition: Icm406xxDriver_HL.h:61
INV_ICM406XX_SENSOR_OIS
@ INV_ICM406XX_SENSOR_OIS
Only used by OIS layer.
Definition: Icm406xxDriver_HL.h:60
INV_ICM406XX_SENSOR_GYRO
@ INV_ICM406XX_SENSOR_GYRO
Gyroscope (UI control path)
Definition: Icm406xxDriver_HL.h:58
INV_ICM406XX_SENSOR_ACCEL
@ INV_ICM406XX_SENSOR_ACCEL
Accelerometer (UI control path)
Definition: Icm406xxDriver_HL.h:57
INV_ICM406XX_SENSOR_FSYNC_EVENT
@ INV_ICM406XX_SENSOR_FSYNC_EVENT
Used by OIS and UI control layers.
Definition: Icm406xxDriver_HL.h:59
inv_icm406xx_sensor_event_t
Sensor event structure definition.
Definition: Icm406xxDriver_HL.h:69
inv_icm406xx
Icm406xx driver states definition.
Definition: Icm406xxDriver_HL.h:79
inv_icm406xx::tmst_to_reg_en_cnt
uint8_t tmst_to_reg_en_cnt
FIFO mirroring memory area
Definition: Icm406xxDriver_HL.h:100
inv_icm406xx::gyro_start_time_us
uint32_t gyro_start_time_us
internal counter to keep track of the timestamp to register access availability
Definition: Icm406xxDriver_HL.h:101
inv_icm406xx::accel_ois_st_bias
int accel_ois_st_bias[3]
collected bias values (lsb) during self test
Definition: Icm406xxDriver_HL.h:91
inv_icm406xx::endianess_data
uint8_t endianess_data
internal state needed for Workaround HW Bug 9863
Definition: Icm406xxDriver_HL.h:102
inv_icm406xx::sensor_event_cb
void(* sensor_event_cb)(inv_icm406xx_sensor_event_t *event)
Warning : this field MUST be the first one of struct icm406xx
Definition: Icm406xxDriver_HL.h:83
inv_icm406xx::gyro_power_off_tmst
uint64_t gyro_power_off_tmst
internal status of wom
Definition: Icm406xxDriver_HL.h:105
inv_icm406xx::gyro_ois_st_bias
int gyro_ois_st_bias[3]
callback executed by inv_icm406xx_get_data_from_fifo function for each data packet extracted from fif...
Definition: Icm406xxDriver_HL.h:90
inv_icm406xx::is_wom_enabled
uint8_t is_wom_enabled
internal status of data endianess mode to poll correctly datas
Definition: Icm406xxDriver_HL.h:103
inv_icm406xx_serif
basesensor serial interface
Definition: Icm406xxTransport.h:58