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 SMARTDOF3_REG_FUNC_CFG_ACCESS 0x01
62 #define SMARTDOF3_REG_PIN_CTRL 0x02
63 #define SMARTDOF3_REG_DRDY_PULSED_REG 0x0B
64 #define SMARTDOF3_REG_INT1_CTRL 0x0D
65 #define SMARTDOF3_REG_INT2_CTRL 0x0E
66 #define SMARTDOF3_REG_WHO_AM_I 0x0F
67 #define SMARTDOF3_REG_CTRL1_XL 0x10
68 #define SMARTDOF3_REG_CTRL2_G 0x11
69 #define SMARTDOF3_REG_CTRL3_C 0x12
70 #define SMARTDOF3_REG_CTRL4_C 0x13
71 #define SMARTDOF3_REG_CTRL5_C 0x14
72 #define SMARTDOF3_REG_CTRL6_C 0x15
73 #define SMARTDOF3_REG_CTRL7_G 0x16
74 #define SMARTDOF3_REG_CTRL9_C 0x18
75 #define SMARTDOF3_REG_CTRL10_C 0x19
76 #define SMARTDOF3_REG_ISPU_INT_STATUS0_MP 0x1A
77 #define SMARTDOF3_REG_ISPU_INT_STATUS1_MP 0x1B
78 #define SMARTDOF3_REG_ISPU_INT_STATUS2_MP 0x1C
79 #define SMARTDOF3_REG_ISPU_INT_STATUS3_MP 0x1D
80 #define SMARTDOF3_REG_STATUS 0x1E
81 #define SMARTDOF3_REG_OUT_TEMP_L 0x20
82 #define SMARTDOF3_REG_OUT_TEMP_H 0x21
83 #define SMARTDOF3_REG_OUTX_L_G 0x22
84 #define SMARTDOF3_REG_OUTX_H_G 0x23
85 #define SMARTDOF3_REG_OUTY_L_G 0x24
86 #define SMARTDOF3_REG_OUTY_H_G 0x25
87 #define SMARTDOF3_REG_OUTZ_L_G 0x26
88 #define SMARTDOF3_REG_OUTZ_H_G 0x27
89 #define SMARTDOF3_REG_OUTX_L_A 0x28
90 #define SMARTDOF3_REG_OUTX_H_A 0x29
91 #define SMARTDOF3_REG_OUTY_L_A 0x2A
92 #define SMARTDOF3_REG_OUTY_H_A 0x2B
93 #define SMARTDOF3_REG_OUTZ_L_A 0x2C
94 #define SMARTDOF3_REG_OUTZ_H_A 0x2D
95 #define SMARTDOF3_REG_STATUS_MASTER_MAINPAGE 0x39
96 #define SMARTDOF3_REG_TIMESTAMP0 0x40
97 #define SMARTDOF3_REG_TIMESTAMP1 0x41
98 #define SMARTDOF3_REG_TIMESTAMP2 0x42
99 #define SMARTDOF3_REG_TIMESTAMP3 0x43
100 #define SMARTDOF3_REG_MD1_CFG 0x5E
101 #define SMARTDOF3_REG_MD2_CFG 0x5F
102 #define SMARTDOF3_REG_INTERNAL_FREQ_FINE 0x63
103 #define SMARTDOF3_REG_ISPU_DUMMY_CFG_1_L 0x73
104 #define SMARTDOF3_REG_ISPU_DUMMY_CFG_1_H 0x74
105 #define SMARTDOF3_REG_ISPU_DUMMY_CFG_2_L 0x75
106 #define SMARTDOF3_REG_ISPU_DUMMY_CFG_2_H 0x76
107 #define SMARTDOF3_REG_ISPU_DUMMY_CFG_3_L 0x77
108 #define SMARTDOF3_REG_ISPU_DUMMY_CFG_3_H 0x78
109 #define SMARTDOF3_REG_ISPU_DUMMY_CFG_4_L 0x79
110 #define SMARTDOF3_REG_ISPU_DUMMY_CFG_4_H 0x7A
128 #define SMARTDOF3_DEVICE_ID 0x22
134 #define SMARTDOF3_SOFT_RESET 0x01
135 #define SMARTDOF3_IF_INC_DISABLE 0x00
136 #define SMARTDOF3_IF_INC_ENABLE 0x04
137 #define SMARTDOF3_IF_INC_BIT_MASK 0xFB
138 #define SMARTDOF3_BDU_DISABLE 0x00
139 #define SMARTDOF3_BDU_ENABLE 0x40
140 #define SMARTDOF3_BDU_BIT_MASK 0xBF
146 #define SMARTDOF3_ODR_XL_G_OFF 0x00
147 #define SMARTDOF3_ODR_XL_G_12_5_HZ 0x01
148 #define SMARTDOF3_ODR_XL_G_26_HZ 0x02
149 #define SMARTDOF3_ODR_XL_G_52_HZ 0x03
150 #define SMARTDOF3_ODR_XL_G_104_HZ 0x04
151 #define SMARTDOF3_ODR_XL_G_208_HZ 0x05
152 #define SMARTDOF3_ODR_XL_G_416_HZ 0x06
153 #define SMARTDOF3_ODR_XL_G_833_HZ 0x07
154 #define SMARTDOF3_ODR_XL_G_1667_HZ 0x08
155 #define SMARTDOF3_ODR_XL_G_3333_HZ 0x09
156 #define SMARTDOF3_ODR_XL_G_6667_HZ 0x0A
157 #define SMARTDOF3_ODR_XL_G_BIT_MASK 0x0F
163 #define SMARTDOF3_XL_FULL_SCALE_2g 0x00
164 #define SMARTDOF3_XL_FULL_SCALE_16g 0x01
165 #define SMARTDOF3_XL_FULL_SCALE_4g 0x02
166 #define SMARTDOF3_XL_FULL_SCALE_8g 0x03
167 #define SMARTDOF3_XL_FULL_SCALE_BIT_MASK 0x03
173 #define SMARTDOF3_OP_MODE_PERFORMANCE_LOW 0x00
174 #define SMARTDOF3_OP_MODE_PERFORMANCE_HIGH 0x01
180 #define SMARTDOF3_TIMESTAMP_ENABLE 0x20
186 #define SMARTDOF3_ACC_SENSITIVITY_FS_2g 0.061
187 #define SMARTDOF3_ACC_SENSITIVITY_FS_4g 0.122
188 #define SMARTDOF3_ACC_SENSITIVITY_FS_8g 0.244
189 #define SMARTDOF3_ACC_SENSITIVITY_FS_16g 0.488
195 #define SMARTDOF3_GY_FULL_SCALE_125dps 0x01
196 #define SMARTDOF3_GY_FULL_SCALE_250dps 0x00
197 #define SMARTDOF3_GY_FULL_SCALE_500dps 0x02
198 #define SMARTDOF3_GY_FULL_SCALE_1000dps 0x04
199 #define SMARTDOF3_GY_FULL_SCALE_2000dps 0x06
200 #define SMARTDOF3_GY_FULL_SCALE_BIT_MASK 0x07
206 #define SMARTDOF3_GYRO_SENSITIVITY_FS_125dps 0.004375
207 #define SMARTDOF3_GYRO_SENSITIVITY_FS_250dps 0.00875
208 #define SMARTDOF3_GYRO_SENSITIVITY_FS_500dps 0.0175
209 #define SMARTDOF3_GYRO_SENSITIVITY_FS_1000dps 0.035
210 #define SMARTDOF3_GYRO_SENSITIVITY_FS_2000dps 0.07
217 #define SMARTDOF3_DEVICE_ADDRESS_GND 0x6A
218 #define SMARTDOF3_DEVICE_ADDRESS_VCC 0x6B
228 #define SMARTDOF3_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
229 #define SMARTDOF3_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
247 #define SMARTDOF3_MAP_MIKROBUS( cfg, mikrobus ) \
248 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
249 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
250 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
251 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
252 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
253 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
254 cfg.it2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
255 cfg.it1 = MIKROBUS( mikrobus, MIKROBUS_INT )
844 #endif // SMARTDOF3_H
digital_in_t it1
Definition: smartdof3.h:284
err_t smartdof3_default_cfg(smartdof3_t *ctx)
Smart DOF 3 default configuration function.
err_t smartdof3_get_gyro_sensitivity(smartdof3_t *ctx, float *sensitivity)
Smart DOF 3 get the gyro sensitivity function.
smartdof3_return_value_t
Smart DOF 3 Click return value data.
Definition: smartdof3.h:365
uint8_t xlda
Definition: smartdof3.h:332
smartdof3_drv_t
Smart DOF 3 Click driver selector.
Definition: smartdof3.h:265
smartdof3_master_io_t read_f
Definition: smartdof3.h:294
int16_t x
Definition: smartdof3.h:342
err_t smartdof3_get_gyro_axis_data(smartdof3_t *ctx, smartdof3_axis_data_t *gyro_axis)
Smart DOF 3 get the gyro data function.
err_t smartdof3_generic_write(smartdof3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Smart DOF 3 data writing function.
pin_name_t miso
Definition: smartdof3.h:306
Smart DOF 3 Click sensor axes structure object.
Definition: smartdof3.h:353
smartdof3_drv_t drv_sel
Definition: smartdof3.h:291
err_t smartdof3_soft_reset(smartdof3_t *ctx)
Smart DOF 3 software reset function.
void smartdof3_drv_interface_selection(smartdof3_cfg_t *cfg, smartdof3_drv_t drv_sel)
Smart DOF 3 driver interface setup function.
uint8_t slave_address
Definition: smartdof3.h:289
i2c_master_t i2c
Definition: smartdof3.h:286
This file contains SPI specific macros, functions, etc.
smartdof3_master_io_t write_f
Definition: smartdof3.h:293
err_t smartdof3_enable_auto_increment(smartdof3_t *ctx)
Smart DOF 3 enable auto-increment function.
err_t smartdof3_set_acc_full_scale(smartdof3_t *ctx, uint8_t data_scale)
Smart DOF 3 sets the accel full-scale range function.
pin_name_t scl
Definition: smartdof3.h:304
Smart DOF 3 Click context object.
Definition: smartdof3.h:282
@ SMARTDOF3_ERROR
Definition: smartdof3.h:367
err_t smartdof3_get_acc_full_scale(smartdof3_t *ctx, uint8_t *data_scale)
Smart DOF 3 get the accel full-scale range function.
err_t smartdof3_get_acc_axis_data(smartdof3_t *ctx, smartdof3_axis_data_t *acc_axis)
Smart DOF 3 get the accel data function.
err_t smartdof3_get_acc_sensitivity(smartdof3_t *ctx, float *sensitivity)
Smart DOF 3 get the accel sensitivity function.
err_t(* smartdof3_master_io_t)(struct smartdof3_s *, uint8_t, uint8_t *, uint8_t)
Smart DOF 3 Click driver interface.
Definition: smartdof3.h:275
err_t smartdof3_get_status(smartdof3_t *ctx, smartdof3_status_t *status)
Smart DOF 3 get the status function.
err_t smartdof3_generic_read(smartdof3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Smart DOF 3 data reading function.
err_t smartdof3_set_op_mode(smartdof3_t *ctx, uint8_t acc_op_mode, uint8_t gyro_op_mode)
Smart DOF 3 sets the operation mode function.
int16_t y
Definition: smartdof3.h:343
uint8_t i2c_address
Definition: smartdof3.h:314
Smart DOF 3 Click configuration object.
Definition: smartdof3.h:303
void smartdof3_cfg_setup(smartdof3_cfg_t *cfg)
Smart DOF 3 configuration object setup function.
@ SMARTDOF3_DRV_SEL_SPI
Definition: smartdof3.h:266
struct smartdof3_s smartdof3_t
Smart DOF 3 Click context object.
uint8_t tda
Definition: smartdof3.h:330
pin_name_t it1
Definition: smartdof3.h:311
uint32_t i2c_speed
Definition: smartdof3.h:313
err_t smartdof3_enable_temperature(smartdof3_t *ctx)
Smart DOF 3 enable the temperature function.
float z
Definition: smartdof3.h:356
pin_name_t sda
Definition: smartdof3.h:305
err_t smartdof3_set_acc_data_rate(smartdof3_t *ctx, uint8_t data_rate)
Smart DOF 3 sets the accel data rate function.
uint8_t smartdof3_get_in1_pin(smartdof3_t *ctx)
Smart DOF 3 get interrupt 1 function.
int16_t z
Definition: smartdof3.h:344
err_t smartdof3_get_gyro_full_scale(smartdof3_t *ctx, uint8_t *data_scale)
Smart DOF 3 get the gyro full-scale range function.
err_t smartdof3_set_gyro_data_rate(smartdof3_t *ctx, uint8_t data_rate)
Smart DOF 3 sets the gyro data rate function.
float x
Definition: smartdof3.h:354
@ SMARTDOF3_OK
Definition: smartdof3.h:366
err_t smartdof3_get_device_id(smartdof3_t *ctx, uint8_t *device_id)
Smart DOF 3 get device ID function.
uint8_t smartdof3_get_in2_pin(smartdof3_t *ctx)
Smart DOF 3 get interrupt 2 function.
pin_name_t mosi
Definition: smartdof3.h:307
pin_name_t sck
Definition: smartdof3.h:308
err_t smartdof3_get_temperature(smartdof3_t *ctx, float *temperature)
Smart DOF 3 get the temperature function.
smartdof3_drv_t drv_sel
Definition: smartdof3.h:320
err_t smartdof3_init(smartdof3_t *ctx, smartdof3_cfg_t *cfg)
Smart DOF 3 initialization function.
err_t smartdof3_get_gyro_axis(smartdof3_t *ctx, smartdof3_axis_t *gyro_axis)
Smart DOF 3 get the gyro sensor axes function.
@ SMARTDOF3_DRV_SEL_I2C
Definition: smartdof3.h:267
uint8_t gda
Definition: smartdof3.h:331
spi_master_mode_t spi_mode
Definition: smartdof3.h:317
err_t smartdof3_set_gyro_full_scale(smartdof3_t *ctx, uint8_t data_scale)
Smart DOF 3 sets the gyro full-scale range function.
float y
Definition: smartdof3.h:355
pin_name_t cs
Definition: smartdof3.h:309
Smart DOF 3 Click sensor status structure object.
Definition: smartdof3.h:329
uint32_t spi_speed
Definition: smartdof3.h:316
digital_in_t it2
Definition: smartdof3.h:283
err_t smartdof3_enable_block_data_update(smartdof3_t *ctx)
Smart DOF 3 enable block data update function.
Smart DOF 3 Click axis raw data structure object.
Definition: smartdof3.h:341
err_t smartdof3_get_temperature_raw(smartdof3_t *ctx, int16_t *temp_raw)
Smart DOF 3 get the temperature data function.
pin_name_t chip_select
Definition: smartdof3.h:290
err_t smartdof3_get_acc_axis(smartdof3_t *ctx, smartdof3_axis_t *acc_axis)
Smart DOF 3 get the accel sensor axes function.
spi_master_chip_select_polarity_t cs_polarity
Definition: smartdof3.h:318
spi_master_t spi
Definition: smartdof3.h:287
pin_name_t it2
Definition: smartdof3.h:310