39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52#include "drv_spi_master.h"
75#define SMARTDOF3_REG_FUNC_CFG_ACCESS 0x01
76#define SMARTDOF3_REG_PIN_CTRL 0x02
77#define SMARTDOF3_REG_DRDY_PULSED_REG 0x0B
78#define SMARTDOF3_REG_INT1_CTRL 0x0D
79#define SMARTDOF3_REG_INT2_CTRL 0x0E
80#define SMARTDOF3_REG_WHO_AM_I 0x0F
81#define SMARTDOF3_REG_CTRL1_XL 0x10
82#define SMARTDOF3_REG_CTRL2_G 0x11
83#define SMARTDOF3_REG_CTRL3_C 0x12
84#define SMARTDOF3_REG_CTRL4_C 0x13
85#define SMARTDOF3_REG_CTRL5_C 0x14
86#define SMARTDOF3_REG_CTRL6_C 0x15
87#define SMARTDOF3_REG_CTRL7_G 0x16
88#define SMARTDOF3_REG_CTRL9_C 0x18
89#define SMARTDOF3_REG_CTRL10_C 0x19
90#define SMARTDOF3_REG_ISPU_INT_STATUS0_MP 0x1A
91#define SMARTDOF3_REG_ISPU_INT_STATUS1_MP 0x1B
92#define SMARTDOF3_REG_ISPU_INT_STATUS2_MP 0x1C
93#define SMARTDOF3_REG_ISPU_INT_STATUS3_MP 0x1D
94#define SMARTDOF3_REG_STATUS 0x1E
95#define SMARTDOF3_REG_OUT_TEMP_L 0x20
96#define SMARTDOF3_REG_OUT_TEMP_H 0x21
97#define SMARTDOF3_REG_OUTX_L_G 0x22
98#define SMARTDOF3_REG_OUTX_H_G 0x23
99#define SMARTDOF3_REG_OUTY_L_G 0x24
100#define SMARTDOF3_REG_OUTY_H_G 0x25
101#define SMARTDOF3_REG_OUTZ_L_G 0x26
102#define SMARTDOF3_REG_OUTZ_H_G 0x27
103#define SMARTDOF3_REG_OUTX_L_A 0x28
104#define SMARTDOF3_REG_OUTX_H_A 0x29
105#define SMARTDOF3_REG_OUTY_L_A 0x2A
106#define SMARTDOF3_REG_OUTY_H_A 0x2B
107#define SMARTDOF3_REG_OUTZ_L_A 0x2C
108#define SMARTDOF3_REG_OUTZ_H_A 0x2D
109#define SMARTDOF3_REG_STATUS_MASTER_MAINPAGE 0x39
110#define SMARTDOF3_REG_TIMESTAMP0 0x40
111#define SMARTDOF3_REG_TIMESTAMP1 0x41
112#define SMARTDOF3_REG_TIMESTAMP2 0x42
113#define SMARTDOF3_REG_TIMESTAMP3 0x43
114#define SMARTDOF3_REG_MD1_CFG 0x5E
115#define SMARTDOF3_REG_MD2_CFG 0x5F
116#define SMARTDOF3_REG_INTERNAL_FREQ_FINE 0x63
117#define SMARTDOF3_REG_ISPU_DUMMY_CFG_1_L 0x73
118#define SMARTDOF3_REG_ISPU_DUMMY_CFG_1_H 0x74
119#define SMARTDOF3_REG_ISPU_DUMMY_CFG_2_L 0x75
120#define SMARTDOF3_REG_ISPU_DUMMY_CFG_2_H 0x76
121#define SMARTDOF3_REG_ISPU_DUMMY_CFG_3_L 0x77
122#define SMARTDOF3_REG_ISPU_DUMMY_CFG_3_H 0x78
123#define SMARTDOF3_REG_ISPU_DUMMY_CFG_4_L 0x79
124#define SMARTDOF3_REG_ISPU_DUMMY_CFG_4_H 0x7A
142#define SMARTDOF3_DEVICE_ID 0x22
148#define SMARTDOF3_CTRL3_SOFT_RESET 0x01
149#define SMARTDOF3_CTRL3_IF_INC_DISABLE 0x00
150#define SMARTDOF3_CTRL3_IF_INC_ENABLE 0x04
151#define SMARTDOF3_CTRL3_IF_INC_BIT_MASK 0xFB
152#define SMARTDOF3_CTRL3_BDU_DISABLE 0x00
153#define SMARTDOF3_CTRL3_BDU_ENABLE 0x40
154#define SMARTDOF3_CTRL3_BDU_BIT_MASK 0xBF
160#define SMARTDOF3_ODR_XL_G_OFF 0x00
161#define SMARTDOF3_ODR_XL_G_12_5_HZ 0x01
162#define SMARTDOF3_ODR_XL_G_26_HZ 0x02
163#define SMARTDOF3_ODR_XL_G_52_HZ 0x03
164#define SMARTDOF3_ODR_XL_G_104_HZ 0x04
165#define SMARTDOF3_ODR_XL_G_208_HZ 0x05
166#define SMARTDOF3_ODR_XL_G_416_HZ 0x06
167#define SMARTDOF3_ODR_XL_G_833_HZ 0x07
168#define SMARTDOF3_ODR_XL_G_1667_HZ 0x08
169#define SMARTDOF3_ODR_XL_G_3333_HZ 0x09
170#define SMARTDOF3_ODR_XL_G_6667_HZ 0x0A
171#define SMARTDOF3_ODR_XL_G_BIT_MASK 0x0F
177#define SMARTDOF3_XL_FULL_SCALE_2G 0x00
178#define SMARTDOF3_XL_FULL_SCALE_16G 0x01
179#define SMARTDOF3_XL_FULL_SCALE_4G 0x02
180#define SMARTDOF3_XL_FULL_SCALE_8G 0x03
181#define SMARTDOF3_XL_FULL_SCALE_BIT_MASK 0x03
187#define SMARTDOF3_OP_MODE_PERFORMANCE_LOW 0x00
188#define SMARTDOF3_OP_MODE_PERFORMANCE_HIGH 0x01
194#define SMARTDOF3_TIMESTAMP_ENABLE 0x20
200#define SMARTDOF3_ACC_SENSITIVITY_FS_2G 0.061
201#define SMARTDOF3_ACC_SENSITIVITY_FS_4G 0.122
202#define SMARTDOF3_ACC_SENSITIVITY_FS_8G 0.244
203#define SMARTDOF3_ACC_SENSITIVITY_FS_16G 0.488
209#define SMARTDOF3_GY_FULL_SCALE_125DPS 0x01
210#define SMARTDOF3_GY_FULL_SCALE_250DPS 0x00
211#define SMARTDOF3_GY_FULL_SCALE_500DPS 0x02
212#define SMARTDOF3_GY_FULL_SCALE_1000DPS 0x04
213#define SMARTDOF3_GY_FULL_SCALE_2000DPS 0x06
214#define SMARTDOF3_GY_FULL_SCALE_BIT_MASK 0x07
220#define SMARTDOF3_GYRO_SENSITIVITY_FS_125DPS 0.004375
221#define SMARTDOF3_GYRO_SENSITIVITY_FS_250DPS 0.00875
222#define SMARTDOF3_GYRO_SENSITIVITY_FS_500DPS 0.0175
223#define SMARTDOF3_GYRO_SENSITIVITY_FS_1000DPS 0.035
224#define SMARTDOF3_GYRO_SENSITIVITY_FS_2000DPS 0.07
231#define SMARTDOF3_DEVICE_ADDRESS_GND 0x6A
232#define SMARTDOF3_DEVICE_ADDRESS_VCC 0x6B
242#define SMARTDOF3_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
243#define SMARTDOF3_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
261#define SMARTDOF3_MAP_MIKROBUS( cfg, mikrobus ) \
262 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
263 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
264 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
265 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
266 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
267 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
268 cfg.it2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
269 cfg.it1 = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t smartdof3_init(smartdof3_t *ctx, smartdof3_cfg_t *cfg)
Smart DOF 3 initialization function.
uint8_t smartdof3_get_in1_pin(smartdof3_t *ctx)
Smart DOF 3 get interrupt 1 function.
err_t smartdof3_get_acc_sensitivity(smartdof3_t *ctx, float *sensitivity)
Smart DOF 3 get the accel sensitivity function.
err_t smartdof3_get_gyro_sensitivity(smartdof3_t *ctx, float *sensitivity)
Smart DOF 3 get the gyro sensitivity function.
void smartdof3_drv_interface_selection(smartdof3_cfg_t *cfg, smartdof3_drv_t drv_sel)
Smart DOF 3 driver interface setup 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.
uint8_t smartdof3_get_in2_pin(smartdof3_t *ctx)
Smart DOF 3 get interrupt 2 function.
void smartdof3_cfg_setup(smartdof3_cfg_t *cfg)
Smart DOF 3 configuration object setup function.
err_t smartdof3_en_block_data_upd(smartdof3_t *ctx)
Smart DOF 3 enable block data update function.
err_t smartdof3_get_device_id(smartdof3_t *ctx, uint8_t *device_id)
Smart DOF 3 get device ID function.
err_t smartdof3_get_temperature_raw(smartdof3_t *ctx, int16_t *temp_raw)
Smart DOF 3 get the temperature data function.
err_t smartdof3_get_gyro_axis(smartdof3_t *ctx, smartdof3_axis_t *gyro_axis)
Smart DOF 3 get the gyro sensor axes 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.
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_set_gyro_data_rate(smartdof3_t *ctx, uint8_t data_rate)
Smart DOF 3 sets the gyro data rate function.
err_t smartdof3_get_acc_axis(smartdof3_t *ctx, smartdof3_axis_t *acc_axis)
Smart DOF 3 get the accel sensor axes function.
err_t smartdof3_default_cfg(smartdof3_t *ctx)
Smart DOF 3 default configuration function.
err_t smartdof3_enable_temperature(smartdof3_t *ctx)
Smart DOF 3 enable the temperature function.
err_t smartdof3_get_temperature(smartdof3_t *ctx, float *temperature)
Smart DOF 3 get the temperature function.
err_t smartdof3_set_acc_data_rate(smartdof3_t *ctx, uint8_t data_rate)
Smart DOF 3 sets the accel data rate function.
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_generic_write(smartdof3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Smart DOF 3 data writing 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_gyro_full_scale(smartdof3_t *ctx, uint8_t data_scale)
Smart DOF 3 sets the gyro full-scale range function.
err_t smartdof3_en_auto_incr(smartdof3_t *ctx)
Smart DOF 3 enable auto-increment 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_soft_reset(smartdof3_t *ctx)
Smart DOF 3 software reset function.
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_get_status(smartdof3_t *ctx, smartdof3_status_t *status)
Smart DOF 3 get the status function.
smartdof3_drv_t
Smart DOF 3 Click driver selector.
Definition smartdof3.h:279
@ SMARTDOF3_DRV_SEL_SPI
Definition smartdof3.h:280
@ SMARTDOF3_DRV_SEL_I2C
Definition smartdof3.h:281
struct smartdof3_s smartdof3_t
Smart DOF 3 Click context object.
err_t(* smartdof3_master_io_t)(struct smartdof3_s *, uint8_t, uint8_t *, uint8_t)
Smart DOF 3 Click driver interface.
Definition smartdof3.h:289
smartdof3_return_value_t
Smart DOF 3 Click return value data.
Definition smartdof3.h:379
@ SMARTDOF3_ERROR
Definition smartdof3.h:381
@ SMARTDOF3_OK
Definition smartdof3.h:380
This file contains SPI specific macros, functions, etc.
Smart DOF 3 Click axis raw data structure object.
Definition smartdof3.h:355
int16_t z
Definition smartdof3.h:358
int16_t x
Definition smartdof3.h:356
int16_t y
Definition smartdof3.h:357
Smart DOF 3 Click sensor axes structure object.
Definition smartdof3.h:367
float y
Definition smartdof3.h:369
float x
Definition smartdof3.h:368
float z
Definition smartdof3.h:370
Smart DOF 3 Click configuration object.
Definition smartdof3.h:317
pin_name_t it2
Definition smartdof3.h:324
uint32_t i2c_speed
Definition smartdof3.h:327
pin_name_t it1
Definition smartdof3.h:325
smartdof3_drv_t drv_sel
Definition smartdof3.h:334
spi_master_chip_select_polarity_t cs_polarity
Definition smartdof3.h:332
pin_name_t sck
Definition smartdof3.h:322
spi_master_mode_t spi_mode
Definition smartdof3.h:331
pin_name_t mosi
Definition smartdof3.h:321
uint32_t spi_speed
Definition smartdof3.h:330
pin_name_t scl
Definition smartdof3.h:318
pin_name_t miso
Definition smartdof3.h:320
pin_name_t sda
Definition smartdof3.h:319
pin_name_t cs
Definition smartdof3.h:323
uint8_t i2c_address
Definition smartdof3.h:328
Smart DOF 3 Click context object.
Definition smartdof3.h:296
spi_master_t spi
Definition smartdof3.h:301
digital_in_t it2
Definition smartdof3.h:297
smartdof3_drv_t drv_sel
Definition smartdof3.h:305
smartdof3_master_io_t read_f
Definition smartdof3.h:308
i2c_master_t i2c
Definition smartdof3.h:300
uint8_t slave_address
Definition smartdof3.h:303
smartdof3_master_io_t write_f
Definition smartdof3.h:307
pin_name_t chip_select
Definition smartdof3.h:304
digital_in_t it1
Definition smartdof3.h:298
Smart DOF 3 Click sensor status structure object.
Definition smartdof3.h:343
uint8_t tda
Definition smartdof3.h:344
uint8_t gda
Definition smartdof3.h:345
uint8_t xlda
Definition smartdof3.h:346