c6dofimu18 2.1.0.0
c6dofimu18.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef C6DOFIMU18_H
29#define C6DOFIMU18_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
53#include "spi_specifics.h"
54
80#define C6DOFIMU18_REG_DEVICE_CONFIG 0x11
81#define C6DOFIMU18_REG_DRIVE_CONFIG 0x13
82#define C6DOFIMU18_REG_INT_CONFIG 0x14
83#define C6DOFIMU18_REG_FIFO_CONFIG 0x16
84#define C6DOFIMU18_REG_TEMP_DATA1 0x1D
85#define C6DOFIMU18_REG_TEMP_DATA0 0x1E
86#define C6DOFIMU18_REG_ACCEL_DATA_X1 0x1F
87#define C6DOFIMU18_REG_ACCEL_DATA_X0 0x20
88#define C6DOFIMU18_REG_ACCEL_DATA_Y1 0x21
89#define C6DOFIMU18_REG_ACCEL_DATA_Y0 0x22
90#define C6DOFIMU18_REG_ACCEL_DATA_Z1 0x23
91#define C6DOFIMU18_REG_ACCEL_DATA_Z0 0x24
92#define C6DOFIMU18_REG_GYRO_DATA_X1 0x25
93#define C6DOFIMU18_REG_GYRO_DATA_X0 0x26
94#define C6DOFIMU18_REG_GYRO_DATA_Y1 0x27
95#define C6DOFIMU18_REG_GYRO_DATA_Y0 0x28
96#define C6DOFIMU18_REG_GYRO_DATA_Z1 0x29
97#define C6DOFIMU18_REG_GYRO_DATA_Z0 0x2A
98#define C6DOFIMU18_REG_TMST_FSYNCH 0x2B
99#define C6DOFIMU18_REG_TMST_FSYNCL 0x2C
100#define C6DOFIMU18_REG_INT_STATUS 0x2D
101#define C6DOFIMU18_REG_FIFO_COUNTH 0x2E
102#define C6DOFIMU18_REG_FIFO_COUNTL 0x2F
103#define C6DOFIMU18_REG_FIFO_DATA 0x30
104#define C6DOFIMU18_REG_APEX_DATA0 0x31
105#define C6DOFIMU18_REG_APEX_DATA1 0x32
106#define C6DOFIMU18_REG_APEX_DATA2 0x33
107#define C6DOFIMU18_REG_APEX_DATA3 0x34
108#define C6DOFIMU18_REG_APEX_DATA4 0x35
109#define C6DOFIMU18_REG_APEX_DATA5 0x36
110#define C6DOFIMU18_REG_INT_STATUS2 0x37
111#define C6DOFIMU18_REG_INT_STATUS3 0x38
112#define C6DOFIMU18_REG_SIGNAL_PATH_RESET 0x4B
113#define C6DOFIMU18_REG_INTF_CONFIG0 0x4C
114#define C6DOFIMU18_REG_INTF_CONFIG1 0x4D
115#define C6DOFIMU18_REG_PWR_MGMT0 0x4E
116#define C6DOFIMU18_REG_GYRO_CONFIG0 0x4F
117#define C6DOFIMU18_REG_ACCEL_CONFIG0 0x50
118#define C6DOFIMU18_REG_GYRO_CONFIG1 0x51
119#define C6DOFIMU18_REG_GYRO_ACCEL_CONFIG0 0x52
120#define C6DOFIMU18_REG_ACCEL_CONFIG1 0x53
121#define C6DOFIMU18_REG_TMST_CONFIG 0x54
122#define C6DOFIMU18_REG_APEX_CONFIG0 0x56
123#define C6DOFIMU18_REG_SMD_CONFIG 0x57
124#define C6DOFIMU18_REG_FIFO_CONFIG1 0x5F
125#define C6DOFIMU18_REG_FIFO_CONFIG2 0x60
126#define C6DOFIMU18_REG_FIFO_CONFIG3 0x61
127#define C6DOFIMU18_REG_FSYNC_CONFIG 0x62
128#define C6DOFIMU18_REG_INT_CONFIG0 0x63
129#define C6DOFIMU18_REG_INT_CONFIG1 0x64
130#define C6DOFIMU18_REG_INT_SOURCE0 0x65
131#define C6DOFIMU18_REG_INT_SOURCE1 0x66
132#define C6DOFIMU18_REG_INT_SOURCE3 0x68
133#define C6DOFIMU18_REG_INT_SOURCE4 0x69
134#define C6DOFIMU18_REG_FIFO_LOST_PKT0 0x6C
135#define C6DOFIMU18_REG_FIFO_LOST_PKT1 0x6D
136#define C6DOFIMU18_REG_SELF_TEST_CONFIG 0x70
137#define C6DOFIMU18_REG_WHO_AM_I 0x75
138#define C6DOFIMU18_REG_BANK_SEL 0x76
139
144#define C6DOFIMU18_REG_SENSOR_CONFIG0 0x03
145#define C6DOFIMU18_REG_GYRO_CONFIG_STATIC2 0x0B
146#define C6DOFIMU18_REG_GYRO_CONFIG_STATIC3 0x0C
147#define C6DOFIMU18_REG_GYRO_CONFIG_STATIC4 0x0D
148#define C6DOFIMU18_REG_GYRO_CONFIG_STATIC5 0x0E
149#define C6DOFIMU18_REG_GYRO_CONFIG_STATIC6 0x0F
150#define C6DOFIMU18_REG_GYRO_CONFIG_STATIC7 0x10
151#define C6DOFIMU18_REG_GYRO_CONFIG_STATIC8 0x11
152#define C6DOFIMU18_REG_GYRO_CONFIG_STATIC9 0x12
153#define C6DOFIMU18_REG_GYRO_CONFIG_STATIC10 0x13
154#define C6DOFIMU18_REG_XG_ST_DATA 0x5F
155#define C6DOFIMU18_REG_YG_ST_DATA 0x60
156#define C6DOFIMU18_REG_ZG_ST_DATA 0x61
157#define C6DOFIMU18_REG_TMSTVAL0 0x62
158#define C6DOFIMU18_REG_TMSTVAL1 0x63
159#define C6DOFIMU18_REG_TMSTVAL2 0x64
160#define C6DOFIMU18_REG_INTF_CONFIG4 0x7A
161#define C6DOFIMU18_REG_INTF_CONFIG5 0x7B
162#define C6DOFIMU18_REG_INTF_CONFIG6 0x7C
163
168#define C6DOFIMU18_REG_ACCEL_CONFIG_STATIC2 0x03
169#define C6DOFIMU18_REG_ACCEL_CONFIG_STATIC3 0x04
170#define C6DOFIMU18_REG_ACCEL_CONFIG_STATIC4 0x05
171#define C6DOFIMU18_REG_XA_ST_DATA 0x3B
172#define C6DOFIMU18_REG_YA_ST_DATA 0x3C
173#define C6DOFIMU18_REG_ZA_ST_DATA 0x3D
174
179#define C6DOFIMU18_REG_APEX_CONFIG1 0x40
180#define C6DOFIMU18_REG_APEX_CONFIG2 0x41
181#define C6DOFIMU18_REG_APEX_CONFIG3 0x42
182#define C6DOFIMU18_REG_APEX_CONFIG4 0x43
183#define C6DOFIMU18_REG_APEX_CONFIG5 0x44
184#define C6DOFIMU18_REG_APEX_CONFIG6 0x45
185#define C6DOFIMU18_REG_APEX_CONFIG7 0x46
186#define C6DOFIMU18_REG_APEX_CONFIG8 0x47
187#define C6DOFIMU18_REG_APEX_CONFIG9 0x48
188#define C6DOFIMU18_REG_ACCEL_WOM_X_THR 0x4A
189#define C6DOFIMU18_REG_ACCEL_WOM_Y_THR 0x4B
190#define C6DOFIMU18_REG_ACCEL_WOM_Z_THR 0x4C
191#define C6DOFIMU18_REG_INT_SOURCE6 0x4D
192#define C6DOFIMU18_REG_INT_SOURCE7 0x4E
193#define C6DOFIMU18_REG_INT_SOURCE8 0x4F
194#define C6DOFIMU18_REG_INT_SOURCE9 0x50
195#define C6DOFIMU18_REG_INT_SOURCE10 0x51
196#define C6DOFIMU18_REG_OFFSET_USER0 0x77
197#define C6DOFIMU18_REG_OFFSET_USER1 0x78
198#define C6DOFIMU18_REG_OFFSET_USER2 0x79
199#define C6DOFIMU18_REG_OFFSET_USER3 0x7A
200#define C6DOFIMU18_REG_OFFSET_USER4 0x7B
201#define C6DOFIMU18_REG_OFFSET_USER5 0x7C
202#define C6DOFIMU18_REG_OFFSET_USER6 0x7D
203#define C6DOFIMU18_REG_OFFSET_USER7 0x7E
204#define C6DOFIMU18_REG_OFFSET_USER8 0x7F
205
206 // c6dofimu18_reg
207
223#define C6DOFIMU18_BANK0_SEL 0x00
224#define C6DOFIMU18_BANK1_SEL 0x01
225#define C6DOFIMU18_BANK2_SEL 0x02
226#define C6DOFIMU18_BANK3_SEL 0x03
227#define C6DOFIMU18_BANK4_SEL 0x04
228
233#define C6DOFIMU18_SLEW_RATE_60nS 0x00
234#define C6DOFIMU18_SLEW_RATE_36nS 0x01
235#define C6DOFIMU18_SLEW_RATE_18nS 0x02
236#define C6DOFIMU18_SLEW_RATE_12nS 0x03
237#define C6DOFIMU18_SLEW_RATE_6nS 0x04
238#define C6DOFIMU18_SLEW_RATE_2nS 0x05
239
244#define C6DOFIMU18_SPI_MODE0_MODE3 0x00
245#define C6DOFIMU18_SPI_MODE1_MODE2 0x01
246
247#define C6DOFIMU18_ENABLE_SW_RESET 0x01
248
253#define C6DOFIMU18_DMP_IDEL_FLAG 0x04
254#define C6DOFIMU18_ACTIVITY_UNKNOWN 0x00
255#define C6DOFIMU18_ACTIVITY_WALK 0x01
256#define C6DOFIMU18_ACTIVITY_RUN 0x02
257#define C6DOFIMU18_ACTIVITY_MASK 0x03
258
259#define C6DOFIMU18_TAP_NUM_MASK 0x18
260#define C6DOFIMU18_TAP_SINGLE 0x08
261#define C6DOFIMU18_TAP_DOUBLE 0x10
262#define C6DOFIMU18_TAP_AXIS_MASK 0x06
263#define C6DOFIMU18_TAP_AXIS_X 0x00
264#define C6DOFIMU18_TAP_AXIS_Y 0x02
265#define C6DOFIMU18_TAP_AXIS_Z 0x04
266#define C6DOFIMU18_TAP_DIR_MASK 0x01
267#define C6DOFIMU18_TAP_DIR_POSITIVE 0x00
268#define C6DOFIMU18_TAP_DIR_NEGATIVE 0x01
269
274#define C6DOFIMU18_INT_INT2_MODE_PULSED 0x00
275#define C6DOFIMU18_INT_INT2_MODE_LATCHED 0x20
276#define C6DOFIMU18_INT_INT2_OPEN_DRAIN 0x00
277#define C6DOFIMU18_INT_INT2_PUSH_PULL 0x10
278#define C6DOFIMU18_INT_INT2_ACTIVE_LOW 0x00
279#define C6DOFIMU18_INT_INT2_ACTIVE_HIGH 0x08
280#define C6DOFIMU18_INT_INT1_MODE_PULSED 0x00
281#define C6DOFIMU18_INT_INT1_MODE_LATCHED 0x04
282#define C6DOFIMU18_INT_INT1_OPEN_DRAIN 0x00
283#define C6DOFIMU18_INT_INT1_PUSH_PULL 0x02
284#define C6DOFIMU18_INT_INT1_ACTIVE_LOW 0x00
285#define C6DOFIMU18_INT_INT1_ACTIVE_HIGH 0x01
286#define C6DOFIMU18_INT_CONFIG_MASK 0x3F
287
292#define C6DOFIMU18_DRDY_INT_CLR_ON_STATUS_READ 0x00
293#define C6DOFIMU18_DRDY_INT_CLR_FIFO_READ 0x20
294#define C6DOFIMU18_DRDY_INT_CLR_STATUS_AND_REG 0x30
295#define C6DOFIMU18_FIFO_INT_CLR_ON_STATUS_READ 0x00
296#define C6DOFIMU18_FIFO_INT_CLR_FIFO_READ 0x80
297#define C6DOFIMU18_FIFO_INT_CLR_STATUS_AND_REG 0xc0
298#define C6DOFIMU18_FIFO_FULL_CLR_ON_STATUS_READ 0x00
299#define C6DOFIMU18_FIFO_FULL_CLR_FIFO_READ 0x02
300#define C6DOFIMU18_FIFO_FULL_CLR_STATUS_AND_REG 0x03
301
306#define C6DOFIMU18_INT_TPULSE_100uS 0x00
307#define C6DOFIMU18_INT_TPULSE_8uS 0x40
308#define C6DOFIMU18_INT_TDEASSERT_DISABLE 0x20
309#define C6DOFIMU18_INT_ASYNC_RESET_DISABLE 0x10
310#define C6DOFIMU18_INT_ASYNC_RESET_ENABLE 0x00
311#define C6DOFIMU18_INT_CONFIG1_MASK 0x70
312
317#define C6DOFIMU18_INT_UI_FSYNC_INT1_EN 0x40
318#define C6DOFIMU18_INT_PLL_RDY_INT1_EN 0x20
319#define C6DOFIMU18_INT_RESET_DONE_INT1_EN 0x10
320#define C6DOFIMU18_INT_UI_DRDY_INT1_EN 0x08
321#define C6DOFIMU18_INT_FIFO_THS_INT1_EN 0x04
322#define C6DOFIMU18_INT_FIFO_FULL_INT1_EN 0x02
323#define C6DOFIMU18_INT_UI_AGC_RDY_INT1_EN 0x01
324#define C6DOFIMU18_INT_SOURCE0_MASK 0x7F
325
330#define C6DOFIMU18_SMD_INT1_EN 0x08
331#define C6DOFIMU18_WOM_Z_INT1_EN 0x04
332#define C6DOFIMU18_WOM_Y_INT1_EN 0x02
333#define C6DOFIMU18_WOM_X_INT1_EN 0x01
334#define C6DOFIMU18_INT_SOURCE1_MASK 0x0F
335
340#define C6DOFIMU18_INT_UI_FSYNC_INT2_EN 0x40
341#define C6DOFIMU18_INT_PLL_RDY_INT2_EN 0x20
342#define C6DOFIMU18_INT_RESET_DONE_INT2_EN 0x10
343#define C6DOFIMU18_INT_UI_DRDY_INT2_EN 0x08
344#define C6DOFIMU18_INT_FIFO_THS_INT2_EN 0x04
345#define C6DOFIMU18_INT_FIFO_FULL_INT2_EN 0x02
346#define C6DOFIMU18_INT_UI_AGC_RDY_INT2_EN 0x01
347#define C6DOFIMU18_INT_SOURCE3_MASK 0x7F
348
353#define C6DOFIMU18_SMD_INT2_EN 0x08
354#define C6DOFIMU18_WOM_Z_INT2_EN 0x04
355#define C6DOFIMU18_WOM_Y_INT2_EN 0x02
356#define C6DOFIMU18_WOM_X_INT2_EN 0x01
357#define C6DOFIMU18_INT_SOURCE4_MASK 0x0F
358
363#define C6DOFIMU18_INT_SOURCE6_STEP_DET_INT1_EN 0x20
364#define C6DOFIMU18_INT_SOURCE6_STEP_CNT_INT1_EN 0x10
365#define C6DOFIMU18_INT_SOURCE6_TILT_DET_INT1_EN 0x08
366#define C6DOFIMU18_INT_SOURCE6_TAP_DET_INT1_EN 0x01
367#define C6DOFIMU18_INT_SOURCE6_MASK 0x39
368
373#define C6DOFIMU18_INT_SOURCE7_STEP_DET_INT2_EN 0x20
374#define C6DOFIMU18_INT_SOURCE7_STEP_CNT_INT2_EN 0x10
375#define C6DOFIMU18_INT_SOURCE7_TILT_DET_INT2_EN 0x08
376#define C6DOFIMU18_INT_SOURCE7_TAP_DET_INT2_EN 0x01
377#define C6DOFIMU18_INT_SOURCE7_MASK 0x39
378
383#define C6DOFIMU18_UI_FSYNC_INT_FLAG 0x40
384#define C6DOFIMU18_PLL_DONE_INT_FLAG 0x20
385#define C6DOFIMU18_RESET_DONE_INT_FLAG 0x10
386#define C6DOFIMU18_DATA_RDY_INT_FLAG 0x08
387#define C6DOFIMU18_FIFO_THS_INT_FLAG 0x04
388#define C6DOFIMU18_FIFO_FULL_INT_FLAG 0x02
389#define C6DOFIMU18_AGC_RDY_INT_FLAG 0x01
390
395#define C6DOFIMU18_SMD_INT_FLAG 0x08
396#define C6DOFIMU18_WOM_Z_INT_FLAG 0x04
397#define C6DOFIMU18_WOM_Y_INT_FLAG 0x02
398#define C6DOFIMU18_WOM_X_INT_FLAG 0x01
399
404#define C6DOFIMU18_STEP_DET_INT_FLAG 0x10
405#define C6DOFIMU18_STEP_CNT_OVF_INT_FLAG 0x08
406#define C6DOFIMU18_TILT_DET_INT_FLAG 0x04
407#define C6DOFIMU18_SLEEP_INT_FLAG 0x02
408#define C6DOFIMU18_TAP_DET_INT_FLAG 0x01
409
414#define C6DOFIMU18_FIFO_HLD_LAST_DATA_EN 0x80
415#define C6DOFIMU18_FIFO_COUNT_REC 0x40
416#define C6DOFIMU18_FIFO_COUNT_ENDIAN 0x20
417#define C6DOFIMU18_FIFO_DATA_ENDIAN 0x10
418#define C6DOFIMU18_UI_SIFS_CFG_DISABLE_I2C 0x03
419#define C6DOFIMU18_UI_SIFS_CFG_DISABLE_SPI 0x02
420#define C6DOFIMU18_INTF_CONFIG0_MASK 0xF3
421
426#define C6DOFIMU18_ACCEL_LP_CLK_SEL_WAKE_UP_OSC 0x00
427#define C6DOFIMU18_ACCEL_LP_CLK_SEL_RC_OSC 0x08
428#define C6DOFIMU18_ACCEL_CLKSEL_RC 0x00
429#define C6DOFIMU18_ACCEL_CLKSEL_PLL_OR_RC 0x01
430#define C6DOFIMU18_ACCEL_CLKSEL_DISABLE 0x03
431
436#define C6DOFIMU18_SPI_3WIRE 0x00
437#define C6DOFIMU18_SPI_4WIRE 0x02
438
443#define C6DOFIMU18_PIN9_INT2 0x00
444#define C6DOFIMU18_PIN9_FSYNC 0x01
445
450#define C6DOFIMU18_DMP_INIT_EN 0x40
451#define C6DOFIMU18_DMP_MEM_RESET_EN 0x20
452#define C6DOFIMU18_ABORT_AND_RESET 0x08
453#define C6DOFIMU18_TMST_STROBE 0x04
454#define C6DOFIMU18_FIFO_FLUSH 0x02
455
460#define C6DOFIMU18_PWR_TEMP_DIS 0x20
461#define C6DOFIMU18_PWR_IDLE_OFF 0x10
462#define C6DOFIMU18_PWR_GYRO_MODE_OFF 0x00
463#define C6DOFIMU18_PWR_GYRO_STANDBY 0x04
464#define C6DOFIMU18_PWR_GYRO_LN_MODE 0x0C
465#define C6DOFIMU18_PWR_ACCEL_MODE_OFF 0x00
466#define C6DOFIMU18_PWR_ACCEL_LP_MODE 0x02
467#define C6DOFIMU18_PWR_ACCEL_LN_MODE 0x03
468
473#define C6DOFIMU18_GYRO_FS_SEL_2000DPS 0x00
474#define C6DOFIMU18_GYRO_FS_SEL_1000DPS 0x20
475#define C6DOFIMU18_GYRO_FS_SEL_500DPS 0x40
476#define C6DOFIMU18_GYRO_FS_SEL_250DPS 0x60
477#define C6DOFIMU18_GYRO_FS_SEL_125DPS 0x80
478#define C6DOFIMU18_GYRO_FS_SEL_62DPS 0xA0
479#define C6DOFIMU18_GYRO_FS_SEL_32DPS 0xC0
480#define C6DOFIMU18_GYRO_FS_SEL_15DPS 0xE0
481#define C6DOFIMU18_GYRO_FS_SEL_MASK 0xE0
482#define C6DOFIMU18_GYRO_ODR_8kHz 0x03
483#define C6DOFIMU18_GYRO_ODR_4kHz 0x04
484#define C6DOFIMU18_GYRO_ODR_2kHz 0x05
485#define C6DOFIMU18_GYRO_ODR_1kHz 0x06
486#define C6DOFIMU18_GYRO_ODR_200Hz 0x07
487#define C6DOFIMU18_GYRO_ODR_100Hz 0x08
488#define C6DOFIMU18_GYRO_ODR_50Hz 0x09
489#define C6DOFIMU18_GYRO_ODR_25Hz 0x0A
490#define C6DOFIMU18_GYRO_ODR_12Hz 0x0B
491#define C6DOFIMU18_GYRO_ODR_500Hz 0x0F
492#define C6DOFIMU18_GYRO_ODR_MASK 0x0F
493#define C6DOFIMU18_GYRO_ODR_MASK 0x0F
494
499#define C6DOFIMU18_TEMP_FILT_BW_4kHz 0x00
500#define C6DOFIMU18_TEMP_FILT_BW_170Hz 0x20
501#define C6DOFIMU18_TEMP_FILT_BW_82Hz 0x40
502#define C6DOFIMU18_TEMP_FILT_BW_40Hz 0x60
503#define C6DOFIMU18_TEMP_FILT_BW_20Hz 0x80
504#define C6DOFIMU18_TEMP_FILT_BW_10Hz 0xA0
505#define C6DOFIMU18_TEMP_FILT_BW_5Hz_0 0xC0
506#define C6DOFIMU18_TEMP_FILT_BW_5Hz_1 0xE0
507#define C6DOFIMU18_GYRO_UI_FILT_ORD_1st 0x00
508#define C6DOFIMU18_GYRO_UI_FILT_ORD_2nd 0x04
509#define C6DOFIMU18_GYRO_UI_FILT_ORD_3rd 0x08
510#define C6DOFIMU18_GYRO_UI_FILT_ORD_MASK 0x0C
511#define C6DOFIMU18_GYRO_DEC2_M2_ORD_3rd 0x02
512#define C6DOFIMU18_GYRO_CONFIG1_MASK 0xEF
513
518#define C6DOFIMU18_ACCEL_FS_SEL_16G 0x00
519#define C6DOFIMU18_ACCEL_FS_SEL_8G 0x20
520#define C6DOFIMU18_ACCEL_FS_SEL_4G 0x40
521#define C6DOFIMU18_ACCEL_FS_SEL_2G 0x60
522#define C6DOFIMU18_ACCEL_FS_SEL_MASK 0x60
523#define C6DOFIMU18_ACCEL_ODR_8kHz_LN 0x03
524#define C6DOFIMU18_ACCEL_ODR_4kHz_LN 0x04
525#define C6DOFIMU18_ACCEL_ODR_2kHz_LN 0x05
526#define C6DOFIMU18_ACCEL_ODR_1kHz_LN 0x06
527#define C6DOFIMU18_ACCEL_ODR_200Hz_LP_LN 0x07
528#define C6DOFIMU18_ACCEL_ODR_100Hz_LP_LN 0x08
529#define C6DOFIMU18_ACCEL_ODR_50Hz_LP_LN 0x09
530#define C6DOFIMU18_ACCEL_ODR_25Hz_LP_LN 0x0A
531#define C6DOFIMU18_ACCEL_ODR_12Hz_LP_LN 0x0B
532#define C6DOFIMU18_ACCEL_ODR_6Hz_LP 0x0C
533#define C6DOFIMU18_ACCEL_ODR_3Hz_LP 0x0D
534#define C6DOFIMU18_ACCEL_ODR_1Hz_LP 0x0E
535#define C6DOFIMU18_ACCEL_ODR_500Hz_LP_LN 0x0F
536#define C6DOFIMU18_ACCEL_ODR_MASK 0x0F
537
542#define C6DOFIMU18_ACCEL_UI_FILT_ORD_1st 0x00
543#define C6DOFIMU18_ACCEL_UI_FILT_ORD_2nd 0x08
544#define C6DOFIMU18_ACCEL_UI_FILT_ORD_3rd 0x10
545#define C6DOFIMU18_ACCEL_UI_FILT_ORD_MASK 0x18
546#define C6DOFIMU18_ACCEL_DEC2_M2_ORD_3rd 0x04
547
552#define C6DOFIMU18_TMST_TO_REGS_EN 0x10
553#define C6DOFIMU18_TMST_RES 0x08
554#define C6DOFIMU18_TMST_DELTA_EN 0x04
555#define C6DOFIMU18_TMST_FSYNC_EN 0x02
556#define C6DOFIMU18_TMST_EN 0x01
557#define C6DOFIMU18_TMST_MASK 0x1F
558
563#define C6DOFIMU18_FIFO_BYPASS 0x00
564#define C6DOFIMU18_FIFO_STREAM_TO_FIFO 0x40
565#define C6DOFIMU18_FIFO_STOP_ON_FULL 0x80
566#define C6DOFIMU18_FIFO_CONFIG_MASK 0xC0
567
572#define C6DOFIMU18_FIFO_RESUME_PARTIAL_RD 0x40
573#define C6DOFIMU18_FIFO_WM_GT_TH 0x20
574#define C6DOFIMU18_FIFO_TMST_FSYNC_EN 0x08
575#define C6DOFIMU18_FIFO_TEMP_EN 0x04
576#define C6DOFIMU18_FIFO_GYRO_EN 0x02
577#define C6DOFIMU18_FIFO_ACCEL_EN 0x01
578
583#define C6DOFIMU18_DO_NOT_TAG_FSYNC 0x00
584#define C6DOFIMU18_FSYNC_TAG_TEMP_OUT_LSB 0x10
585#define C6DOFIMU18_FSYNC_GYRO_XOUT_LSB 0x20
586#define C6DOFIMU18_FSYNC_GYRO_YOUT_LSB 0x30
587#define C6DOFIMU18_FSYNC_GYRO_ZOUT_LSB 0x40
588#define C6DOFIMU18_FSYNC_ACCEL_XOUT_LSB 0x50
589#define C6DOFIMU18_FSYNC_ACCEL_YOUT_LSB 0x60
590#define C6DOFIMU18_FSYNC_ACCEL_ZOUT_LSB 0x70
591#define C6DOFIMU18_FSYNC_UI_SEL_MASK 0x70
592#define C6DOFIMU18_FSYNC_UI_FLAG_CLEAR_SEL 0x02
593#define C6DOFIMU18_FSYNC_POLARITY_RISING_EGDE 0x01
594#define C6DOFIMU18_FSYNC_POLARITY_FALLING_EGDE 0x01
595
600#define C6DOFIMU18_DMP_POVER_SAVE_EN 0x80
601#define C6DOFIMU18_TAP_ENABLE 0x40
602#define C6DOFIMU18_PED_ENABLE 0x20
603#define C6DOFIMU18_TILT_ENABLE 0x10
604#define C6DOFIMU18_R2W_ENABLE 0x08
605#define C6DOFIMU18_DMP_ODR_25Hz 0x00
606#define C6DOFIMU18_DMP_ODR_50Hz 0x02
607
612#define C6DOFIMU18_LOW_ENERGY_AMP_TH_SEL 0xA0
613#define C6DOFIMU18_DMP_POVER_SAVE_TIME_0S 0x00
614#define C6DOFIMU18_DMP_POVER_SAVE_TIME_4S 0x01
615#define C6DOFIMU18_DMP_POWER_SAVE_TIME_8S 0x02
616#define C6DOFIMU18_DMP_POWER_SAVE_TIME_12S 0x03
617#define C6DOFIMU18_DMP_POWER_SAVE_TIME_16S 0x04
618#define C6DOFIMU18_DMP_POWER_SAVE_TIME_20S 0x05
619#define C6DOFIMU18_DMP_POWER_SAVE_TIME_24S 0x06
620#define C6DOFIMU18_DMP_POWER_SAVE_TIME_28S 0x07
621#define C6DOFIMU18_DMP_POWER_SAVE_TIME_32S 0x08
622#define C6DOFIMU18_DMP_POWER_SAVE_TIME_36S 0x09
623#define C6DOFIMU18_DMP_POWER_SAVE_TIME_40S 0x0A
624#define C6DOFIMU18_DMP_POWER_SAVE_TIME_44S 0x0B
625#define C6DOFIMU18_DMP_POWER_SAVE_TIME_48S 0x0C
626#define C6DOFIMU18_DMP_POWER_SAVE_TIME_52S 0x0D
627#define C6DOFIMU18_DMP_POWER_SAVE_TIME_56S 0x0E
628#define C6DOFIMU18_DMP_POWER_SAVE_TIME_60S 0x0F
629
634#define C6DOFIMU18_PED_AMP_TH_SEL 0x80
635#define C6DOFIMU18_PED_STEP_CNT_TH_0_STEPS 0x00
636#define C6DOFIMU18_PED_STEP_CNT_TH_1_STEPS 0x01
637#define C6DOFIMU18_PED_STEP_CNT_TH_2_STEPS 0x02
638#define C6DOFIMU18_PED_STEP_CNT_TH_3_STEPS 0x03
639#define C6DOFIMU18_PED_STEP_CNT_TH_4_STEPS 0x04
640#define C6DOFIMU18_PED_STEP_CNT_TH_5_STEPS 0x05
641#define C6DOFIMU18_PED_STEP_CNT_TH_6_STEPS 0x06
642#define C6DOFIMU18_PED_STEP_CNT_TH_7_STEPS 0x07
643#define C6DOFIMU18_PED_STEP_CNT_TH_8_STEPS 0x08
644#define C6DOFIMU18_PED_STEP_CNT_TH_9_STEPS 0x09
645#define C6DOFIMU18_PED_STEP_CNT_TH_10_STEPS 0x0A
646#define C6DOFIMU18_PED_STEP_CNT_TH_11_STEPS 0x0B
647#define C6DOFIMU18_PED_STEP_CNT_TH_12_STEPS 0x0C
648#define C6DOFIMU18_PED_STEP_CNT_TH_13_STEPS 0x0D
649#define C6DOFIMU18_PED_STEP_CNT_TH_14_STEPS 0x0E
650#define C6DOFIMU18_PED_STEP_CNT_TH_15_STEPS 0x0F
651#define C6DOFIMU18_PED_STEP_CNT_TH_MASK 0x0F
652
657#define C6DOFIMU18_PED_STEP_DET_TH_0_STEPS 0x00
658#define C6DOFIMU18_PED_STEP_DET_TH_1_STEPS 0x20
659#define C6DOFIMU18_PED_STEP_DET_TH_2_STEPS 0x40
660#define C6DOFIMU18_PED_STEP_DET_TH_3_STEPS 0x60
661#define C6DOFIMU18_PED_STEP_DET_TH_4_STEPS 0x80
662#define C6DOFIMU18_PED_STEP_DET_TH_5_STEPS 0xA0
663#define C6DOFIMU18_PED_STEP_DET_TH_6_STEPS 0xC0
664#define C6DOFIMU18_PED_STEP_DET_TH_7_STEPS 0xE0
665#define C6DOFIMU18_PED_SB_TIMER_TH_0_SAMPLES 0x00
666#define C6DOFIMU18_PED_SB_TIMER_TH_1_SAMPLES 0x04
667#define C6DOFIMU18_PED_SB_TIMER_TH_2_SAMPLES 0x08
668#define C6DOFIMU18_PED_SB_TIMER_TH_3_SAMPLES 0x0C
669#define C6DOFIMU18_PED_SB_TIMER_TH_4_SAMPLES 0x10
670#define C6DOFIMU18_PED_SB_TIMER_TH_5_SAMPLES 0x14
671#define C6DOFIMU18_PED_SB_TIMER_TH_6_SAMPLES 0x18
672#define C6DOFIMU18_PED_SB_TIMER_TH_7_SAMPLES 0x1C
673#define C6DOFIMU18_PED_HI_EN_TH_SEL 0x01
674
679#define C6DOFIMU18_TILT_WAIT_TIME_0S 0x00
680#define C6DOFIMU18_TILT_WAIT_TIME_2S 0x40
681#define C6DOFIMU18_TILT_WAIT_TIME_4S 0x80
682#define C6DOFIMU18_TILT_WAIT_TIME_6S 0xC0
683#define C6DOFIMU18_TILT_WAIT_TIME_MASK 0xC0
684#define C6DOFIMU18_SLEEP_TIME_OUT_1s28 0x00
685#define C6DOFIMU18_SLEEP_TIME_OUT_2s56 0x08
686#define C6DOFIMU18_SLEEP_TIME_OUT_3s84 0x10
687#define C6DOFIMU18_SLEEP_TIME_OUT_5s12 0x18
688#define C6DOFIMU18_SLEEP_TIME_OUT_6s4 0x20
689#define C6DOFIMU18_SLEEP_TIME_OUT_7s68 0x28
690#define C6DOFIMU18_SLEEP_TIME_OUT_8s96 0x30
691#define C6DOFIMU18_SLEEP_TIME_OUT_10s24 0x38
692#define C6DOFIMU18_SLEEP_TIME_OUT_MASK 0x38
693
698#define C6DOFIMU18_TAP_MIN_JERK_THR 0x44
699#define C6DOFIMU18_TAP_MAX_OEAK_TOL 0x01
700
705#define C6DOFIMU18_TAP_TMAX 0x20
706#define C6DOFIMU18_TAP_TAVG 0x08
707#define C6DOFIMU18_TAP_TMIN 0x03
708
713#define C6DOFIMU18_SENSITIVITY_MODE_HIGH_PERF 0x00
714#define C6DOFIMU18_SENSITIVITY_MODE_SLOW_WALK 0x01
715
720#define C6DOFIMU18_TEMPERATURE_DIV 132.48
721#define C6DOFIMU18_TEMPERATURE_ADD 25
722
727#define C6DOFIMU18_WHO_AM_I_VALUE 0x42
728
734#define C6DOFIMU18_DEVICE_ADDRESS_GND 0x68
735#define C6DOFIMU18_DEVICE_ADDRESS_VCC 0x69
736
745#define C6DOFIMU18_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
746#define C6DOFIMU18_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
747
748 // c6dofimu18_set
749
764#define C6DOFIMU18_MAP_MIKROBUS( cfg, mikrobus ) \
765 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
766 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
767 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
768 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
769 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
770 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
771 cfg.ryc = MIKROBUS( mikrobus, MIKROBUS_AN ); \
772 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
773
774 // c6dofimu18_map
775 // c6dofimu18
776
787
792typedef err_t ( *c6dofimu18_master_io_t )( struct c6dofimu18_s*, uint8_t, uint8_t*, uint8_t );
798typedef struct c6dofimu18_s
799{
800 digital_in_t ryc;
801 digital_in_t int_pin;
803 i2c_master_t i2c;
804 spi_master_t spi;
807 pin_name_t chip_select;
808 spi_master_mode_t spi_mode;
809 uint8_t slew_rate;
816
821typedef struct
822{
823 pin_name_t scl;
824 pin_name_t sda;
825 pin_name_t miso;
826 pin_name_t mosi;
827 pin_name_t sck;
828 pin_name_t cs;
829 pin_name_t ryc;
830 pin_name_t int_pin;
832 uint32_t i2c_speed;
833 uint8_t i2c_address;
835 uint32_t spi_speed;
836 spi_master_mode_t spi_mode;
837 spi_master_chip_select_polarity_t cs_polarity;
842
847typedef struct
848{
849 int16_t data_x;
850 int16_t data_y;
851 int16_t data_z;
852
854
866
883
899
914
928
943err_t c6dofimu18_generic_write ( c6dofimu18_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
944
959err_t c6dofimu18_generic_read ( c6dofimu18_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
960
973err_t c6dofimu18_set_reg_bank( c6dofimu18_t *ctx, uint8_t bank );
974
991err_t c6dofimu18_reg_write ( c6dofimu18_t *ctx, uint8_t reg_bank, uint8_t reg, uint8_t *data_in, uint8_t len );
992
1007err_t c6dofimu18_reg_read ( c6dofimu18_t *ctx, uint8_t reg_bank, uint8_t reg, uint8_t *data_out, uint8_t len );
1008
1021
1031
1041
1054
1067err_t c6dofimu18_read_temperature ( c6dofimu18_t *ctx, float *temperature_data );
1068
1081err_t c6dofimu18_read_timestamp ( c6dofimu18_t *ctx, uint32_t *tmst_data );
1082
1098err_t c6dofimu18_get_data_from_register ( c6dofimu18_t *ctx, float *temperature_data,
1099 c6dofimu18_data_t *accel_data, c6dofimu18_data_t *gyro_data,
1100 uint32_t *tmst_data );
1101
1113
1127err_t c6dofimu18_get_tap_detection ( c6dofimu18_t *ctx, uint8_t *tap_num, uint8_t *tap_axis, uint8_t *tap_dir );
1128
1129#ifdef __cplusplus
1130}
1131#endif
1132#endif // C6DOFIMU18_H
1133
1134 // c6dofimu18
1135
1136// ------------------------------------------------------------------------ END
c6dofimu18_return_value_t
6DOF IMU 18 Click return value data.
Definition c6dofimu18.h:860
@ C6DOFIMU18_OK
Definition c6dofimu18.h:861
@ C6DOFIMU18_RESET_ERROR
Definition c6dofimu18.h:863
@ C6DOFIMU18_ERROR
Definition c6dofimu18.h:862
c6dofimu18_drv_t
6DOF IMU 18 Click driver selector.
Definition c6dofimu18.h:782
@ C6DOFIMU18_DRV_SEL_I2C
Definition c6dofimu18.h:784
@ C6DOFIMU18_DRV_SEL_SPI
Definition c6dofimu18.h:783
err_t(* c6dofimu18_master_io_t)(struct c6dofimu18_s *, uint8_t, uint8_t *, uint8_t)
6DOF IMU 18 Click driver interface.
Definition c6dofimu18.h:792
struct c6dofimu18_s c6dofimu18_t
6DOF IMU 18 Click context object.
err_t c6dofimu18_read_timestamp(c6dofimu18_t *ctx, uint32_t *tmst_data)
6DOF IMU 18 read timestamp function.
err_t c6dofimu18_reg_write(c6dofimu18_t *ctx, uint8_t reg_bank, uint8_t reg, uint8_t *data_in, uint8_t len)
6DOF IMU 18 register data writing function.
err_t c6dofimu18_read_temperature(c6dofimu18_t *ctx, float *temperature_data)
6DOF IMU 18 read temperature function.
err_t c6dofimu18_reg_read(c6dofimu18_t *ctx, uint8_t reg_bank, uint8_t reg, uint8_t *data_out, uint8_t len)
6DOF IMU 18 data reading function.
err_t c6dofimu18_get_data_from_register(c6dofimu18_t *ctx, float *temperature_data, c6dofimu18_data_t *accel_data, c6dofimu18_data_t *gyro_data, uint32_t *tmst_data)
6DOF IMU 18 read data function.
err_t c6dofimu18_default_cfg(c6dofimu18_t *ctx)
6DOF IMU 18 default configuration function.
void c6dofimu18_cfg_setup(c6dofimu18_cfg_t *cfg)
6DOF IMU 18 configuration object setup function.
err_t c6dofimu18_set_reg_bank(c6dofimu18_t *ctx, uint8_t bank)
6DOF IMU 18 set register bank function.
err_t c6dofimu18_generic_write(c6dofimu18_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
6DOF IMU 18 data writing function.
uint8_t c6dofimu18_get_int1_state(c6dofimu18_t *ctx)
6DOF IMU 18 read INT1 pin state function.
err_t c6dofimu18_sw_reset(c6dofimu18_t *ctx)
6DOF IMU 18 software reset function.
err_t c6dofimu18_set_basic_tap_detection(c6dofimu18_t *ctx)
6DOF IMU 18 basic tap detection configuration function.
err_t c6dofimu18_get_tap_detection(c6dofimu18_t *ctx, uint8_t *tap_num, uint8_t *tap_axis, uint8_t *tap_dir)
6DOF IMU 18 get tap detection data function.
err_t c6dofimu18_generic_read(c6dofimu18_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
6DOF IMU 18 data reading function.
void c6dofimu18_drv_interface_selection(c6dofimu18_cfg_t *cfg, c6dofimu18_drv_t drv_sel)
6DOF IMU 18 driver interface setup function.
err_t c6dofimu18_init(c6dofimu18_t *ctx, c6dofimu18_cfg_t *cfg)
6DOF IMU 18 initialization function.
err_t c6dofimu18_configure_digital_interface(c6dofimu18_t *ctx, uint8_t slew_rate)
6DOF IMU 18 configure digital interface function.
This file contains SPI specific macros, functions, etc.
6DOF IMU 18 Click configuration object.
Definition c6dofimu18.h:822
uint32_t i2c_speed
Definition c6dofimu18.h:832
pin_name_t ryc
Definition c6dofimu18.h:829
spi_master_chip_select_polarity_t cs_polarity
Definition c6dofimu18.h:837
pin_name_t sck
Definition c6dofimu18.h:827
spi_master_mode_t spi_mode
Definition c6dofimu18.h:836
pin_name_t mosi
Definition c6dofimu18.h:826
uint32_t spi_speed
Definition c6dofimu18.h:835
pin_name_t scl
Definition c6dofimu18.h:823
pin_name_t int_pin
Definition c6dofimu18.h:830
pin_name_t miso
Definition c6dofimu18.h:825
pin_name_t sda
Definition c6dofimu18.h:824
pin_name_t cs
Definition c6dofimu18.h:828
uint8_t i2c_address
Definition c6dofimu18.h:833
c6dofimu18_drv_t drv_sel
Definition c6dofimu18.h:839
6DOF IMU 18 data object.
Definition c6dofimu18.h:848
int16_t data_y
Definition c6dofimu18.h:850
int16_t data_z
Definition c6dofimu18.h:851
int16_t data_x
Definition c6dofimu18.h:849
6DOF IMU 18 Click context object.
Definition c6dofimu18.h:799
spi_master_t spi
Definition c6dofimu18.h:804
digital_in_t ryc
Definition c6dofimu18.h:800
uint8_t slew_rate
Definition c6dofimu18.h:809
c6dofimu18_master_io_t read_f
Definition c6dofimu18.h:813
spi_master_mode_t spi_mode
Definition c6dofimu18.h:808
digital_in_t int_pin
Definition c6dofimu18.h:801
i2c_master_t i2c
Definition c6dofimu18.h:803
uint8_t slave_address
Definition c6dofimu18.h:806
c6dofimu18_master_io_t write_f
Definition c6dofimu18.h:812
pin_name_t chip_select
Definition c6dofimu18.h:807
c6dofimu18_drv_t drv_sel
Definition c6dofimu18.h:810