smartdof5  2.1.0.0
smartdof5.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 SMARTDOF5_H
29 #define SMARTDOF5_H
30 
31 #ifdef __cplusplus
32 extern "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 
75 #define SMARTDOF5_REG_FUNC_CFG_ACCESS 0x01
76 #define SMARTDOF5_REG_PIN_CTRL 0x02
77 #define SMARTDOF5_REG_FIFO_CTRL1 0x07
78 #define SMARTDOF5_REG_FIFO_CTRL2 0x08
79 #define SMARTDOF5_REG_FIFO_CTRL3 0x09
80 #define SMARTDOF5_REG_FIFO_CTRL4 0x0A
81 #define SMARTDOF5_REG_COUNTER_BDR_1 0x0B
82 #define SMARTDOF5_REG_COUNTER_BDR_2 0x0C
83 #define SMARTDOF5_REG_INT1_CTRL 0x0D
84 #define SMARTDOF5_REG_INT2_CTRL 0x0E
85 #define SMARTDOF5_REG_WHO_AM_I 0x0F
86 #define SMARTDOF5_REG_CTRL1_XL 0x10
87 #define SMARTDOF5_REG_CTRL2_G 0x11
88 #define SMARTDOF5_REG_CTRL3_C 0x12
89 #define SMARTDOF5_REG_CTRL4_C 0x13
90 #define SMARTDOF5_REG_CTRL5_C 0x14
91 #define SMARTDOF5_REG_CTRL6_C 0x15
92 #define SMARTDOF5_REG_CTRL7_G 0x16
93 #define SMARTDOF5_REG_CTRL8_XL 0x17
94 #define SMARTDOF5_REG_CTRL9_XL 0x18
95 #define SMARTDOF5_REG_CTRL10_C 0x19
96 #define SMARTDOF5_REG_ALL_INT_SRC 0x1A
97 #define SMARTDOF5_REG_WAKE_UP_SRC 0x1B
98 #define SMARTDOF5_REG_D6D_SRC 0x1D
99 #define SMARTDOF5_REG_STATUS 0x1E
100 #define SMARTDOF5_REG_OUT_TEMP_L 0x20
101 #define SMARTDOF5_REG_OUT_TEMP_H 0x21
102 #define SMARTDOF5_REG_OUTX_L_G 0x22
103 #define SMARTDOF5_REG_OUTX_H_G 0x23
104 #define SMARTDOF5_REG_OUTY_L_G 0x24
105 #define SMARTDOF5_REG_OUTY_H_G 0x25
106 #define SMARTDOF5_REG_OUTZ_L_G 0x26
107 #define SMARTDOF5_REG_OUTZ_H_G 0x27
108 #define SMARTDOF5_REG_OUTX_L_A 0x28
109 #define SMARTDOF5_REG_OUTX_H_A 0x29
110 #define SMARTDOF5_REG_OUTY_L_A 0x2A
111 #define SMARTDOF5_REG_OUTY_H_A 0x2B
112 #define SMARTDOF5_REG_OUTZ_L_A 0x2C
113 #define SMARTDOF5_REG_OUTZ_H_A 0x2D
114 #define SMARTDOF5_REG_EMB_FUNC_STATUS_MAINPAGE 0x35
115 #define SMARTDOF5_REG_FSM_STATUS_A_MAINPAGE 0x36
116 #define SMARTDOF5_REG_FSM_STATUS_B_MAINPAGE 0x37
117 #define SMARTDOF5_REG_MLC_STATUS_MAINPAGE 0x38
118 #define SMARTDOF5_REG_STATUS_MASTER_MAINPAGE 0x39
119 #define SMARTDOF5_REG_FIFO_STATUS1 0x3A
120 #define SMARTDOF5_REG_FIFO_STATUS2 0x3B
121 #define SMARTDOF5_REG_TIMESTAMP0 0x40
122 #define SMARTDOF5_REG_TIMESTAMP1 0x41
123 #define SMARTDOF5_REG_TIMESTAMP2 0x42
124 #define SMARTDOF5_REG_TIMESTAMP3 0x43
125 #define SMARTDOF5_REG_INT_CFG0 0x56
126 #define SMARTDOF5_REG_INT_CFG1 0x58
127 #define SMARTDOF5_REG_THS_6D 0x59
128 #define SMARTDOF5_REG_WAKE_UP_THS 0x5B
129 #define SMARTDOF5_REG_WAKE_UP_DUR 0x5C
130 #define SMARTDOF5_REG_FREE_FALL 0x5D
131 #define SMARTDOF5_REG_MD1_CFG 0x5E
132 #define SMARTDOF5_REG_MD2_CFG 0x5F
133 #define SMARTDOF5_REG_I3C_BUS_AVB 0x62
134 #define SMARTDOF5_REG_INTERNAL_FREQ_FINE 0x63
135 #define SMARTDOF5_REG_X_OFS_USR 0x73
136 #define SMARTDOF5_REG_Y_OFS_USR 0x74
137 #define SMARTDOF5_REG_Z_OFS_USR 0x75
138 #define SMARTDOF5_REG_FIFO_DATA_OUT_TAG 0x78
139 #define SMARTDOF5_REG_FIFO_DATA_OUT_X_L 0x79
140 #define SMARTDOF5_REG_FIFO_DATA_OUT_X_H 0x7A
141 #define SMARTDOF5_REG_FIFO_DATA_OUT_Y_L 0x7B
142 #define SMARTDOF5_REG_FIFO_DATA_OUT_Y_H 0x7C
143 #define SMARTDOF5_REG_FIFO_DATA_OUT_Z_L 0x7D
144 #define SMARTDOF5_REG_FIFO_DATA_OUT_Z_H 0x7E
145 
150 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_1 0x02
151 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_2 0x03
152 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_3 0x04
153 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_4 0x05
154 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_5 0x06
155 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_6 0x07
156 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_7 0x08
157 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_8 0x09
158 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_9 0x0A
159 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_10 0x0B
160 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_11 0x0C
161 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_12 0x0D
162 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_13 0x0E
163 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_14 0x0F
164 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_15 0x10
165 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_16 0x11
166 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_17 0x12
167 #define SMARTDOF5_REG_SHUB_SENSOR_HUB_18 0x13
168 #define SMARTDOF5_REG_SHUB_MASTER_CONFIG 0x14
169 #define SMARTDOF5_REG_SHUB_SLV0_ADD 0x15
170 #define SMARTDOF5_REG_SHUB_SLV0_SUBADD 0x16
171 #define SMARTDOF5_REG_SHUB_SLV0_CONFIG 0x17
172 #define SMARTDOF5_REG_SHUB_SLV1_ADD 0x18
173 #define SMARTDOF5_REG_SHUB_SLV1_SUBADD 0x19
174 #define SMARTDOF5_REG_SHUB_SLV1_CONFIG 0x1A
175 #define SMARTDOF5_REG_SHUB_SLV2_ADD 0x1B
176 #define SMARTDOF5_REG_SHUB_SLV2_SUBADD 0x1C
177 #define SMARTDOF5_REG_SHUB_SLV2_CONFIG 0x1D
178 #define SMARTDOF5_REG_SHUB_SLV3_ADD 0x1E
179 #define SMARTDOF5_REG_SHUB_SLV3_SUBADD 0x1F
180 #define SMARTDOF5_REG_SHUB_SLV3_CONFIG 0x20
181 #define SMARTDOF5_REG_SHUB_DATAWRITE_SLV0 0x21
182 #define SMARTDOF5_REG_SHUB_STATUS_MASTER 0x22
183 
188 #define SMARTDOF5_REG_EMBF_PAGE_SEL 0x02
189 #define SMARTDOF5_REG_EMBF_EMB_FUNC_EN_B 0x05
190 #define SMARTDOF5_REG_EMBF_PAGE_ADDRESS 0x08
191 #define SMARTDOF5_REG_EMBF_PAGE_VALUE 0x09
192 #define SMARTDOF5_REG_EMBF_EMB_FUNC_INT1 0x0A
193 #define SMARTDOF5_REG_EMBF_FSM_INT1_A 0x0B
194 #define SMARTDOF5_REG_EMBF_FSM_INT1_B 0x0C
195 #define SMARTDOF5_REG_EMBF_MLC_INT1 0x0D
196 #define SMARTDOF5_REG_EMBF_EMB_FUNC_INT2 0x0E
197 #define SMARTDOF5_REG_EMBF_FSM_INT2_A 0x0F
198 #define SMARTDOF5_REG_EMBF_FSM_INT2_B 0x10
199 #define SMARTDOF5_REG_EMBF_MLC_INT2 0x11
200 #define SMARTDOF5_REG_EMBF_EMB_FUNC_STATUS 0x12
201 #define SMARTDOF5_REG_EMBF_FSM_STATUS_A 0x13
202 #define SMARTDOF5_REG_EMBF_FSM_STATUS_B 0x14
203 #define SMARTDOF5_REG_EMBF_MLC_STATUS 0x15
204 #define SMARTDOF5_REG_EMBF_PAGE_RW 0x17
205 #define SMARTDOF5_REG_EMBF_FSM_ENABLE_A 0x46
206 #define SMARTDOF5_REG_EMBF_FSM_ENABLE_B 0x47
207 #define SMARTDOF5_REG_EMBF_FSM_LONG_COUNTER_L 0x48
208 #define SMARTDOF5_REG_EMBF_FSM_LONG_COUNTER_H 0x49
209 #define SMARTDOF5_REG_EMBF_FSM_LONG_COUNTER_CLEAR 0x4A
210 #define SMARTDOF5_REG_EMBF_FSM_OUTS1 0x4C
211 #define SMARTDOF5_REG_EMBF_FSM_OUTS2 0x4D
212 #define SMARTDOF5_REG_EMBF_FSM_OUTS3 0x4E
213 #define SMARTDOF5_REG_EMBF_FSM_OUTS4 0x4F
214 #define SMARTDOF5_REG_EMBF_FSM_OUTS5 0x50
215 #define SMARTDOF5_REG_EMBF_FSM_OUTS6 0x51
216 #define SMARTDOF5_REG_EMBF_FSM_OUTS7 0x52
217 #define SMARTDOF5_REG_EMBF_FSM_OUTS8 0x53
218 #define SMARTDOF5_REG_EMBF_FSM_OUTS9 0x54
219 #define SMARTDOF5_REG_EMBF_FSM_OUTS10 0x55
220 #define SMARTDOF5_REG_EMBF_FSM_OUTS11 0x56
221 #define SMARTDOF5_REG_EMBF_FSM_OUTS12 0x57
222 #define SMARTDOF5_REG_EMBF_FSM_OUTS13 0x58
223 #define SMARTDOF5_REG_EMBF_FSM_OUTS14 0x59
224 #define SMARTDOF5_REG_EMBF_FSM_OUTS15 0x5A
225 #define SMARTDOF5_REG_EMBF_FSM_OUTS16 0x5B
226 #define SMARTDOF5_REG_EMBF_EMB_FUNC_ODR_CFG_B 0x5F
227 #define SMARTDOF5_REG_EMBF_EMB_FUNC_ODR_CFG_C 0x60
228 #define SMARTDOF5_REG_EMBF_EMB_FUNC_INIT_B 0x67
229 #define SMARTDOF5_REG_EMBF_MLC0_SRC 0x70
230 #define SMARTDOF5_REG_EMBF_MLC1_SRC 0x71
231 #define SMARTDOF5_REG_EMBF_MLC2_SRC 0x72
232 #define SMARTDOF5_REG_EMBF_MLC3_SRC 0x73
233 #define SMARTDOF5_REG_EMBF_MLC4_SRC 0x74
234 #define SMARTDOF5_REG_EMBF_MLC5_SRC 0x75
235 #define SMARTDOF5_REG_EMBF_MLC6_SRC 0x76
236 #define SMARTDOF5_REG_EMBF_MLC7_SRC 0x77
237 #define SMARTDOF5_REG_EMBF_P0_MAG_SENSITIVITY_L 0xBA
238 #define SMARTDOF5_REG_EMBF_P0_MAG_SENSITIVITY_H 0xBB
239 #define SMARTDOF5_REG_EMBF_P0_MAG_OFFX_L 0xC0
240 #define SMARTDOF5_REG_EMBF_P0_MAG_OFFX_H 0xC1
241 #define SMARTDOF5_REG_EMBF_P0_MAG_OFFY_L 0xC2
242 #define SMARTDOF5_REG_EMBF_P0_MAG_OFFY_H 0xC3
243 #define SMARTDOF5_REG_EMBF_P0_MAG_OFFZ_L 0xC4
244 #define SMARTDOF5_REG_EMBF_P0_MAG_OFFZ_H 0xC5
245 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_XX_L 0xC6
246 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_XX_H 0xC7
247 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_XY_L 0xC8
248 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_XY_H 0xC9
249 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_XZ_L 0xCA
250 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_XZ_H 0xCB
251 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_YY_L 0xCC
252 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_YY_H 0xCD
253 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_YZ_L 0xCE
254 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_YZ_H 0xCF
255 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_ZZ_L 0xD0
256 #define SMARTDOF5_REG_EMBF_P0_MAG_SI_ZZ_H 0xD1
257 #define SMARTDOF5_REG_EMBF_P0_MAG_CFG_A 0xD4
258 #define SMARTDOF5_REG_EMBF_P0_MAG_CFG_B 0xD5
259 #define SMARTDOF5_REG_EMBF_P1_FSM_LC_TIMEOUT_L 0x7A
260 #define SMARTDOF5_REG_EMBF_P1_FSM_LC_TIMEOUT_H 0x7B
261 #define SMARTDOF5_REG_EMBF_P1_FSM_PROGRAMS 0x7C
262 #define SMARTDOF5_REG_EMBF_P1_FSM_START_ADD_L 0x7E
263 #define SMARTDOF5_REG_EMBF_P1_FSM_START_ADD_H 0x7F
264 #define SMARTDOF5_REG_EMBF_P1_MLC_MAG_SENSITIVITY_L 0xE8
265 #define SMARTDOF5_REG_EMBF_P1_MLC_MAG_SENSITIVITY_H 0xE9
266  // smartdof5_reg
268 
283 #define SMARTDOF5_FUNC_CFG_ACCESS_MASK 0xC0
284 
289 #define SMARTDOF5_INT1_CTRL_DEN_DRDY 0x80
290 #define SMARTDOF5_INT1_CTRL_CNT_BDR 0x40
291 #define SMARTDOF5_INT1_CTRL_FIFO_FULL 0x20
292 #define SMARTDOF5_INT1_CTRL_FIFO_OVR 0x10
293 #define SMARTDOF5_INT1_CTRL_FIFO_TH 0x08
294 #define SMARTDOF5_INT1_CTRL_BOOT 0x04
295 #define SMARTDOF5_INT1_CTRL_DRDY_G 0x02
296 #define SMARTDOF5_INT1_CTRL_DRDY_XL 0x01
297 
302 #define SMARTDOF5_WHO_AM_I 0x6B
303 
308 #define SMARTDOF5_CTRL1_XL_ODR_MASK 0xF0
309 #define SMARTDOF5_CTRL1_XL_FS_MASK 0x0C
310 #define SMARTDOF5_CTRL1_XL_LPF2_EN_MASK 0x02
311 
316 #define SMARTDOF5_CTRL2_G_ODR_MASK 0xF0
317 #define SMARTDOF5_CTRL2_G_FS_MASK 0x0C
318 #define SMARTDOF5_CTRL2_G_FS_125_MASK 0x02
319 #define SMARTDOF5_CTRL2_G_FS_4000_MASK 0x01
320 
325 #define SMARTDOF5_CTRL3_C_BOOT 0x80
326 #define SMARTDOF5_CTRL3_C_BDU 0x40
327 #define SMARTDOF5_CTRL3_C_H_LACTIVE 0x20
328 #define SMARTDOF5_CTRL3_C_PP_OD 0x10
329 #define SMARTDOF5_CTRL3_C_SIM 0x08
330 #define SMARTDOF5_CTRL3_C_IF_INC 0x04
331 #define SMARTDOF5_CTRL3_C_SW_RESET 0x01
332 
337 #define SMARTDOF5_CTRL9_XL_DEN_X 0x80
338 #define SMARTDOF5_CTRL9_XL_DEN_Y 0x40
339 #define SMARTDOF5_CTRL9_XL_DEN_Z 0x20
340 #define SMARTDOF5_CTRL9_XL_DEN_XL_G 0x10
341 #define SMARTDOF5_CTRL9_XL_DEN_XL_EN 0x08
342 #define SMARTDOF5_CTRL9_XL_DEN_LH 0x04
343 #define SMARTDOF5_CTRL9_XL_I3C_DISABLE 0x02
344 
349 #define SMARTDOF5_STATUS_TDA 0x04
350 #define SMARTDOF5_STATUS_GDA 0x02
351 #define SMARTDOF5_STATUS_XLDA 0x01
352 
357 #define SMARTDOF5_MEM_BANK_USER 0
358 #define SMARTDOF5_MEM_BANK_SENSOR_HUB 1
359 #define SMARTDOF5_MEM_BANK_EMBEDDED_FUNC 2
360 
365 #define SMARTDOF5_ACCEL_ODR_OFF 0
366 #define SMARTDOF5_ACCEL_ODR_12_5_HZ 1
367 #define SMARTDOF5_ACCEL_ODR_26_HZ 2
368 #define SMARTDOF5_ACCEL_ODR_52_HZ 3
369 #define SMARTDOF5_ACCEL_ODR_104_HZ 4
370 #define SMARTDOF5_ACCEL_ODR_208_HZ 5
371 #define SMARTDOF5_ACCEL_ODR_417_HZ 6
372 #define SMARTDOF5_ACCEL_ODR_833_HZ 7
373 #define SMARTDOF5_ACCEL_ODR_1667_HZ 8
374 #define SMARTDOF5_ACCEL_ODR_3333_HZ 9
375 #define SMARTDOF5_ACCEL_ODR_6667_HZ 10
376 #define SMARTDOF5_ACCEL_ODR_1_6_HZ 11
377 
382 #define SMARTDOF5_ACCEL_FS_2G 0
383 #define SMARTDOF5_ACCEL_FS_16G 1
384 #define SMARTDOF5_ACCEL_FS_4G 2
385 #define SMARTDOF5_ACCEL_FS_8G 3
386 
391 #define SMARTDOF5_GYRO_ODR_OFF 0
392 #define SMARTDOF5_GYRO_ODR_12_5_HZ 1
393 #define SMARTDOF5_GYRO_ODR_26_HZ 2
394 #define SMARTDOF5_GYRO_ODR_52_HZ 3
395 #define SMARTDOF5_GYRO_ODR_104_HZ 4
396 #define SMARTDOF5_GYRO_ODR_208_HZ 5
397 #define SMARTDOF5_GYRO_ODR_417_HZ 6
398 #define SMARTDOF5_GYRO_ODR_833_HZ 7
399 #define SMARTDOF5_GYRO_ODR_1667_HZ 8
400 #define SMARTDOF5_GYRO_ODR_3333_HZ 9
401 #define SMARTDOF5_GYRO_ODR_6667_HZ 10
402 
407 #define SMARTDOF5_GYRO_FS_250DPS 0
408 #define SMARTDOF5_GYRO_FS_500DPS 1
409 #define SMARTDOF5_GYRO_FS_1000DPS 2
410 #define SMARTDOF5_GYRO_FS_2000DPS 3
411 #define SMARTDOF5_GYRO_FS_4000DPS 4
412 #define SMARTDOF5_GYRO_FS_125DPS 5
413 
418 #define SMARTDOF5_ACCEL_SENS_G_PER_LSB 0.000061
419 #define SMARTDOF5_GYRO_SENS_DPS_PER_LSB 0.004375
420 #define SMARTDOF5_TEMP_SENS_LSB_PER_C 256.0
421 #define SMARTDOF5_TEMP_OFFSET 25.0
422 
428 #define SMARTDOF5_DEVICE_ADDRESS_0 0x6A
429 #define SMARTDOF5_DEVICE_ADDRESS_1 0x6B
430 
439 #define SMARTDOF5_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
440 #define SMARTDOF5_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
441  // smartdof5_set
443 
458 #define SMARTDOF5_MAP_MIKROBUS( cfg, mikrobus ) \
459  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
460  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
461  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
462  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
463  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
464  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
465  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
466  // smartdof5_map // smartdof5
469 
474 typedef enum
475 {
480 
485 struct smartdof5_s;
486 typedef err_t ( *smartdof5_master_io_t )( struct smartdof5_s*, uint8_t, uint8_t*, uint8_t );
492 typedef struct smartdof5_s
493 {
494  digital_in_t int_pin;
496  i2c_master_t i2c;
497  spi_master_t spi;
499  uint8_t slave_address;
500  pin_name_t chip_select;
506  float gyro_sens;
507  float accel_sens;
510 
515 typedef struct
516 {
517  pin_name_t scl;
518  pin_name_t sda;
519  pin_name_t miso;
520  pin_name_t mosi;
521  pin_name_t sck;
522  pin_name_t cs;
523  pin_name_t int_pin;
525  uint32_t i2c_speed;
526  uint8_t i2c_address;
528  uint32_t spi_speed;
529  spi_master_mode_t spi_mode;
530  spi_master_chip_select_polarity_t cs_polarity;
535 
540 typedef struct
541 {
542  float x;
543  float y;
544  float z;
547 
552 typedef struct
553 {
556  float temperature;
559 
564 typedef enum
565 {
567  SMARTDOF5_ERROR = -1
568 
570 
587 
603 
618 
632 
645 err_t smartdof5_write_reg ( smartdof5_t *ctx, uint8_t reg, uint8_t data_in );
646 
661 err_t smartdof5_write_regs ( smartdof5_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
662 
675 err_t smartdof5_read_reg ( smartdof5_t *ctx, uint8_t reg, uint8_t *data_out );
676 
691 err_t smartdof5_read_regs ( smartdof5_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
692 
702 
714 
729 err_t smartdof5_set_mem_bank ( smartdof5_t *ctx, uint8_t mem_bank );
730 
742 
765 err_t smartdof5_set_accel_odr ( smartdof5_t *ctx, uint8_t odr );
766 
788 err_t smartdof5_set_gyro_odr ( smartdof5_t *ctx, uint8_t odr );
789 
804 err_t smartdof5_set_accel_fsr ( smartdof5_t *ctx, uint8_t fsr );
805 
822 err_t smartdof5_set_gyro_fsr ( smartdof5_t *ctx, uint8_t fsr );
823 
836 err_t smartdof5_get_accel_drdy ( smartdof5_t *ctx, uint8_t *drdy );
837 
850 err_t smartdof5_get_gyro_drdy ( smartdof5_t *ctx, uint8_t *drdy );
851 
864 err_t smartdof5_get_temp_drdy ( smartdof5_t *ctx, uint8_t *drdy );
865 
879 
893 
905 err_t smartdof5_get_temp ( smartdof5_t *ctx, float *temp );
906 
920 
921 #ifdef __cplusplus
922 }
923 #endif
924 #endif // SMARTDOF5_H
925  // smartdof5
927 
928 // ------------------------------------------------------------------------ END
smartdof5_cfg_t::sck
pin_name_t sck
Definition: smartdof5.h:521
smartdof5_s::chip_select
pin_name_t chip_select
Definition: smartdof5.h:500
smartdof5_set_accel_fsr
err_t smartdof5_set_accel_fsr(smartdof5_t *ctx, uint8_t fsr)
Smart DOF 5 set accel fsr function.
smartdof5_get_accel_drdy
err_t smartdof5_get_accel_drdy(smartdof5_t *ctx, uint8_t *drdy)
Smart DOF 5 get accel drdy function.
smartdof5_s::read_f
smartdof5_master_io_t read_f
Definition: smartdof5.h:504
smartdof5_get_temp_drdy
err_t smartdof5_get_temp_drdy(smartdof5_t *ctx, uint8_t *drdy)
Smart DOF 5 get temp drdy function.
smartdof5_read_regs
err_t smartdof5_read_regs(smartdof5_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Smart DOF 5 read regs function.
smartdof5_cfg_t::cs
pin_name_t cs
Definition: smartdof5.h:522
smartdof5_cfg_t::mosi
pin_name_t mosi
Definition: smartdof5.h:520
smartdof5_cfg_setup
void smartdof5_cfg_setup(smartdof5_cfg_t *cfg)
Smart DOF 5 configuration object setup function.
smartdof5_return_value_t
smartdof5_return_value_t
Smart DOF 5 Click return value data.
Definition: smartdof5.h:565
smartdof5_cfg_t::spi_speed
uint32_t spi_speed
Definition: smartdof5.h:528
spi_specifics.h
This file contains SPI specific macros, functions, etc.
smartdof5_s::gyro_sens
float gyro_sens
Definition: smartdof5.h:506
smartdof5_s::int_pin
digital_in_t int_pin
Definition: smartdof5.h:494
smartdof5_write_reg
err_t smartdof5_write_reg(smartdof5_t *ctx, uint8_t reg, uint8_t data_in)
Smart DOF 5 write reg function.
smartdof5_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: smartdof5.h:525
SMARTDOF5_OK
@ SMARTDOF5_OK
Definition: smartdof5.h:566
smartdof5_drv_t
smartdof5_drv_t
Smart DOF 5 Click driver selector.
Definition: smartdof5.h:475
smartdof5_read_reg
err_t smartdof5_read_reg(smartdof5_t *ctx, uint8_t reg, uint8_t *data_out)
Smart DOF 5 read reg function.
smartdof5_s::i2c
i2c_master_t i2c
Definition: smartdof5.h:496
SMARTDOF5_DRV_SEL_SPI
@ SMARTDOF5_DRV_SEL_SPI
Definition: smartdof5.h:476
smartdof5_get_gyro
err_t smartdof5_get_gyro(smartdof5_t *ctx, smartdof5_axes_t *gyro)
Smart DOF 5 get gyro function.
smartdof5_write_regs
err_t smartdof5_write_regs(smartdof5_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Smart DOF 5 write regs function.
smartdof5_drv_interface_sel
void smartdof5_drv_interface_sel(smartdof5_cfg_t *cfg, smartdof5_drv_t drv_sel)
Smart DOF 5 driver interface setup function.
smartdof5_init
err_t smartdof5_init(smartdof5_t *ctx, smartdof5_cfg_t *cfg)
Smart DOF 5 initialization function.
smartdof5_get_temp
err_t smartdof5_get_temp(smartdof5_t *ctx, float *temp)
Smart DOF 5 get temp function.
smartdof5_s::accel_sens
float accel_sens
Definition: smartdof5.h:507
smartdof5_master_io_t
err_t(* smartdof5_master_io_t)(struct smartdof5_s *, uint8_t, uint8_t *, uint8_t)
Definition: smartdof5.h:486
smartdof5_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: smartdof5.h:530
smartdof5_get_gyro_drdy
err_t smartdof5_get_gyro_drdy(smartdof5_t *ctx, uint8_t *drdy)
Smart DOF 5 get gyro drdy function.
SMARTDOF5_ERROR
@ SMARTDOF5_ERROR
Definition: smartdof5.h:567
smartdof5_cfg_t
Smart DOF 5 Click configuration object.
Definition: smartdof5.h:516
smartdof5_axes_t::x
float x
Definition: smartdof5.h:542
smartdof5_s
Smart DOF 5 Click context object.
Definition: smartdof5.h:493
smartdof5_get_accel
err_t smartdof5_get_accel(smartdof5_t *ctx, smartdof5_axes_t *accel)
Smart DOF 5 get accel function.
smartdof5_default_cfg
err_t smartdof5_default_cfg(smartdof5_t *ctx)
Smart DOF 5 default configuration function.
smartdof5_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: smartdof5.h:529
smartdof5_s::drv_sel
smartdof5_drv_t drv_sel
Definition: smartdof5.h:501
smartdof5_t
struct smartdof5_s smartdof5_t
Smart DOF 5 Click context object.
smartdof5_set_gyro_odr
err_t smartdof5_set_gyro_odr(smartdof5_t *ctx, uint8_t odr)
Smart DOF 5 set gyro odr function.
smartdof5_axes_t::y
float y
Definition: smartdof5.h:543
smartdof5_s::write_f
smartdof5_master_io_t write_f
Definition: smartdof5.h:503
smartdof5_cfg_t::miso
pin_name_t miso
Definition: smartdof5.h:519
smartdof5_cfg_t::scl
pin_name_t scl
Definition: smartdof5.h:517
smartdof5_cfg_t::i2c_address
uint8_t i2c_address
Definition: smartdof5.h:526
smartdof5_data_t::temperature
float temperature
Definition: smartdof5.h:556
smartdof5_get_data
err_t smartdof5_get_data(smartdof5_t *ctx, smartdof5_data_t *data_out)
Smart DOF 5 get data function.
smartdof5_set_mem_bank
err_t smartdof5_set_mem_bank(smartdof5_t *ctx, uint8_t mem_bank)
Smart DOF 5 set mem bank function.
smartdof5_cfg_t::sda
pin_name_t sda
Definition: smartdof5.h:518
SMARTDOF5_DRV_SEL_I2C
@ SMARTDOF5_DRV_SEL_I2C
Definition: smartdof5.h:477
smartdof5_check_communication
err_t smartdof5_check_communication(smartdof5_t *ctx)
Smart DOF 5 check communication function.
smartdof5_data_t
Smart DOF 5 Click data structure.
Definition: smartdof5.h:553
smartdof5_s::slave_address
uint8_t slave_address
Definition: smartdof5.h:499
smartdof5_set_gyro_fsr
err_t smartdof5_set_gyro_fsr(smartdof5_t *ctx, uint8_t fsr)
Smart DOF 5 set gyro fsr function.
smartdof5_axes_t
Smart DOF 5 Click axes data structure.
Definition: smartdof5.h:541
smartdof5_s::spi
spi_master_t spi
Definition: smartdof5.h:497
smartdof5_data_t::gyro
smartdof5_axes_t gyro
Definition: smartdof5.h:555
smartdof5_cfg_t::drv_sel
smartdof5_drv_t drv_sel
Definition: smartdof5.h:532
smartdof5_axes_t::z
float z
Definition: smartdof5.h:544
smartdof5_set_accel_odr
err_t smartdof5_set_accel_odr(smartdof5_t *ctx, uint8_t odr)
Smart DOF 5 set accel odr function.
smartdof5_data_t::accel
smartdof5_axes_t accel
Definition: smartdof5.h:554
smartdof5_get_int_pin
uint8_t smartdof5_get_int_pin(smartdof5_t *ctx)
Smart DOF 5 get int pin function.
smartdof5_cfg_t::int_pin
pin_name_t int_pin
Definition: smartdof5.h:523
smartdof5_sw_reset
err_t smartdof5_sw_reset(smartdof5_t *ctx)
Smart DOF 5 sw reset function.