Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 #include "drv_spi_master.h"
61 #define SMARTDOF2_REG_FUNC_CFG_ACCESS 0x01
62 #define SMARTDOF2_REG_PIN_CTRL 0x02
63 #define SMARTDOF2_REG_IF_CFG 0x03
64 #define SMARTDOF2_REG_S4S_TPH_L 0x04
65 #define SMARTDOF2_REG_S4S_TPH_H 0x05
66 #define SMARTDOF2_REG_S4S_RR 0x06
67 #define SMARTDOF2_REG_FIFO_CTRL1 0x07
68 #define SMARTDOF2_REG_FIFO_CTRL2 0x08
69 #define SMARTDOF2_REG_FIFO_CTRL3 0x09
70 #define SMARTDOF2_REG_FIFO_CTRL4 0x0A
71 #define SMARTDOF2_REG_COUNTER_BDR_REG1 0x0B
72 #define SMARTDOF2_REG_COUNTER_BDR_REG2 0x0C
73 #define SMARTDOF2_REG_INT1_CTRL 0x0D
74 #define SMARTDOF2_REG_INT2_CTRL 0x0E
75 #define SMARTDOF2_REG_WHO_AM_I 0x0F
76 #define SMARTDOF2_REG_CTRL1 0x10
77 #define SMARTDOF2_REG_CTRL2 0x11
78 #define SMARTDOF2_REG_CTRL3 0x12
79 #define SMARTDOF2_REG_CTRL4 0x13
80 #define SMARTDOF2_REG_CTRL5 0x14
81 #define SMARTDOF2_REG_CTRL6 0x15
82 #define SMARTDOF2_REG_CTRL7 0x16
83 #define SMARTDOF2_REG_CTRL8 0x17
84 #define SMARTDOF2_REG_CTRL9 0x18
85 #define SMARTDOF2_REG_CTRL10 0x19
86 #define SMARTDOF2_REG_CTRL_STATUS 0x1A
87 #define SMARTDOF2_REG_FIFO_STATUS1 0x1B
88 #define SMARTDOF2_REG_FIFO_STATUS2 0x1C
89 #define SMARTDOF2_REG_ALL_INT_SRC 0x1D
90 #define SMARTDOF2_REG_STATUS_REG 0x1E
91 #define SMARTDOF2_REG_OUT_TEMP_L 0x20
92 #define SMARTDOF2_REG_OUT_TEMP_H 0x21
93 #define SMARTDOF2_REG_OUTX_L_G 0x22
94 #define SMARTDOF2_REG_OUTX_H_G 0x23
95 #define SMARTDOF2_REG_OUTY_L_G 0x24
96 #define SMARTDOF2_REG_OUTY_H_G 0x25
97 #define SMARTDOF2_REG_OUTZ_L_G 0x26
98 #define SMARTDOF2_REG_OUTZ_H_G 0x27
99 #define SMARTDOF2_REG_OUTX_L_A 0x28
100 #define SMARTDOF2_REG_OUTX_H_A 0x29
101 #define SMARTDOF2_REG_OUTY_L_A 0x2A
102 #define SMARTDOF2_REG_OUTY_H_A 0x2B
103 #define SMARTDOF2_REG_OUTZ_L_A 0x2C
104 #define SMARTDOF2_REG_OUTZ_H_A 0x2D
105 #define SMARTDOF2_REG_UI_OUTX_L_G_OIS_EIS 0x2E
106 #define SMARTDOF2_REG_UI_OUTX_H_G_OIS_EIS 0x2F
107 #define SMARTDOF2_REG_UI_OUTY_L_G_OIS_EIS 0x30
108 #define SMARTDOF2_REG_UI_OUTY_H_G_OIS_EIS 0x31
109 #define SMARTDOF2_REG_UI_OUTZ_L_G_OIS_EIS 0x32
110 #define SMARTDOF2_REG_UI_OUTZ_H_G_OIS_EIS 0x33
111 #define SMARTDOF2_REG_UI_OUTX_L_A_OIS_DUALC 0x34
112 #define SMARTDOF2_REG_UI_OUTX_H_A_OIS_DUALC 0x35
113 #define SMARTDOF2_REG_UI_OUTY_L_A_OIS_DUALC 0x36
114 #define SMARTDOF2_REG_UI_OUTY_H_A_OIS_DUALC 0x37
115 #define SMARTDOF2_REG_UI_OUTZ_L_A_OIS_DUALC 0x38
116 #define SMARTDOF2_REG_UI_OUTZ_H_A_OIS_DUALC 0x39
117 #define SMARTDOF2_REG_AH_QVAR_OUT_L 0x3A
118 #define SMARTDOF2_REG_AH_QVAR_OUT_H 0x3B
119 #define SMARTDOF2_REG_TIMESTAMP0 0x40
120 #define SMARTDOF2_REG_TIMESTAMP1 0x41
121 #define SMARTDOF2_REG_TIMESTAMP2 0x42
122 #define SMARTDOF2_REG_TIMESTAMP3 0x43
123 #define SMARTDOF2_REG_UI_STATUS_REG_OIS 0x44
124 #define SMARTDOF2_REG_WAKE_UP_SRC 0x45
125 #define SMARTDOF2_REG_TAP_SRC 0x46
126 #define SMARTDOF2_REG_D6D_SRC 0x47
127 #define SMARTDOF2_REG_STATUS_MASTER_MAINPAGE 0x48
128 #define SMARTDOF2_REG_EMB_FUNC_STATUS_MAINPAGE 0x49
129 #define SMARTDOF2_REG_FSM_STATUS_MAINPAGE 0x4A
130 #define SMARTDOF2_REG_MLC_STATUS_MAINPAGE 0x4B
131 #define SMARTDOF2_REG_INTERNAL_FREQ 0x4F
132 #define SMARTDOF2_REG_FUNCTIONS_ENABLE 0x50
133 #define SMARTDOF2_REG_DEN 0x51
134 #define SMARTDOF2_REG_INACTIVITY_DUR 0x54
135 #define SMARTDOF2_REG_INACTIVITY_THS 0x55
136 #define SMARTDOF2_REG_TAP_CFG0 0x56
137 #define SMARTDOF2_REG_TAP_CFG1 0x57
138 #define SMARTDOF2_REG_TAP_CFG2 0x58
139 #define SMARTDOF2_REG_TAP_THS_6D 0x59
140 #define SMARTDOF2_REG_INT_DUR2 0x5A
141 #define SMARTDOF2_REG_WAKE_UP_THS 0x5B
142 #define SMARTDOF2_REG_WAKE_UP_DUR 0x5C
143 #define SMARTDOF2_REG_FREE_FALL 0x5D
144 #define SMARTDOF2_REG_MD1_CFG 0x5E
145 #define SMARTDOF2_REG_MD2_CFG 0x5F
146 #define SMARTDOF2_REG_S4S_ST_CMD_CODE 0x60
147 #define SMARTDOF2_REG_S4S_DT_REG 0x61
148 #define SMARTDOF2_REG_EMB_FUNC_CFG 0x63
149 #define SMARTDOF2_REG_UI_HANDSHAKE_CTRL 0x64
150 #define SMARTDOF2_REG_UI_SPI2_SHARED_0 0x65
151 #define SMARTDOF2_REG_UI_SPI2_SHARED_1 0x66
152 #define SMARTDOF2_REG_UI_SPI2_SHARED_2 0x67
153 #define SMARTDOF2_REG_UI_SPI2_SHARED_3 0x68
154 #define SMARTDOF2_REG_UI_SPI2_SHARED_4 0x69
155 #define SMARTDOF2_REG_UI_SPI2_SHARED_5 0x6A
156 #define SMARTDOF2_REG_CTRL_EIS 0x6B
157 #define SMARTDOF2_REG_UI_INT_OIS 0x6F
158 #define SMARTDOF2_REG_UI_CTRL1_OIS 0x70
159 #define SMARTDOF2_REG_UI_CTRL2_OIS 0x71
160 #define SMARTDOF2_REG_UI_CTRL3_OIS 0x72
161 #define SMARTDOF2_REG_X_OFS_USR 0x73
162 #define SMARTDOF2_REG_Y_OFS_USR 0x74
163 #define SMARTDOF2_REG_Z_OFS_USR 0x75
164 #define SMARTDOF2_REG_FIFO_DATA_OUT_TAG 0x78
165 #define SMARTDOF2_REG_FIFO_DATA_OUT_X_L 0x79
166 #define SMARTDOF2_REG_FIFO_DATA_OUT_X_H 0x7A
167 #define SMARTDOF2_REG_FIFO_DATA_OUT_Y_L 0x7B
168 #define SMARTDOF2_REG_FIFO_DATA_OUT_Y_H 0x7C
169 #define SMARTDOF2_REG_FIFO_DATA_OUT_Z_L 0x7D
170 #define SMARTDOF2_REG_FIFO_DATA_OUT_Z_H 0x7E
189 #define SMARTDOF2_DEVICE_ID 0x70
195 #define SMARTDOF2_IF_INC_DISABLE 0x00
196 #define SMARTDOF2_IF_INC_ENABLE 0x04
197 #define SMARTDOF2_IF_INC_BIT_MASK 0xFB
198 #define SMARTDOF2_BDU_DISABLE 0x00
199 #define SMARTDOF2_BDU_ENABLE 0x40
200 #define SMARTDOF2_BDU_BIT_MASK 0xBF
206 #define SMARTDOF2_FIFO_MODE_BYPASS 0x00
207 #define SMARTDOF2_FIFO_MODE_FIFO 0x01
208 #define SMARTDOF2_FIFO_MODE_STREAM_WTM_TO_FULL 0x02
209 #define SMARTDOF2_FIFO_MODE_STREAM_TO_FIFO 0x03
210 #define SMARTDOF2_FIFO_MODE_BYPASS_TO_STREAM 0x04
211 #define SMARTDOF2_FIFO_MODE_STREAM 0x06
212 #define SMARTDOF2_FIFO_MODE_BYPASS_TO_FIFO 0x07
213 #define SMARTDOF2_FIFO_MODE_BIT_MASK 0xF8
219 #define SMARTDOF2_ODR_OFF 0x00
220 #define SMARTDOF2_ODR_AT_1Hz875 0x01
221 #define SMARTDOF2_ODR_AT_7Hz5 0x02
222 #define SMARTDOF2_ODR_AT_15Hz 0x03
223 #define SMARTDOF2_ODR_AT_30Hz 0x04
224 #define SMARTDOF2_ODR_AT_60Hz 0x05
225 #define SMARTDOF2_ODR_AT_120Hz 0x06
226 #define SMARTDOF2_ODR_AT_240Hz 0x07
227 #define SMARTDOF2_ODR_AT_480Hz 0x08
228 #define SMARTDOF2_ODR_AT_960Hz 0x09
229 #define SMARTDOF2_ODR_AT_1920Hz 0x0A
230 #define SMARTDOF2_ODR_AT_3840Hz 0x0B
231 #define SMARTDOF2_ODR_AT_7680Hz 0x0C
232 #define SMARTDOF2_ODR_BIT_MASK 0xF0
238 #define SMARTDOF2_XL_FULL_SCALE_2g 0x00
239 #define SMARTDOF2_XL_FULL_SCALE_4g 0x01
240 #define SMARTDOF2_XL_FULL_SCALE_8g 0x02
241 #define SMARTDOF2_XL_FULL_SCALE_16g 0x03
242 #define SMARTDOF2_XL_FULL_SCALE_BIT_MASK 0xF8
248 #define SMARTDOF2_GY_FULL_SCALE_125dps 0x00
249 #define SMARTDOF2_GY_FULL_SCALE_250dps 0x01
250 #define SMARTDOF2_GY_FULL_SCALE_500dps 0x02
251 #define SMARTDOF2_GY_FULL_SCALE_1000dps 0x03
252 #define SMARTDOF2_GY_FULL_SCALE_2000dps 0x04
253 #define SMARTDOF2_GY_FULL_SCALE_4000dps 0x0C
254 #define SMARTDOF2_GY_FULL_SCALE_BIT_MASK 0xF0
260 #define SMARTDOF2_ACC_SENSITIVITY_FS_2g 0.061
261 #define SMARTDOF2_ACC_SENSITIVITY_FS_4g 0.122
262 #define SMARTDOF2_ACC_SENSITIVITY_FS_8g 0.244
263 #define SMARTDOF2_ACC_SENSITIVITY_FS_16g 0.488
269 #define SMARTDOF2_GYRO_SENSITIVITY_FS_125dps 4.375
270 #define SMARTDOF2_GYRO_SENSITIVITY_FS_250dps 8.750
271 #define SMARTDOF2_GYRO_SENSITIVITY_FS_500dps 17.500
272 #define SMARTDOF2_GYRO_SENSITIVITY_FS_1000dps 35.000
273 #define SMARTDOF2_GYRO_SENSITIVITY_FS_2000dps 70.000
274 #define SMARTDOF2_GYRO_SENSITIVITY_FS_4000dps 140.000
281 #define SMARTDOF2_DEVICE_ADDRESS_GND 0x6A
282 #define SMARTDOF2_DEVICE_ADDRESS_VCC 0x6B
292 #define SMARTDOF2_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
293 #define SMARTDOF2_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
311 #define SMARTDOF2_MAP_MIKROBUS( cfg, mikrobus ) \
312 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
313 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
314 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
315 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
316 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
317 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
318 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
834 #endif // SMARTDOF2_H
err_t smartdof2_default_cfg(smartdof2_t *ctx)
Smart DOF 2 default configuration function.
err_t smartdof2_get_acc_axis_data(smartdof2_t *ctx, smartdof2_axis_data_t *acc_axis)
Smart DOF 2 get accel data function.
float x
Definition: smartdof2.h:403
pin_name_t miso
Definition: smartdof2.h:368
uint8_t slave_address
Definition: smartdof2.h:351
int16_t y
Definition: smartdof2.h:392
uint8_t i2c_address
Definition: smartdof2.h:375
err_t smartdof2_enable_block_data_update(smartdof2_t *ctx)
Smart DOF 2 enable block data update function.
uint8_t smartdof2_get_int_pin(smartdof2_t *ctx)
Smart DOF 2 get interrupt function.
digital_in_t int_pin
Definition: smartdof2.h:346
Smart DOF 2 Click axis raw data structure object.
Definition: smartdof2.h:390
@ SMARTDOF2_DRV_SEL_SPI
Definition: smartdof2.h:329
This file contains SPI specific macros, functions, etc.
spi_master_mode_t spi_mode
Definition: smartdof2.h:378
i2c_master_t i2c
Definition: smartdof2.h:348
void smartdof2_cfg_setup(smartdof2_cfg_t *cfg)
Smart DOF 2 configuration object setup function.
err_t smartdof2_get_gyro_axis(smartdof2_t *ctx, smartdof2_axis_t *gyro_axis)
Smart DOF 2 get gyro sensor axes function.
err_t smartdof2_get_acc_axis(smartdof2_t *ctx, smartdof2_axis_t *acc_axis)
Smart DOF 2 get accel sensor axes function.
err_t smartdof2_get_temperature_raw(smartdof2_t *ctx, int16_t *temp_raw)
Smart DOF 2 get temperature data function.
@ SMARTDOF2_DRV_SEL_I2C
Definition: smartdof2.h:330
float y
Definition: smartdof2.h:404
smartdof2_drv_t
Smart DOF 2 Click driver selector.
Definition: smartdof2.h:328
pin_name_t sck
Definition: smartdof2.h:370
Smart DOF 2 Click configuration object.
Definition: smartdof2.h:365
err_t smartdof2_init(smartdof2_t *ctx, smartdof2_cfg_t *cfg)
Smart DOF 2 initialization function.
err_t smartdof2_get_gyro_full_scale(smartdof2_t *ctx, uint8_t *data_scale)
Smart DOF 2 get full-scale gyro range function.
void smartdof2_drv_interface_selection(smartdof2_cfg_t *cfg, smartdof2_drv_t drv_sel)
Smart DOF 2 driver interface setup function.
err_t smartdof2_generic_write(smartdof2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Smart DOF 2 data writing function.
smartdof2_master_io_t write_f
Definition: smartdof2.h:355
err_t smartdof2_get_gyro_axis_data(smartdof2_t *ctx, smartdof2_axis_data_t *gyro_axis)
Smart DOF 2 get gyro data function.
err_t smartdof2_enable_auto_increment(smartdof2_t *ctx)
Smart DOF 2 enable auto increment function.
int16_t x
Definition: smartdof2.h:391
smartdof2_drv_t drv_sel
Definition: smartdof2.h:381
err_t smartdof2_get_acc_sensitivity(smartdof2_t *ctx, float *sensitivity)
Smart DOF 2 get accel sensitivity function.
pin_name_t sda
Definition: smartdof2.h:367
err_t smartdof2_get_temperature(smartdof2_t *ctx, float *temperature)
Smart DOF 2 get temperature function.
spi_master_chip_select_polarity_t cs_polarity
Definition: smartdof2.h:379
err_t smartdof2_generic_read(smartdof2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Smart DOF 2 data reading function.
err_t(* smartdof2_master_io_t)(struct smartdof2_s *, uint8_t, uint8_t *, uint8_t)
Smart DOF 2 Click driver interface.
Definition: smartdof2.h:338
Smart DOF 2 Click context object.
Definition: smartdof2.h:345
@ SMARTDOF2_OK
Definition: smartdof2.h:415
@ SMARTDOF2_ERROR
Definition: smartdof2.h:416
struct smartdof2_s smartdof2_t
Smart DOF 2 Click context object.
err_t smartdof2_set_gyro_data_rate(smartdof2_t *ctx, uint8_t data_rate)
Smart DOF 2 set gyro data rate function.
Smart DOF 2 Click sensor axes structure object.
Definition: smartdof2.h:402
err_t smartdof2_get_device_id(smartdof2_t *ctx, uint8_t *device_id)
Smart DOF 2 get device ID function.
err_t smartdof2_get_acc_full_scale(smartdof2_t *ctx, uint8_t *data_scale)
Smart DOF 2 get full-scale accel range function.
err_t smartdof2_set_acc_full_scale(smartdof2_t *ctx, uint8_t data_scale)
Smart DOF 2 set full-scale accel range function.
pin_name_t int_pin
Definition: smartdof2.h:372
smartdof2_master_io_t read_f
Definition: smartdof2.h:356
pin_name_t mosi
Definition: smartdof2.h:369
err_t smartdof2_set_fifo_mode(smartdof2_t *ctx, uint8_t fifo_mode)
Smart DOF 2 set FIFO mode function.
err_t smartdof2_set_gyro_full_scale(smartdof2_t *ctx, uint8_t data_scale)
Smart DOF 2 set full-scale gyro range function.
err_t smartdof2_get_gyro_sensitivity(smartdof2_t *ctx, float *sensitivity)
Smart DOF 2 get gyro sensitivity function.
uint32_t i2c_speed
Definition: smartdof2.h:374
smartdof2_return_value_t
Smart DOF 2 Click return value data.
Definition: smartdof2.h:414
int16_t z
Definition: smartdof2.h:393
pin_name_t cs
Definition: smartdof2.h:371
pin_name_t scl
Definition: smartdof2.h:366
uint32_t spi_speed
Definition: smartdof2.h:377
spi_master_t spi
Definition: smartdof2.h:349
pin_name_t chip_select
Definition: smartdof2.h:352
float z
Definition: smartdof2.h:405
err_t smartdof2_set_acc_data_rate(smartdof2_t *ctx, uint8_t data_rate)
Smart DOF 2 set accel data rate function.
smartdof2_drv_t drv_sel
Definition: smartdof2.h:353