c6dofimu20  2.1.0.0
c6dofimu20.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 C6DOFIMU20_H
29 #define C6DOFIMU20_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 #include "drv_spi_master.h"
49 #include "spi_specifics.h"
50 
71 #define C6DOFIMU20_REG_CHIP_ID 0x00
72 #define C6DOFIMU20_REG_ERR 0x01
73 #define C6DOFIMU20_REG_STATUS 0x02
74 #define C6DOFIMU20_REG_ACC_DATA_X 0x03
75 #define C6DOFIMU20_REG_ACC_DATA_Y 0x04
76 #define C6DOFIMU20_REG_ACC_DATA_Z 0x05
77 #define C6DOFIMU20_REG_GYR_DATA_X 0x06
78 #define C6DOFIMU20_REG_GYR_DATA_Y 0x07
79 #define C6DOFIMU20_REG_GYR_DATA_Z 0x08
80 #define C6DOFIMU20_REG_TEMP_DATA 0x09
81 #define C6DOFIMU20_REG_SENSOR_TIME_0 0x0A
82 #define C6DOFIMU20_REG_SENSOR_TIME_1 0x0B
83 #define C6DOFIMU20_REG_SAT_FLAGS 0x0C
84 #define C6DOFIMU20_REG_INT_STATUS_INT1 0x0D
85 #define C6DOFIMU20_REG_INT_STATUS_INT2 0x0E
86 #define C6DOFIMU20_REG_INT_STATUS_IBI 0x0F
87 #define C6DOFIMU20_REG_FEATURE_IO0 0x10
88 #define C6DOFIMU20_REG_FEATURE_IO1 0x11
89 #define C6DOFIMU20_REG_FEATURE_IO2 0x12
90 #define C6DOFIMU20_REG_FEATURE_IO3 0x13
91 #define C6DOFIMU20_REG_FEATURE_IO_STATUS 0x14
92 #define C6DOFIMU20_REG_FIFO_FILL_LEVEL 0x15
93 #define C6DOFIMU20_REG_FIFO_DATA 0x16
94 #define C6DOFIMU20_REG_ACC_CONF 0x20
95 #define C6DOFIMU20_REG_GYR_CONF 0x21
96 #define C6DOFIMU20_REG_ALT_ACC_CONF 0x28
97 #define C6DOFIMU20_REG_ALT_GYR_CONF 0x29
98 #define C6DOFIMU20_REG_ALT_CONF 0x2A
99 #define C6DOFIMU20_REG_ALT_STATUS 0x2B
100 #define C6DOFIMU20_REG_FIFO_WATERMARK 0x35
101 #define C6DOFIMU20_REG_FIFO_CONF 0x36
102 #define C6DOFIMU20_REG_FIFO_CTRL 0x37
103 #define C6DOFIMU20_REG_IO_INT_CTRL 0x38
104 #define C6DOFIMU20_REG_INT_CONF 0x39
105 #define C6DOFIMU20_REG_INT_MAP1 0x3A
106 #define C6DOFIMU20_REG_INT_MAP2 0x3B
107 #define C6DOFIMU20_REG_FEATURE_CTRL 0x40
108 #define C6DOFIMU20_REG_FEATURE_DATA_ADDR 0x41
109 #define C6DOFIMU20_REG_FEATURE_DATA_TX 0x42
110 #define C6DOFIMU20_REG_FEATURE_DATA_STATUS 0x43
111 #define C6DOFIMU20_REG_FEATURE_ENGINE_STATUS 0x45
112 #define C6DOFIMU20_REG_FEATURE_EVENT_EXT 0x47
113 #define C6DOFIMU20_REG_IO_PDN_CTRL 0x4F
114 #define C6DOFIMU20_REG_IO_SPI_IF 0x50
115 #define C6DOFIMU20_REG_IO_PAD_STRENGTH 0x51
116 #define C6DOFIMU20_REG_IO_I2C_IF 0x52
117 #define C6DOFIMU20_REG_IO_ODR_DEVIATION 0x53
118 #define C6DOFIMU20_REG_ACC_DP_OFF_X 0x60
119 #define C6DOFIMU20_REG_ACC_DP_DGAIN_X 0x61
120 #define C6DOFIMU20_REG_ACC_DP_OFF_Y 0x62
121 #define C6DOFIMU20_REG_ACC_DP_DGAIN_Y 0x63
122 #define C6DOFIMU20_REG_ACC_DP_OFF_Z 0x64
123 #define C6DOFIMU20_REG_ACC_DP_DGAIN_Z 0x65
124 #define C6DOFIMU20_REG_GYR_DP_OFF_X 0x66
125 #define C6DOFIMU20_REG_GYR_DP_DGAIN_X 0x67
126 #define C6DOFIMU20_REG_GYR_DP_OFF_Y 0x68
127 #define C6DOFIMU20_REG_GYR_DP_DGAIN_Y 0x69
128 #define C6DOFIMU20_REG_GYR_DP_OFF_Z 0x6A
129 #define C6DOFIMU20_REG_GYR_DP_DGAIN_Z 0x6B
130 #define C6DOFIMU20_REG_CMD 0x7E
131 #define C6DOFIMU20_REG_CFG_RES 0x7F
132 
137 #define C6DOFIMU20_REG_SC_ST_VALUE4 0x2C
138 #define C6DOFIMU20_REG_SC_ST_VALUE3 0x2B
139 #define C6DOFIMU20_REG_SC_ST_VALUE2 0x2A
140 #define C6DOFIMU20_REG_SC_ST_VALUE1 0x29
141 #define C6DOFIMU20_REG_SC_ST_VALUE0 0x28
142 #define C6DOFIMU20_REG_GYR_SC_ST_CONF_RE 0x27
143 #define C6DOFIMU20_REG_GYR_SC_SELECT 0x26
144 #define C6DOFIMU20_REG_ST_SELECT 0x25
145 #define C6DOFIMU20_REG_ST_RESULT 0x24
146 #define C6DOFIMU20_REG_ALT_CONFIG_CHG 0x23
147 #define C6DOFIMU20_REG_TILT_2 0x22
148 #define C6DOFIMU20_REG_TILT_1 0x21
149 #define C6DOFIMU20_REG_TAP_3 0x20
150 #define C6DOFIMU20_REG_TAP_2 0x1F
151 #define C6DOFIMU20_REG_TAP_1 0x1E
152 #define C6DOFIMU20_REG_ORIENT_2 0x1D
153 #define C6DOFIMU20_REG_ORIENT_1 0x1C
154 #define C6DOFIMU20_REG_SC_12 0x1B
155 #define C6DOFIMU20_REG_SC_11 0x1A
156 #define C6DOFIMU20_REG_SC_10 0x19
157 #define C6DOFIMU20_REG_SC_9 0x18
158 #define C6DOFIMU20_REG_SC_8 0x17
159 #define C6DOFIMU20_REG_SC_7 0x16
160 #define C6DOFIMU20_REG_SC_6 0x15
161 #define C6DOFIMU20_REG_SC_5 0x14
162 #define C6DOFIMU20_REG_SC_4 0x13
163 #define C6DOFIMU20_REG_SC_3 0x12
164 #define C6DOFIMU20_REG_SC_2 0x11
165 #define C6DOFIMU20_REG_SC_1 0x10
166 #define C6DOFIMU20_REG_SIGMO_3 0x0F
167 #define C6DOFIMU20_REG_SIGMO_2 0x0E
168 #define C6DOFIMU20_REG_SIGMO_1 0x0D
169 #define C6DOFIMU20_REG_FLAT_2 0x0C
170 #define C6DOFIMU20_REG_FLAT_1 0x0B
171 #define C6DOFIMU20_REG_MOMO_3 0x0A
172 #define C6DOFIMU20_REG_MOMO_2 0x09
173 #define C6DOFIMU20_REG_MOMO_1 0x08
174 #define C6DOFIMU20_REG_ANYMO_3 0x07
175 #define C6DOFIMU20_REG_ANYMO_2 0x06
176 #define C6DOFIMU20_REG_ANYMO_1 0x05
177 #define C6DOFIMU20_REG_AXIS_MAP_1 0x03
178 #define C6DOFIMU20_REG_GEN_SET_1 0x02
179  // c6dofimu20_reg
181 
196 #define C6DOFIMU20_SW_RESET_CMD 0xDEAF
197 
202 #define C6DOFIMU20_REG_ERR_FATAL_ERR_FLAG 0x0001
203 #define C6DOFIMU20_REG_ERR_FEAT_ENG_OVRLD_FLAG 0x0004
204 #define C6DOFIMU20_REG_ERR_ACC_CONF_ERR_FLAG 0x0020
205 #define C6DOFIMU20_REG_ERR_GYR_CONF_ERR_FLAG 0x0040
206 
211 #define C6DOFIMU20_STATUS_POR_DETECTED_FLAG 0x0001
212 #define C6DOFIMU20_STATUS_DRDY_TEMP_FLAG 0x0020
213 #define C6DOFIMU20_STATUS_DRDY_GYR_FLAG 0x0040
214 #define C6DOFIMU20_STATUS_DRDY_ACC_FLAG 0x0080
215 
220 #define C6DOFIMU20_SAT_FLAGS_SATF_ACC_X_FLAG 0x0001
221 #define C6DOFIMU20_SAT_FLAGS_SATF_ACC_Y_FLAG 0x0002
222 #define C6DOFIMU20_SAT_FLAGS_SATF_ACC_Z_FLAG 0x0004
223 #define C6DOFIMU20_SAT_FLAGS_SATF_GYR_X_FLAG 0x0008
224 #define C6DOFIMU20_SAT_FLAGS_SATF_GYR_Y_FLAG 0x0010
225 #define C6DOFIMU20_SAT_FLAGS_SATF_GYR_Z_FLAG 0x0020
226 
231 #define C6DOFIMU20_INT_STATUS_INT1_NO_MOTION 0x0001
232 #define C6DOFIMU20_INT_STATUS_INT1_ANY_MOTION 0x0002
233 #define C6DOFIMU20_INT_STATUS_INT1_FLAT 0x0004
234 #define C6DOFIMU20_INT_STATUS_INT1_ORIENTATION 0x0008
235 #define C6DOFIMU20_INT_STATUS_INT1_STEP_DETECTOR 0x0010
236 #define C6DOFIMU20_INT_STATUS_INT1_STEP_COUNTER 0x0020
237 #define C6DOFIMU20_INT_STATUS_INT1_SIG_MOTION 0x0040
238 #define C6DOFIMU20_INT_STATUS_INT1_TILT 0x0080
239 #define C6DOFIMU20_INT_STATUS_INT1_TAP 0x0100
240 #define C6DOFIMU20_INT_STATUS_INT1_ERR_STATUS 0x0400
241 #define C6DOFIMU20_INT_STATUS_INT1_TEMP_DRDY 0x0800
242 #define C6DOFIMU20_INT_STATUS_INT1_GYR_DRDY 0x1000
243 #define C6DOFIMU20_INT_STATUS_INT1_ACC_DRDY 0x2000
244 #define C6DOFIMU20_INT_STATUS_INT1_FWM 0x4000
245 #define C6DOFIMU20_INT_STATUS_INT1_FFULL 0x8000
246 
251 #define C6DOFIMU20_INT_STATUS_INT2_NO_MOTION 0x0001
252 #define C6DOFIMU20_INT_STATUS_INT2_ANY_MOTION 0x0002
253 #define C6DOFIMU20_INT_STATUS_INT2_FLAT 0x0004
254 #define C6DOFIMU20_INT_STATUS_INT2_ORIENTATION 0x0008
255 #define C6DOFIMU20_INT_STATUS_INT2_STEP_DETECTOR 0x0010
256 #define C6DOFIMU20_INT_STATUS_INT2_STEP_COUNTER 0x0020
257 #define C6DOFIMU20_INT_STATUS_INT2_SIG_MOTION 0x0040
258 #define C6DOFIMU20_INT_STATUS_INT2_TILT 0x0080
259 #define C6DOFIMU20_INT_STATUS_INT2_TAP 0x0100
260 #define C6DOFIMU20_INT_STATUS_INT2_ERR_STATUS 0x0400
261 #define C6DOFIMU20_INT_STATUS_INT2_TEMP_DRDY 0x0800
262 #define C6DOFIMU20_INT_STATUS_INT2_GYR_DRDY 0x1000
263 #define C6DOFIMU20_INT_STATUS_INT2_ACC_DRDY 0x2000
264 #define C6DOFIMU20_INT_STATUS_INT2_FWM 0x4000
265 #define C6DOFIMU20_INT_STATUS_INT2_FFULL 0x8000
266 
271 #define C6DOFIMU20_ACC_CONF_ODR_0POINT78125_Hz 0x0001
272 #define C6DOFIMU20_ACC_CONF_ODR_1POINT5625_Hz 0x0002
273 #define C6DOFIMU20_ACC_CONF_ODR_3POINT125_Hz 0x0003
274 #define C6DOFIMU20_ACC_CONF_ODR_6POINT25_Hz 0x0004
275 #define C6DOFIMU20_ACC_CONF_ODR_12POINT5_Hz 0x0005
276 #define C6DOFIMU20_ACC_CONF_ODR_25_Hz 0x0006
277 #define C6DOFIMU20_ACC_CONF_ODR_50_Hz 0x0007
278 #define C6DOFIMU20_ACC_CONF_ODR_100_Hz 0x0008
279 #define C6DOFIMU20_ACC_CONF_ODR_200_Hz 0x0009
280 #define C6DOFIMU20_ACC_CONF_ODR_400_Hz 0x000A
281 #define C6DOFIMU20_ACC_CONF_ODR_800_Hz 0x000B
282 #define C6DOFIMU20_ACC_CONF_ODR_1POINT6_kHz 0x000C
283 #define C6DOFIMU20_ACC_CONF_ODR_3POINT2_kHz 0x000D
284 #define C6DOFIMU20_ACC_CONF_ODR_6POINT4_kHz 0x000E
285 #define C6DOFIMU20_ACC_CONF_ACC_RANGE_2G 0x0000
286 #define C6DOFIMU20_ACC_CONF_ACC_RANGE_4G 0x0010
287 #define C6DOFIMU20_ACC_CONF_ACC_RANGE_8G 0x0020
288 #define C6DOFIMU20_ACC_CONF_ACC_RANGE_16G 0x0030
289 #define C6DOFIMU20_ACC_CONF_ACC_BW_DIV_2 0x0000
290 #define C6DOFIMU20_ACC_CONF_ACC_BW_DIV_4 0x0080
291 #define C6DOFIMU20_ACC_CONF_ACC_AVG_NUM_0 0x0000
292 #define C6DOFIMU20_ACC_CONF_ACC_AVG_NUM_2 0x0100
293 #define C6DOFIMU20_ACC_CONF_ACC_AVG_NUM_4 0x0200
294 #define C6DOFIMU20_ACC_CONF_ACC_AVG_NUM_8 0x0300
295 #define C6DOFIMU20_ACC_CONF_ACC_AVG_NUM_16 0x0400
296 #define C6DOFIMU20_ACC_CONF_ACC_AVG_NUM_32 0x0500
297 #define C6DOFIMU20_ACC_CONF_ACC_AVG_NUM_64 0x0600
298 #define C6DOFIMU20_ACC_CONF_ACC_MODE_DIS 0x0000
299 #define C6DOFIMU20_ACC_CONF_ACC_MODE_DUTY_CYCLING 0x3000
300 #define C6DOFIMU20_ACC_CONF_ACC_MODE_CONSTANT_OPERATION 0x4000
301 #define C6DOFIMU20_ACC_CONF_ACC_MODE_HIGH_PERFORMANCE 0x7000
302 
307 #define C6DOFIMU20_GYR_CONF_ODR_0POINT78125_Hz 0x0001
308 #define C6DOFIMU20_GYR_CONF_ODR_1POINT5625_Hz 0x0002
309 #define C6DOFIMU20_GYR_CONF_ODR_3POINT125_Hz 0x0003
310 #define C6DOFIMU20_GYR_CONF_ODR_6POINT25_Hz 0x0004
311 #define C6DOFIMU20_GYR_CONF_ODR_12POINT5_Hz 0x0005
312 #define C6DOFIMU20_GYR_CONF_ODR_25_Hz 0x0006
313 #define C6DOFIMU20_GYR_CONF_ODR_50_Hz 0x0007
314 #define C6DOFIMU20_GYR_CONF_ODR_100_Hz 0x0008
315 #define C6DOFIMU20_GYR_CONF_ODR_200_Hz 0x0009
316 #define C6DOFIMU20_GYR_CONF_ODR_400_Hz 0x000A
317 #define C6DOFIMU20_GYR_CONF_ODR_800_Hz 0x000B
318 #define C6DOFIMU20_GYR_CONF_ODR_1POINT6_kHz 0x000C
319 #define C6DOFIMU20_GYR_CONF_ODR_3POINT2_kHz 0x000D
320 #define C6DOFIMU20_GYR_CONF_ODR_6POINT4_kHz 0x000E
321 #define C6DOFIMU20_GYR_CONF_GYR_RANGE_2G 0x0000
322 #define C6DOFIMU20_GYR_CONF_GYR_RANGE_4G 0x0010
323 #define C6DOFIMU20_GYR_CONF_GYR_RANGE_8G 0x0020
324 #define C6DOFIMU20_GYR_CONF_GYR_RANGE_16G 0x0030
325 #define C6DOFIMU20_GYR_CONF_GYR_BW_DIV_2 0x0000
326 #define C6DOFIMU20_GYR_CONF_GYR_BW_DIV_4 0x0080
327 #define C6DOFIMU20_GYR_CONF_GYR_AVG_NUM_0 0x0000
328 #define C6DOFIMU20_GYR_CONF_GYR_AVG_NUM_2 0x0100
329 #define C6DOFIMU20_GYR_CONF_GYR_AVG_NUM_4 0x0200
330 #define C6DOFIMU20_GYR_CONF_GYR_AVG_NUM_8 0x0300
331 #define C6DOFIMU20_GYR_CONF_GYR_AVG_NUM_16 0x0400
332 #define C6DOFIMU20_GYR_CONF_GYR_AVG_NUM_32 0x0500
333 #define C6DOFIMU20_GYR_CONF_GYR_AVG_NUM_64 0x0600
334 #define C6DOFIMU20_GYR_CONF_GYR_MODE_DIS 0x0000
335 #define C6DOFIMU20_GYR_CONF_GYR_MODE_DUTY_CYCLING 0x3000
336 #define C6DOFIMU20_GYR_CONF_GYR_MODE_CONSTANT_OPERATION 0x4000
337 #define C6DOFIMU20_GYR_CONF_GYR_MODE_HIGH_PERFORMANCE 0x7000
338 
343 #define C6DOFIMU20_IO_INT_CTRL_INT1_LVL_ACTIVE_HIGH 0x0001
344 #define C6DOFIMU20_IO_INT_CTRL_INT1_LVL_ACTIVE_LOW 0x0000
345 #define C6DOFIMU20_IO_INT_CTRL_INT1_OUTPUT_PUSH_PULL 0x0000
346 #define C6DOFIMU20_IO_INT_CTRL_INT1_OUTPUT_OPEN_DRAIN 0x0002
347 #define C6DOFIMU20_IO_INT_CTRL_INT1_OUTPUT_EN 0x0004
348 #define C6DOFIMU20_IO_INT_CTRL_INT2_LVL_ACTIVE_HIGH 0x0100
349 #define C6DOFIMU20_IO_INT_CTRL_INT2_LVL_ACTIVE_LOW 0x0000
350 #define C6DOFIMU20_IO_INT_CTRL_INT2_OUTPUT_PUSH_PULL 0x0000
351 #define C6DOFIMU20_IO_INT_CTRL_INT2_OUTPUT_OPEN_DRAIN 0x0200
352 #define C6DOFIMU20_IO_INT_CTRL_INT2_OUTPUT_EN 0x0400
353 
358 #define C6DOFIMU20_INT_CONF_INT_LATCH_EN 0x0001
359 #define C6DOFIMU20_INT_CONF_INT_LATCH_DIS 0x0000
360 
365 #define C6DOFIMU20_INT_MAP1_NO_MOTION_OUT_DIS 0x0000
366 #define C6DOFIMU20_INT_MAP1_NO_MOTION_OUT_INT1 0x0001
367 #define C6DOFIMU20_INT_MAP1_NO_MOTION_OUT_INT2 0x0002
368 #define C6DOFIMU20_INT_MAP1_ANY_MOTION_OUT_DIS 0x0000
369 #define C6DOFIMU20_INT_MAP1_ANY_MOTION_OUT_INT1 0x0004
370 #define C6DOFIMU20_INT_MAP1_ANY_MOTION_OUT_INT2 0x0008
371 #define C6DOFIMU20_INT_MAP1_FLAT_OUT_DIS 0x0000
372 #define C6DOFIMU20_INT_MAP1_FLAT_OUT_INT1 0x0010
373 #define C6DOFIMU20_INT_MAP1_FLAT_OUT_INT2 0x0020
374 #define C6DOFIMU20_INT_MAP1_ORIENTATION_OUT_DIS 0x0000
375 #define C6DOFIMU20_INT_MAP1_ORIENTATION_OUT_INT1 0x0040
376 #define C6DOFIMU20_INT_MAP1_ORIENTATION_OUT_INT2 0x0080
377 #define C6DOFIMU20_INT_MAP1_STEP_DETECTOR_OUT_DIS 0x0000
378 #define C6DOFIMU20_INT_MAP1_STEP_DETECTOR_OUT_INT1 0x0100
379 #define C6DOFIMU20_INT_MAP1_STEP_DETECTOR_OUT_INT2 0x0200
380 #define C6DOFIMU20_INT_MAP1_STEP_COUNTER_OUT_DIS 0x0000
381 #define C6DOFIMU20_INT_MAP1_STEP_COUNTER_OUT_INT1 0x0400
382 #define C6DOFIMU20_INT_MAP1_STEP_COUNTER_OUT_INT2 0x0800
383 #define C6DOFIMU20_INT_MAP1_SIG_MOTION_OUT_DIS 0x0000
384 #define C6DOFIMU20_INT_MAP1_SIG_MOTION_OUT_INT1 0x1000
385 #define C6DOFIMU20_INT_MAP1_SIG_MOTION_OUT_INT2 0x2000
386 #define C6DOFIMU20_INT_MAP1_TILT_OUT_DIS 0x0000
387 #define C6DOFIMU20_INT_MAP1_TILT_OUT_INT1 0x4000
388 #define C6DOFIMU20_INT_MAP1_TILT_OUT_INT2 0x8000
389 
394 #define C6DOFIMU20_INT_MAP2_TAP_OUT_OUT_DIS 0x0000
395 #define C6DOFIMU20_INT_MAP2_TAP_OUT_OUT_INT1 0x0001
396 #define C6DOFIMU20_INT_MAP2_TAP_OUT_OUT_INT2 0x0002
397 #define C6DOFIMU20_INT_MAP2_ERR_STATUS_DIS 0x0000
398 #define C6DOFIMU20_INT_MAP2_ERR_STATUS_INT1 0x0010
399 #define C6DOFIMU20_INT_MAP2_ERR_STATUS_INT2 0x0020
400 #define C6DOFIMU20_INT_MAP2_TEMP_DRDY_INT_DIS 0x0000
401 #define C6DOFIMU20_INT_MAP2_TEMP_DRDY_INT_INT1 0x0040
402 #define C6DOFIMU20_INT_MAP2_TEMP_DRDY_INT_INT2 0x0080
403 #define C6DOFIMU20_INT_MAP2_GYR_DRDY_INT_DIS 0x0000
404 #define C6DOFIMU20_INT_MAP2_GYR_DRDY_INT_INT1 0x0100
405 #define C6DOFIMU20_INT_MAP2_GYR_DRDY_INT_INT2 0x0200
406 #define C6DOFIMU20_INT_MAP2_ACC_DRDY_INT_DIS 0x0000
407 #define C6DOFIMU20_INT_MAP2_ACC_DRDY_INT_INT1 0x0400
408 #define C6DOFIMU20_INT_MAP2_ACC_DRDY_INT_INT2 0x0800
409 #define C6DOFIMU20_INT_MAP2_FIFO_WATERMARK_INT_DIS 0x0000
410 #define C6DOFIMU20_INT_MAP2_FIFO_WATERMARK_INT_INT1 0x1000
411 #define C6DOFIMU20_INT_MAP2_FIFO_WATERMARK_INT_INT2 0x2000
412 #define C6DOFIMU20_INT_MAP2_FIFO_FULL_INT_DIS 0x0000
413 #define C6DOFIMU20_INT_MAP2_FIFO_FULL_INT_INT1 0x4000
414 #define C6DOFIMU20_INT_MAP2_FIFO_FULL_INT_INT2 0x8000
415 
421 #define C6DOFIMU20_TEMP_CALC_DIVIDER 512
422 #define C6DOFIMU20_TEMP_CALC_VALUE 23
423 
429 #define C6DOFIMU20_CHIP_ID 0x43
430 
436 #define C6DOFIMU20_DEVICE_ADDRESS_GND 0x68
437 #define C6DOFIMU20_DEVICE_ADDRESS_VCC 0x69
438 
447 #define C6DOFIMU20_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
448 #define C6DOFIMU20_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
449  // c6dofimu20_set
451 
466 #define C6DOFIMU20_MAP_MIKROBUS( cfg, mikrobus ) \
467  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
468  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
469  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
470  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
471  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
472  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
473  cfg.it1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
474  cfg.it2 = MIKROBUS( mikrobus, MIKROBUS_INT )
475  // c6dofimu20_map // c6dofimu20
478 
483 typedef enum
484 {
489 
494 typedef err_t ( *c6dofimu20_master_io_t )( struct c6dofimu20_s*, uint8_t, uint8_t*, uint8_t );
500 typedef struct c6dofimu20_s
501 {
502  digital_out_t cs;
504  digital_in_t it1;
505  digital_in_t it2;
507  i2c_master_t i2c;
508  spi_master_t spi;
510  uint8_t slave_address;
511  pin_name_t chip_select;
518 
523 typedef struct
524 {
525  pin_name_t scl;
526  pin_name_t sda;
527  pin_name_t miso;
528  pin_name_t mosi;
529  pin_name_t sck;
530  pin_name_t cs;
531  pin_name_t it1;
532  pin_name_t it2;
534  uint32_t i2c_speed;
535  uint8_t i2c_address;
537  uint32_t spi_speed;
538  spi_master_mode_t spi_mode;
539  spi_master_chip_select_polarity_t cs_polarity;
544 
549 typedef struct
550 {
551  int16_t data_x;
552  int16_t data_y;
553  int16_t data_z;
554 
556 
561 typedef enum
562 {
564  C6DOFIMU20_ERROR = -1
565 
567 
584 
600 
615 
629 
644 err_t c6dofimu20_generic_write ( c6dofimu20_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
645 
660 err_t c6dofimu20_generic_read ( c6dofimu20_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
661 
674 err_t c6dofimu20_set_reg ( c6dofimu20_t *ctx, uint8_t reg, uint16_t data_in );
675 
688 err_t c6dofimu20_get_reg ( c6dofimu20_t *ctx, uint8_t reg, uint16_t *data_out );
689 
701 err_t c6dofimu20_get_id ( c6dofimu20_t *ctx, uint8_t *chip_id );
702 
712 
722 
736 
750 
762 err_t c6dofimu20_get_temperature ( c6dofimu20_t *ctx, float *temp_data );
763 
775 
776 #ifdef __cplusplus
777 }
778 #endif
779 #endif // C6DOFIMU20_H
780  // c6dofimu20
782 
783 // ------------------------------------------------------------------------ END
c6dofimu20_cfg_t::mosi
pin_name_t mosi
Definition: c6dofimu20.h:528
c6dofimu20_get_reg
err_t c6dofimu20_get_reg(c6dofimu20_t *ctx, uint8_t reg, uint16_t *data_out)
6 DOF IMU 20 register data reading function.
c6dofimu20_generic_write
err_t c6dofimu20_generic_write(c6dofimu20_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
6 DOF IMU 20 data writing function.
c6dofimu20_generic_read
err_t c6dofimu20_generic_read(c6dofimu20_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
6 DOF IMU 20 data reading function.
c6dofimu20_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: c6dofimu20.h:539
c6dofimu20_cfg_t::miso
pin_name_t miso
Definition: c6dofimu20.h:527
c6dofimu20_set_reg
err_t c6dofimu20_set_reg(c6dofimu20_t *ctx, uint8_t reg, uint16_t data_in)
6 DOF IMU 20 register data writing function.
c6dofimu20_s::read_f
c6dofimu20_master_io_t read_f
Definition: c6dofimu20.h:515
c6dofimu20_data_t::data_z
int16_t data_z
Definition: c6dofimu20.h:553
c6dofimu20_cfg_t::i2c_address
uint8_t i2c_address
Definition: c6dofimu20.h:535
c6dofimu20_s::it1
digital_in_t it1
Definition: c6dofimu20.h:504
c6dofimu20_data_t::data_y
int16_t data_y
Definition: c6dofimu20.h:552
c6dofimu20_cfg_t::sck
pin_name_t sck
Definition: c6dofimu20.h:529
c6dofimu20_s::slave_address
uint8_t slave_address
Definition: c6dofimu20.h:510
C6DOFIMU20_DRV_SEL_SPI
@ C6DOFIMU20_DRV_SEL_SPI
Definition: c6dofimu20.h:485
spi_specifics.h
This file contains SPI specific macros, functions, etc.
c6dofimu20_return_value_t
c6dofimu20_return_value_t
6 DOF IMU 20 Click return value data.
Definition: c6dofimu20.h:562
c6dofimu20_cfg_t
6 DOF IMU 20 Click configuration object.
Definition: c6dofimu20.h:524
c6dofimu20_default_cfg
err_t c6dofimu20_default_cfg(c6dofimu20_t *ctx)
6 DOF IMU 20 default configuration function.
c6dofimu20_master_io_t
err_t(* c6dofimu20_master_io_t)(struct c6dofimu20_s *, uint8_t, uint8_t *, uint8_t)
6 DOF IMU 20 Click driver interface.
Definition: c6dofimu20.h:494
c6dofimu20_s::drv_sel
c6dofimu20_drv_t drv_sel
Definition: c6dofimu20.h:512
c6dofimu20_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: c6dofimu20.h:534
c6dofimu20_data_t
6 DOF IMU 20 Click data object.
Definition: c6dofimu20.h:550
C6DOFIMU20_ERROR
@ C6DOFIMU20_ERROR
Definition: c6dofimu20.h:564
c6dofimu20_init
err_t c6dofimu20_init(c6dofimu20_t *ctx, c6dofimu20_cfg_t *cfg)
6 DOF IMU 20 initialization function.
c6dofimu20_s::write_f
c6dofimu20_master_io_t write_f
Definition: c6dofimu20.h:514
c6dofimu20_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: c6dofimu20.h:538
c6dofimu20_cfg_t::scl
pin_name_t scl
Definition: c6dofimu20.h:525
C6DOFIMU20_OK
@ C6DOFIMU20_OK
Definition: c6dofimu20.h:563
c6dofimu20_cfg_t::it2
pin_name_t it2
Definition: c6dofimu20.h:532
c6dofimu20_drv_interface_selection
void c6dofimu20_drv_interface_selection(c6dofimu20_cfg_t *cfg, c6dofimu20_drv_t drv_sel)
6 DOF IMU 20 driver interface setup function.
c6dofimu20_get_gyr_data
err_t c6dofimu20_get_gyr_data(c6dofimu20_t *ctx, c6dofimu20_data_t *gyr_data)
6 DOF IMU 20 gyro data reading function.
C6DOFIMU20_DRV_SEL_I2C
@ C6DOFIMU20_DRV_SEL_I2C
Definition: c6dofimu20.h:486
c6dofimu20_get_int2_state
uint8_t c6dofimu20_get_int2_state(c6dofimu20_t *ctx)
6 DOF IMU 20 IT2 state reading function.
c6dofimu20_s
6 DOF IMU 20 Click context object.
Definition: c6dofimu20.h:501
c6dofimu20_cfg_setup
void c6dofimu20_cfg_setup(c6dofimu20_cfg_t *cfg)
6 DOF IMU 20 configuration object setup function.
c6dofimu20_cfg_t::it1
pin_name_t it1
Definition: c6dofimu20.h:531
c6dofimu20_s::cs
digital_out_t cs
Definition: c6dofimu20.h:502
c6dofimu20_s::chip_select
pin_name_t chip_select
Definition: c6dofimu20.h:511
c6dofimu20_t
struct c6dofimu20_s c6dofimu20_t
6 DOF IMU 20 Click context object.
c6dofimu20_get_id
err_t c6dofimu20_get_id(c6dofimu20_t *ctx, uint8_t *chip_id)
6 DOF IMU 20 register chip id reading function.
c6dofimu20_data_t::data_x
int16_t data_x
Definition: c6dofimu20.h:551
c6dofimu20_get_acc_data
err_t c6dofimu20_get_acc_data(c6dofimu20_t *ctx, c6dofimu20_data_t *acc_data)
6 DOF IMU 20 accel data reading function.
c6dofimu20_get_temperature
err_t c6dofimu20_get_temperature(c6dofimu20_t *ctx, float *temp_data)
6 DOF IMU 20 temperature reading function.
c6dofimu20_sw_reset
err_t c6dofimu20_sw_reset(c6dofimu20_t *ctx)
6 DOF IMU 20 software reset function.
c6dofimu20_drv_t
c6dofimu20_drv_t
6 DOF IMU 20 Click driver selector.
Definition: c6dofimu20.h:484
c6dofimu20_s::i2c
i2c_master_t i2c
Definition: c6dofimu20.h:507
c6dofimu20_cfg_t::spi_speed
uint32_t spi_speed
Definition: c6dofimu20.h:537
c6dofimu20_s::it2
digital_in_t it2
Definition: c6dofimu20.h:505
c6dofimu20_cfg_t::cs
pin_name_t cs
Definition: c6dofimu20.h:530
c6dofimu20_s::spi
spi_master_t spi
Definition: c6dofimu20.h:508
c6dofimu20_cfg_t::sda
pin_name_t sda
Definition: c6dofimu20.h:526
c6dofimu20_get_int1_state
uint8_t c6dofimu20_get_int1_state(c6dofimu20_t *ctx)
6 DOF IMU 20 IT1 state reading function.
c6dofimu20_cfg_t::drv_sel
c6dofimu20_drv_t drv_sel
Definition: c6dofimu20.h:541