c6dofimu11  2.0.0.0
c6dofimu11.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef C6DOFIMU11_H
36 #define C6DOFIMU11_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
62 #define C6DOFIMU11_MAP_MIKROBUS( cfg, mikrobus ) \
63  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
64  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
65  cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
66  cfg.gp2 = MIKROBUS( mikrobus, MIKROBUS_INT )
67 
73 #define C6DOFIMU11_RETVAL uint8_t
74 
75 #define C6DOFIMU11_OK 0x00
76 #define C6DOFIMU11_INIT_ERROR 0xFF
77 
83 #define C6DOFIMU11_I2C_SLAVE_ADDRESS_GND 0x0E
84 #define C6DOFIMU11_I2C_SLAVE_ADDRESS_VCC 0x0F
85 
92 #define C6DOFIMU11_WHO_AM_I 0x00
93 #define C6DOFIMU11_INS1 0x01
94 #define C6DOFIMU11_INS2 0x02
95 #define C6DOFIMU11_INS3 0x03
96 #define C6DOFIMU11_INL 0x05
97 #define C6DOFIMU11_ACCEL_XOUT_L 0x0A
98 #define C6DOFIMU11_ACCEL_XOUT_H 0x0B
99 #define C6DOFIMU11_ACCEL_YOUT_L 0x0C
100 #define C6DOFIMU11_ACCEL_YOUT_H 0x0D
101 #define C6DOFIMU11_ACCEL_ZOUT_L 0x0E
102 #define C6DOFIMU11_ACCEL_ZOUT_H 0x0F
103 #define C6DOFIMU11_MAG_XOUT_L 0x10
104 #define C6DOFIMU11_MAG_XOUT_H 0x11
105 #define C6DOFIMU11_MAG_YOUT_L 0x12
106 #define C6DOFIMU11_MAG_YOUT_H 0x13
107 #define C6DOFIMU11_MAG_ZOUT_L 0x14
108 #define C6DOFIMU11_MAG_ZOUT_H 0x15
109 #define C6DOFIMU11_TEMP_OUT_L 0x16
110 #define C6DOFIMU11_TEMP_OUT_H 0x17
111 #define C6DOFIMU11_INC1 0x2A
112 #define C6DOFIMU11_INC2 0x2B
113 #define C6DOFIMU11_INC3 0x2C
114 #define C6DOFIMU11_INC4 0x2D
115 #define C6DOFIMU11_INC5 0x2E
116 #define C6DOFIMU11_AMI_CNTL1 0x2F
117 #define C6DOFIMU11_AMI_CNTL2 0x30
118 #define C6DOFIMU11_AMI_CNTL3 0x31
119 #define C6DOFIMU11_MMI_CNTL1 0x32
120 #define C6DOFIMU11_MMI_CNTL2 0x33
121 #define C6DOFIMU11_MMI_CNTL3 0x34
122 #define C6DOFIMU11_FFI_CNTL1 0x35
123 #define C6DOFIMU11_FFI_CNTL2 0x36
124 #define C6DOFIMU11_FFI_CNTL3 0x37
125 #define C6DOFIMU11_ODCNTL 0x38
126 #define C6DOFIMU11_CNTL1 0x39
127 #define C6DOFIMU11_CNTL2 0x3A
128 #define C6DOFIMU11_COTR 0x3C
129 #define C6DOFIMU11_BUF_CTRL_1 0x77
130 #define C6DOFIMU11_BUF_CTRL_2 0x78
131 #define C6DOFIMU11_BUF_CTRL_3 0x79
132 #define C6DOFIMU11_BUF_CLEAR 0x7A
133 #define C6DOFIMU11_BUF_STATUS_1 0x7B
134 #define C6DOFIMU11_BUF_STATUS_2 0x7C
135 #define C6DOFIMU11_BUF_STATUS_3 0x7D
136 #define C6DOFIMU11_BUF_READ 0x7E
137 
144 #define C6DOFIMU11_WHO_AM_I_WIA_ID 0x2D
145 #define C6DOFIMU11_INS1_INT_NO_INT 0x00
146 #define C6DOFIMU11_INS1_INT_INT 0x80
147 #define C6DOFIMU11_INS1_BFI_BUFF_NOT_FULL 0x00
148 #define C6DOFIMU11_INS1_BFI_BUFF_FULL 0x40
149 #define C6DOFIMU11_INS1_WMI_MARK_NOT_REACHED 0x00
150 #define C6DOFIMU11_INS1_WMI_MARK_REACHED 0x20
151 #define C6DOFIMU11_INS1_DRDY_A_NOT_AVAILABLE 0x00
152 #define C6DOFIMU11_INS1_DRDY_A_AVAILABLE 0x10
153 #define C6DOFIMU11_INS1_DRDY_M_NOT_AVAILABLE 0x00
154 #define C6DOFIMU11_INS1_DRDY_M_AVAILABLE 0x08
155 #define C6DOFIMU11_INS1_FFI_NO_FFI 0x00
156 #define C6DOFIMU11_INS1_FFI_FFI 0x04
157 #define C6DOFIMU11_INS1_AMI_NO_MOTION 0x00
158 #define C6DOFIMU11_INS1_AMI_MOTION 0x02
159 #define C6DOFIMU11_INS1_MMI_NO_MOTION 0x00
160 #define C6DOFIMU11_INS1_MMI_MOTION 0x01
161 #define C6DOFIMU11_INS2_AXNI 0x20
162 #define C6DOFIMU11_INS2_AXPI 0x10
163 #define C6DOFIMU11_INS2_AYNI 0x08
164 #define C6DOFIMU11_INS2_AYPI 0x04
165 #define C6DOFIMU11_INS2_AZNI 0x02
166 #define C6DOFIMU11_INS2_AZPI 0x01
167 #define C6DOFIMU11_INS3_MXNI 0x20
168 #define C6DOFIMU11_INS3_MXPI 0x10
169 #define C6DOFIMU11_INS3_MYNI 0x08
170 #define C6DOFIMU11_INS3_MYPI 0x04
171 #define C6DOFIMU11_INS3_MZNI 0x02
172 #define C6DOFIMU11_INS3_MZPI 0x01
173 #define C6DOFIMU11_INC1_BFI1 0x40
174 #define C6DOFIMU11_INC1_WMI1 0x20
175 #define C6DOFIMU11_INC1_DRDY_A1 0x10
176 #define C6DOFIMU11_INC1_DRDY_M1 0x08
177 #define C6DOFIMU11_INC1_FFI1 0x04
178 #define C6DOFIMU11_INC1_AMI1 0x02
179 #define C6DOFIMU11_INC1_MMI1 0x01
180 #define C6DOFIMU11_INC2_BFI2 0x40
181 #define C6DOFIMU11_INC2_WMI2 0x20
182 #define C6DOFIMU11_INC2_DRDY_A2 0x10
183 #define C6DOFIMU11_INC2_DRDY_M2 0x08
184 #define C6DOFIMU11_INC2_FFI2 0x04
185 #define C6DOFIMU11_INC2_AMI2 0x02
186 #define C6DOFIMU11_INC2_MMI2 0x01
187 #define C6DOFIMU11_INC3_IED2_PUSHPULL 0x00
188 #define C6DOFIMU11_INC3_IED2_OPENDRAIN 0x80
189 #define C6DOFIMU11_INC3_IEA2_LOW 0x00
190 #define C6DOFIMU11_INC3_IEA2_HIGH 0x40
191 #define C6DOFIMU11_INC3_IEL2_LATCHED 0x00
192 #define C6DOFIMU11_INC3_IEL2_PULSED 0x10
193 #define C6DOFIMU11_INC3_IEL2_FIFO_TRIG 0x20
194 #define C6DOFIMU11_INC3_IEL2_FIFO_TRIG_2 0x30
195 #define C6DOFIMU11_INC3_IED1_PUSHPULL 0x00
196 #define C6DOFIMU11_INC3_IED1_OPENDRAIN 0x08
197 #define C6DOFIMU11_INC3_IEA1_LOW 0x00
198 #define C6DOFIMU11_INC3_IEA1_HIGH 0x04
199 #define C6DOFIMU11_INC3_IEL1_LATCHED 0x00
200 #define C6DOFIMU11_INC3_IEL1_PULSED 0x01
201 #define C6DOFIMU11_INC3_IEL1_FIFO_TRIG 0x02
202 #define C6DOFIMU11_INC3_IEL1_FIFO_TRIG_2 0x03
203 #define C6DOFIMU11_INC4_AXNIE 0x20
204 #define C6DOFIMU11_INC4_AXPIE 0x10
205 #define C6DOFIMU11_INC4_AYNIE 0x08
206 #define C6DOFIMU11_INC4_AYPIE 0x04
207 #define C6DOFIMU11_INC4_AZNIE 0x02
208 #define C6DOFIMU11_INC4_AZPIE 0x01
209 #define C6DOFIMU11_INC5_MXNIE 0x20
210 #define C6DOFIMU11_INC5_MXPIE 0x10
211 #define C6DOFIMU11_INC5_MYNIE 0x08
212 #define C6DOFIMU11_INC5_MYPIE 0x04
213 #define C6DOFIMU11_INC5_MZNIE 0x02
214 #define C6DOFIMU11_INC5_MZPIE 0x01
215 #define C6DOFIMU11_AMI_CNTL3_AMI_EN_DISABLED 0x00
216 #define C6DOFIMU11_AMI_CNTL3_AMI_EN_ENABLED 0x80
217 #define C6DOFIMU11_AMI_CNTL3_AMIUL 0x40
218 #define C6DOFIMU11_AMI_CNTL3_OAMI_0P781 0x00
219 #define C6DOFIMU11_AMI_CNTL3_OAMI_1P563 0x01
220 #define C6DOFIMU11_AMI_CNTL3_OAMI_3P125 0x02
221 #define C6DOFIMU11_AMI_CNTL3_OAMI_6P25 0x03
222 #define C6DOFIMU11_AMI_CNTL3_OAMI_12P5 0x04
223 #define C6DOFIMU11_AMI_CNTL3_OAMI_25 0x05
224 #define C6DOFIMU11_AMI_CNTL3_OAMI_50 0x06
225 #define C6DOFIMU11_AMI_CNTL3_OAMI_100 0x07
226 #define C6DOFIMU11_MMI_CNTL3_MMI_EN_DISABLED 0x00
227 #define C6DOFIMU11_MMI_CNTL3_MMI_EN_ENABLED 0x80
228 #define C6DOFIMU11_MMI_CNTL3_MMIUL 0x40
229 #define C6DOFIMU11_MMI_CNTL3_OMMI_0P781 0x00
230 #define C6DOFIMU11_MMI_CNTL3_OMMI_1P563 0x01
231 #define C6DOFIMU11_MMI_CNTL3_OMMI_3P125 0x02
232 #define C6DOFIMU11_MMI_CNTL3_OMMI_6P25 0x03
233 #define C6DOFIMU11_MMI_CNTL3_OMMI_12P5 0x04
234 #define C6DOFIMU11_MMI_CNTL3_OMMI_25 0x05
235 #define C6DOFIMU11_MMI_CNTL3_OMMI_50 0x06
236 #define C6DOFIMU11_MMI_CNTL3_OMMI_100 0x07
237 #define C6DOFIMU11_FFI_CNTL3_FFI_EN_DISABLED 0x00
238 #define C6DOFIMU11_FFI_CNTL3_FFI_EN_ENABLED 0x80
239 #define C6DOFIMU11_FFI_CNTL3_FFIUL 0x40
240 #define C6DOFIMU11_FFI_CNTL3_DCRM 0x08
241 #define C6DOFIMU11_FFI_CNTL3_OFFI_12P5 0x00
242 #define C6DOFIMU11_FFI_CNTL3_OFFI_25 0x01
243 #define C6DOFIMU11_FFI_CNTL3_OFFI_50 0x02
244 #define C6DOFIMU11_FFI_CNTL3_OFFI_100 0x03
245 #define C6DOFIMU11_FFI_CNTL3_OFFI_200 0x04
246 #define C6DOFIMU11_FFI_CNTL3_OFFI_400 0x05
247 #define C6DOFIMU11_FFI_CNTL3_OFFI_800 0x06
248 #define C6DOFIMU11_FFI_CNTL3_OFFI_1600 0x07
249 #define C6DOFIMU11_ODCNTL_OSA_12P5 0x00
250 #define C6DOFIMU11_ODCNTL_OSA_25 0x01
251 #define C6DOFIMU11_ODCNTL_OSA_50 0x02
252 #define C6DOFIMU11_ODCNTL_OSA_100 0x03
253 #define C6DOFIMU11_ODCNTL_OSA_200 0x04
254 #define C6DOFIMU11_ODCNTL_OSA_400 0x05
255 #define C6DOFIMU11_ODCNTL_OSA_800 0x06
256 #define C6DOFIMU11_ODCNTL_OSA_1600 0x07
257 #define C6DOFIMU11_ODCNTL_OSA_0P781 0x08
258 #define C6DOFIMU11_ODCNTL_OSA_1P563 0x09
259 #define C6DOFIMU11_ODCNTL_OSA_3P125 0x0A
260 #define C6DOFIMU11_ODCNTL_OSA_6P25 0x0B
261 #define C6DOFIMU11_ODCNTL_OSA_25600ST0P8 0x0C
262 #define C6DOFIMU11_ODCNTL_OSA_25600ST1P6 0x0D
263 #define C6DOFIMU11_ODCNTL_OSA_25600ST3P2 0x0E
264 #define C6DOFIMU11_ODCNTL_OSA_25600 0x0F
265 #define C6DOFIMU11_ODCNTL_OSM_12P5 0x00
266 #define C6DOFIMU11_ODCNTL_OSM_25 0x10
267 #define C6DOFIMU11_ODCNTL_OSM_50 0x20
268 #define C6DOFIMU11_ODCNTL_OSM_100 0x30
269 #define C6DOFIMU11_ODCNTL_OSM_200 0x40
270 #define C6DOFIMU11_ODCNTL_OSM_400 0x50
271 #define C6DOFIMU11_ODCNTL_OSM_800 0x60
272 #define C6DOFIMU11_ODCNTL_OSM_1600 0x70
273 #define C6DOFIMU11_ODCNTL_OSM_0P781 0x80
274 #define C6DOFIMU11_ODCNTL_OSM_1P563 0x90
275 #define C6DOFIMU11_ODCNTL_OSM_3P125 0xA0
276 #define C6DOFIMU11_ODCNTL_OSM_6P25 0xB0
277 #define C6DOFIMU11_ODCNTL_OSM_12800A 0xC0
278 #define C6DOFIMU11_ODCNTL_OSM_12800B 0xD0
279 #define C6DOFIMU11_ODCNTL_OSM_12800C 0xE0
280 #define C6DOFIMU11_ODCNTL_OSM_12800 0xF0
281 #define C6DOFIMU11_CNTL1_SRST 0x80
282 #define C6DOFIMU11_CNTL1_STEN_DISABLED 0x00
283 #define C6DOFIMU11_CNTL1_STEN_ENABLED 0x40
284 #define C6DOFIMU11_CNTL1_STPOL 0x20
285 #define C6DOFIMU11_CNTL1_COTC 0x08
286 
292 #define C6DOFIMU11_CNTL2_TEMP_EN_STANDBY_MODE 0x00
293 #define C6DOFIMU11_CNTL2_TEMPERATURE_DISABLE 0x00
294 #define C6DOFIMU11_CNTL2_TEMPERATURE_ENABLE 0x01
295 #define C6DOFIMU11_CNTL2_TEMP_EN_OPERATING_MODE 0x40
296 #define C6DOFIMU11_CNTL2_GSEL_8G 0x00
297 #define C6DOFIMU11_CNTL2_GSEL_16G 0x10
298 #define C6DOFIMU11_CNTL2_GSEL_32G 0x20
299 #define C6DOFIMU11_CNTL2_GSEL_64G 0x30
300 #define C6DOFIMU11_CNTL2_RES_A4M2 0x00
301 #define C6DOFIMU11_CNTL2_RES_A32M16 0x04
302 #define C6DOFIMU11_CNTL2_RES_MAX1 0x08
303 #define C6DOFIMU11_CNTL2_RES_MAX2 0x0C
304 #define C6DOFIMU11_CNTL2_MAG_DISABLE 0x00
305 #define C6DOFIMU11_CNTL2_MAG_ENABLE 0x01
306 #define C6DOFIMU11_CNTL2_MAG_EN_STANDBY_MODE 0x00
307 #define C6DOFIMU11_CNTL2_MAG_EN_OPERATING_MODE 0x02
308 #define C6DOFIMU11_CNTL2_ACCEL_EN_STANDBY_MODE 0x00
309 #define C6DOFIMU11_CNTL2_ACCEL_EN_OPERATING_MODE 0x01
310 #define C6DOFIMU11_CNTL2_ACCEL_DISABLE 0x00
311 #define C6DOFIMU11_CNTL2_ACCEL_ENABLE 0x01
312 #define C6DOFIMU11_COTR_TEST_RESP_DEFAULT 0x55
313 #define C6DOFIMU11_COTR_TEST_RESP_TEST 0xAA
314 #define C6DOFIMU11_BUF_CTRL_2_BUF_M_FIFO 0x00
315 #define C6DOFIMU11_BUF_CTRL_2_BUF_M_STREAM 0x02
316 #define C6DOFIMU11_BUF_CTRL_2_BUF_M_TRIGGER 0x04
317 #define C6DOFIMU11_BUF_CTRL_2_BUF_M_FILO 0x03
318 #define C6DOFIMU11_BUF_CTRL_2_SMT_TH8 0x01
319 #define C6DOFIMU11_BUF_CTRL_3_BFI_EN_DISABLED 0x00
320 #define C6DOFIMU11_BUF_CTRL_3_BFI_EN_ENABLED 0x80
321 #define C6DOFIMU11_BUF_CTRL_3_BUF_AX_DISABLED 0x00
322 #define C6DOFIMU11_BUF_CTRL_3_BUF_AX_ENABLED 0x40
323 #define C6DOFIMU11_BUF_CTRL_3_BUF_AY_DISABLED 0x00
324 #define C6DOFIMU11_BUF_CTRL_3_BUF_AY_ENABLED 0x20
325 #define C6DOFIMU11_BUF_CTRL_3_BUF_AZ_DISABLED 0x00
326 #define C6DOFIMU11_BUF_CTRL_3_BUF_AZ_ENABLED 0x10
327 #define C6DOFIMU11_BUF_CTRL_3_BUF_MX_DISABLED 0x00
328 #define C6DOFIMU11_BUF_CTRL_3_BUF_MX_ENABLED 0x08
329 #define C6DOFIMU11_BUF_CTRL_3_BUF_MY_DISABLED 0x00
330 #define C6DOFIMU11_BUF_CTRL_3_BUF_MY_ENABLED 0x04
331 #define C6DOFIMU11_BUF_CTRL_3_BUF_MZ_DISABLED 0x00
332 #define C6DOFIMU11_BUF_CTRL_3_BUF_MZ_ENABLED 0x02
333 #define C6DOFIMU11_BUF_CTRL_3_BUF_TEMP_DISABLED 0x00
334 #define C6DOFIMU11_BUF_CTRL_3_BUF_TEMP_ENABLED 0x01
335 #define C6DOFIMU11_BUF_STATUS_2_BUF_TRIG 0x02
336 #define C6DOFIMU11_BUF_STATUS_2_SMP_LEV_H 0x01
337 #define C6DOFIMU11_WHO_AM_I_WIA_MASK 0xFF
338 #define C6DOFIMU11_INS1_INT_MASK 0x80
339 #define C6DOFIMU11_INS1_BFI_MASK 0x40
340 #define C6DOFIMU11_INS1_WMI_MASK 0x20
341 #define C6DOFIMU11_INS1_DRDY_A_MASK 0x10
342 #define C6DOFIMU11_INS1_DRDY_M_MASK 0x08
343 #define C6DOFIMU11_INS1_FFI_MASK 0x04
344 #define C6DOFIMU11_INS1_AMI_MASK 0x02
345 
346 #define C6DOFIMU11_INS1_MMI_MASK 0x01
347 #define C6DOFIMU11_INC3_IED2_MASK 0x80
348 #define C6DOFIMU11_INC3_IEA2_MASK 0x40
349 #define C6DOFIMU11_INC3_IEL2_MASK 0x30
350 #define C6DOFIMU11_INC3_IED1_MASK 0x08
351 #define C6DOFIMU11_INC3_IEA1_MASK 0x04
352 #define C6DOFIMU11_INC3_IEL1_MASK 0x03
353 
354 #define C6DOFIMU11_AMI_CNTL3_AMI_EN_MASK 0x80
355 #define C6DOFIMU11_AMI_CNTL3_OAMI_MASK 0x07
356 
357 #define C6DOFIMU11_MMI_CNTL3_MMI_EN_MASK 0x80
358 #define C6DOFIMU11_MMI_CNTL3_OMMI_MASK 0x07
359 
360 #define C6DOFIMU11_FFI_CNTL3_FFI_EN_MASK 0x80
361 #define C6DOFIMU11_FFI_CNTL3_OFFI_MASK 0x07
362 
363 #define C6DOFIMU11_ODCNTL_OSA_MASK 0x0F
364 
365 #define C6DOFIMU11_ODCNTL_OSM_MASK 0xF0
366 #define C6DOFIMU11_CNTL1_STEN_MASK 0x40
367 #define C6DOFIMU11_CNTL2_TEMP_EN_MASK 0x40
368 
369 #define C6DOFIMU11_CNTL2_GSEL_MASK 0x30
370 #define C6DOFIMU11_CNTL2_RES_MASK 0x0C
371 #define C6DOFIMU11_CNTL2_MAG_EN_MASK 0x02
372 #define C6DOFIMU11_CNTL2_ACCEL_EN_MASK 0x01
373 #define C6DOFIMU11_COTR_TEST_RESP_MASK 0xFF
374 #define C6DOFIMU11_BUF_CTRL_1_SMT_TH_MASK 0xFF
375 #define C6DOFIMU11_BUF_CTRL_2_BUF_M_MASK 0x06
376 
382 #define C6DOFIMU11_BUF_CTRL_3_BFI_EN_MASK 0x80
383 #define C6DOFIMU11_BUF_CTRL_3_BUF_AX_MASK 0x40
384 #define C6DOFIMU11_BUF_CTRL_3_BUF_AY_MASK 0x20
385 #define C6DOFIMU11_BUF_CTRL_3_BUF_AZ_MASK 0x10
386 #define C6DOFIMU11_BUF_CTRL_3_BUF_MX_MASK 0x08
387 #define C6DOFIMU11_BUF_CTRL_3_BUF_MY_MASK 0x04
388 #define C6DOFIMU11_BUF_CTRL_3_BUF_MZ_MASK 0x02
389 #define C6DOFIMU11_BUF_CTRL_3_BUF_TEMP_MASK 0x01
390 #define C6DOFIMU11_BUF_STATUS_1_SMP_LEV_MASK 0xFF
391 #define C6DOFIMU11_BUF_STATUS_2_SMP_PAST_MASK 0xFF
392 #define C6DOFIMU11_BUF_STATUS_3_SMP_PAST_H_MASK 0xFF
393 
394 #define C6DOFIMU11_CHECK_ID_ERROR 0x00
395 #define C6DOFIMU11_CHECK_ID_SUCCESS 0x01
396 
397 #define C6DOFIMU11_ACCEL_COEF_RES_8G 0.00183111052
398 #define C6DOFIMU11_ACCEL_COEF_RES_16G 0.00732444210
399 #define C6DOFIMU11_ACCEL_COEF_RES_32G 0.02929776840
400 #define C6DOFIMU11_ACCEL_COEF_RES_64G 0.11255815032
401 #define C6DOFIMU11_MAG_COEF 0.03662221137
402  // End group macro
405 // --------------------------------------------------------------- PUBLIC TYPES
416 typedef struct
417 {
418  // Output pins
419 
420  digital_out_t gp1;
421 
422  // Input pins
423 
424  digital_in_t gp2;
425 
426  // Modules
427 
428  i2c_master_t i2c;
429 
430  // ctx variable
431 
432  uint8_t slave_address;
433 
434 } c6dofimu11_t;
435 
439 typedef struct
440 {
441  // Communication gpio pins
442 
443  pin_name_t scl;
444  pin_name_t sda;
445 
446  // Additional gpio pins
447 
448  pin_name_t gp1;
449  pin_name_t gp2;
450 
451  // static variable
452 
453  uint32_t i2c_speed;
454  uint8_t i2c_address;
455 
457 
461 typedef struct
462 {
463  float x;
464  float y;
465  float z;
466 }
468 
472 typedef struct
473 {
474  float x;
475  float y;
476  float z;
477 }
479 
480 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
481 
487 #ifdef __cplusplus
488 extern "C"{
489 #endif
490 
500 
510 
519 
530 void c6dofimu11_generic_write ( c6dofimu11_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
531 
542 void c6dofimu11_generic_read ( c6dofimu11_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
543 
553 void c6dofimu11_write_byte ( c6dofimu11_t *ctx, uint8_t reg_address, uint8_t write_data );
554 
563 uint8_t c6dofimu11_read_byte ( c6dofimu11_t *ctx, uint8_t reg_address );
564 
575 void c6dofimu11_write_multiple_bytes ( c6dofimu11_t *ctx, uint8_t reg_address, uint8_t *p_write_data, uint8_t n_bytes );
576 
587 void c6dofimu11_read_multiple_bytes ( c6dofimu11_t *ctx, uint8_t reg_address, uint8_t *p_read_data, uint8_t n_bytes );
588 
597 
606 
617 void c6dofimu11_enable_sensor ( c6dofimu11_t *ctx, uint8_t en_accel, uint8_t en_mag, uint8_t en_temp );
618 
629 void c6dofimu11_config_accel ( c6dofimu11_t *ctx, uint8_t data_rate, uint8_t data_range, uint8_t data_resolution );
630 
631 
641 void c6dofimu11_config_mag ( c6dofimu11_t *ctx, uint8_t data_rate, uint8_t data_resolution );
642 
651 int16_t c6dofimu11_get_axis ( c6dofimu11_t *ctx, uint8_t reg_add_lsb );
652 
663 void c6dofimu11_get_accel_data ( c6dofimu11_t *ctx, int16_t *accel_x, int16_t *accel_y, int16_t *accel_z );
664 
675 void c6dofimu11_get_mag_data ( c6dofimu11_t *ctx, int16_t *mag_x, int16_t *mag_y, int16_t *mag_z );
676 
686 
687 
697 
706 
715 
724 
725 
726 #ifdef __cplusplus
727 }
728 #endif
729 #endif // _C6DOFIMU11_H_
730  // End public_function group
733 
734 // ------------------------------------------------------------------------- END
c6dofimu11_init
C6DOFIMU11_RETVAL c6dofimu11_init(c6dofimu11_t *ctx, c6dofimu11_cfg_t *cfg)
Initialization function.
c6dofimu11_cfg_t::sda
pin_name_t sda
Definition: c6dofimu11.h:444
c6dofimu11_mag_t::x
float x
Definition: c6dofimu11.h:474
c6dofimu11_cfg_t::scl
pin_name_t scl
Definition: c6dofimu11.h:443
c6dofimu11_mag_t
Mag axis structure definition.
Definition: c6dofimu11.h:473
c6dofimu11_write_multiple_bytes
void c6dofimu11_write_multiple_bytes(c6dofimu11_t *ctx, uint8_t reg_address, uint8_t *p_write_data, uint8_t n_bytes)
This function write multiple bytes.
c6dofimu11_read_mag
void c6dofimu11_read_mag(c6dofimu11_t *ctx, c6dofimu11_mag_t *mag_data)
Read mag.
c6dofimu11_disable_sensor
void c6dofimu11_disable_sensor(c6dofimu11_t *ctx)
Disable sensor.
c6dofimu11_read_accel
void c6dofimu11_read_accel(c6dofimu11_t *ctx, c6dofimu11_accel_t *accel_data)
Read accel.
c6dofimu11_t::i2c
i2c_master_t i2c
Definition: c6dofimu11.h:428
c6dofimu11_accel_t::x
float x
Definition: c6dofimu11.h:463
c6dofimu11_accel_t
Accel axis structure definition.
Definition: c6dofimu11.h:462
c6dofimu11_cfg_t
Click configuration structure definition.
Definition: c6dofimu11.h:440
c6dofimu11_cfg_t::gp2
pin_name_t gp2
Definition: c6dofimu11.h:449
c6dofimu11_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: c6dofimu11.h:453
c6dofimu11_t::slave_address
uint8_t slave_address
Definition: c6dofimu11.h:432
c6dofimu11_mag_t::z
float z
Definition: c6dofimu11.h:476
c6dofimu11_config_mag
void c6dofimu11_config_mag(c6dofimu11_t *ctx, uint8_t data_rate, uint8_t data_resolution)
Configuration map.
c6dofimu11_accel_t::y
float y
Definition: c6dofimu11.h:464
c6dofimu11_enable_sensor
void c6dofimu11_enable_sensor(c6dofimu11_t *ctx, uint8_t en_accel, uint8_t en_mag, uint8_t en_temp)
Enable sensor.
c6dofimu11_generic_read
void c6dofimu11_generic_read(c6dofimu11_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
c6dofimu11_mag_t::y
float y
Definition: c6dofimu11.h:475
c6dofimu11_t::gp1
digital_out_t gp1
Definition: c6dofimu11.h:420
c6dofimu11_check_id
uint8_t c6dofimu11_check_id(c6dofimu11_t *ctx)
This function check id.
c6dofimu11_read_byte
uint8_t c6dofimu11_read_byte(c6dofimu11_t *ctx, uint8_t reg_address)
This function read byte.
c6dofimu11_get_interrupt
uint8_t c6dofimu11_get_interrupt(c6dofimu11_t *ctx)
Get interrupt.
c6dofimu11_t
Click ctx object definition.
Definition: c6dofimu11.h:417
c6dofimu11_cfg_t::i2c_address
uint8_t i2c_address
Definition: c6dofimu11.h:454
c6dofimu11_default_cfg
void c6dofimu11_default_cfg(c6dofimu11_t *ctx)
Click Default Configuration function.
c6dofimu11_config_accel
void c6dofimu11_config_accel(c6dofimu11_t *ctx, uint8_t data_rate, uint8_t data_range, uint8_t data_resolution)
Configuration accel.
c6dofimu11_get_accel_data
void c6dofimu11_get_accel_data(c6dofimu11_t *ctx, int16_t *accel_x, int16_t *accel_y, int16_t *accel_z)
Get accel data.
c6dofimu11_write_byte
void c6dofimu11_write_byte(c6dofimu11_t *ctx, uint8_t reg_address, uint8_t write_data)
This function write byte.
c6dofimu11_accel_t::z
float z
Definition: c6dofimu11.h:465
c6dofimu11_read_multiple_bytes
void c6dofimu11_read_multiple_bytes(c6dofimu11_t *ctx, uint8_t reg_address, uint8_t *p_read_data, uint8_t n_bytes)
This function read multiple bytes.
c6dofimu11_enable_temperature_data
void c6dofimu11_enable_temperature_data(c6dofimu11_t *ctx)
Enable temperature data.
c6dofimu11_get_axis
int16_t c6dofimu11_get_axis(c6dofimu11_t *ctx, uint8_t reg_add_lsb)
Get axis.
C6DOFIMU11_RETVAL
#define C6DOFIMU11_RETVAL
Definition: c6dofimu11.h:73
c6dofimu11_generic_write
void c6dofimu11_generic_write(c6dofimu11_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
c6dofimu11_cfg_t::gp1
pin_name_t gp1
Definition: c6dofimu11.h:448
c6dofimu11_get_mag_data
void c6dofimu11_get_mag_data(c6dofimu11_t *ctx, int16_t *mag_x, int16_t *mag_y, int16_t *mag_z)
Get map data.
c6dofimu11_get_temperature
float c6dofimu11_get_temperature(c6dofimu11_t *ctx)
Get temperature.
c6dofimu11_cfg_setup
void c6dofimu11_cfg_setup(c6dofimu11_cfg_t *cfg)
Config Object Initialization function.
c6dofimu11_t::gp2
digital_in_t gp2
Definition: c6dofimu11.h:424