42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55#include "drv_spi_master.h"
68#define C6DOFIMU8_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
70 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
71 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
72 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
73 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
74 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
75 cfg.it2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
76 cfg.it1 = MIKROBUS( mikrobus, MIKROBUS_INT );
83#define C6DOFIMU8_MASTER_I2C 0
84#define C6DOFIMU8_MASTER_SPI 1
91#define C6DOFIMU8_RETVAL uint8_t
93#define C6DOFIMU8_OK 0x00
94#define C6DOFIMU8_INIT_ERROR 0xFF
101#define C6DOFIMU8_DEVICE_ADDR_LSB_LOW 0x6A
102#define C6DOFIMU8_DEVICE_ADDR_LSB_HIGH 0x6B
109#define C6DOFIMU8_FUNC_CFG_ACCESS_REG 0x01
110#define C6DOFIMU8_SENS_SYNC_TIME_FRAME_REG 0x04
111#define C6DOFIMU8_SENS_SYNC_RES_RATIO_REG 0x05
112#define C6DOFIMU8_FIFO_CTRL1_REG 0x06
113#define C6DOFIMU8_FIFO_CTRL2_REG 0x07
114#define C6DOFIMU8_FIFO_CTRL3_REG 0x08
115#define C6DOFIMU8_FIFO_CTRL4_REG 0x09
116#define C6DOFIMU8_FIFO_CTRL5_REG 0x0A
117#define C6DOFIMU8_DRDY_PULSE_CFG_REG 0x0B
118#define C6DOFIMU8_INT1_CTRL_REG 0x0D
119#define C6DOFIMU8_INT2_CTRL_REG 0x0E
120#define C6DOFIMU8_WHO_AM_I_REG 0x0F
121#define C6DOFIMU8_CTRL1_XL_REG 0x10
122#define C6DOFIMU8_CTRL2_G_REG 0x11
123#define C6DOFIMU8_CTRL3_C_REG 0x12
124#define C6DOFIMU8_CTRL4_C_REG 0x13
125#define C6DOFIMU8_CTRL5_C_REG 0x14
126#define C6DOFIMU8_CTRL6_C_REG 0x15
127#define C6DOFIMU8_CTRL7_G_REG 0x16
128#define C6DOFIMU8_CTRL8_XL_REG 0x17
129#define C6DOFIMU8_CTRL9_XL_REG 0x18
130#define C6DOFIMU8_CTRL10_C_REG 0x19
131#define C6DOFIMU8_MASTER_CFG_REG 0x1A
132#define C6DOFIMU8_WAKE_UP_SRC_REG 0x1B
133#define C6DOFIMU8_TAP_SRC_REG 0x1C
134#define C6DOFIMU8_D6D_SRC_REG 0x1D
135#define C6DOFIMU8_STATUS_REG 0x1E
136#define C6DOFIMU8_OUT_TEMP_REG 0x20
137#define C6DOFIMU8_OUTX_G_REG 0x22
138#define C6DOFIMU8_OUTY_G_REG 0x24
139#define C6DOFIMU8_OUTZ_G_REG 0x26
140#define C6DOFIMU8_OUTX_XL_REG 0x28
141#define C6DOFIMU8_OUTY_XL_REG 0x2A
142#define C6DOFIMU8_OUTZ_XL_REG 0x2C
143#define C6DOFIMU8_SENS_HUB1_REG 0x2E
144#define C6DOFIMU8_SENS_HUB2_REG 0x2F
145#define C6DOFIMU8_SENS_HUB3_REG 0x30
146#define C6DOFIMU8_SENS_HUB4_REG 0x31
147#define C6DOFIMU8_SENS_HUB5_REG 0x32
148#define C6DOFIMU8_SENS_HUB6_REG 0x33
149#define C6DOFIMU8_SENS_HUB7_REG 0x34
150#define C6DOFIMU8_SENS_HUB8_REG 0x35
151#define C6DOFIMU8_SENS_HUB9_REG 0x36
152#define C6DOFIMU8_SENS_HUB10_REG 0x37
153#define C6DOFIMU8_SENS_HUB11_REG 0x38
154#define C6DOFIMU8_SENS_HUB12_REG 0x39
155#define C6DOFIMU8_FIFO_STATUS1_REG 0x3A
156#define C6DOFIMU8_FIFO_STATUS2_REG 0x3B
157#define C6DOFIMU8_FIFO_STATUS3_REG 0x3C
158#define C6DOFIMU8_FIFO_STATUS4_REG 0x3D
159#define C6DOFIMU8_FIFO_DATA_OUT_REG 0x3E
160#define C6DOFIMU8_TIMESTAMP0_REG 0x40
161#define C6DOFIMU8_TIMESTAMP1_REG 0x41
162#define C6DOFIMU8_TIMESTAMP2_REG 0x42
163#define C6DOFIMU8_SENS_HUB13_REG 0x4D
164#define C6DOFIMU8_SENS_HUB14_REG 0x4E
165#define C6DOFIMU8_SENS_HUB15_REG 0x4F
166#define C6DOFIMU8_SENS_HUB16_REG 0x50
167#define C6DOFIMU8_SENS_HUB17_REG 0x51
168#define C6DOFIMU8_SENS_HUB18_REG 0x52
169#define C6DOFIMU8_FUNC_SRC1_REG 0x53
170#define C6DOFIMU8_FUNC_SRC2_REG 0x54
171#define C6DOFIMU8_TAP_CFG_REG 0x58
172#define C6DOFIMU8_TAP_THS_6D_REG 0x59
173#define C6DOFIMU8_INT_DUR2_REG 0x5A
174#define C6DOFIMU8_WAKE_UP_THS_REG 0x5B
175#define C6DOFIMU8_WAKE_UP_DUR_REG 0x5C
176#define C6DOFIMU8_FREE_FALL_REG 0x5D
177#define C6DOFIMU8_MD1_CFG_REG 0x5E
178#define C6DOFIMU8_MD2_CFG_REG 0x5F
179#define C6DOFIMU8_MASTER_CMD_CODE_REG 0x60
180#define C6DOFIMU8_SENS_SYNC_SPI_ERR_CODE_REG 0x61
181#define C6DOFIMU8_OUT_MAG_RAW_X_REG 0x66
182#define C6DOFIMU8_OUT_MAG_RAW_Y_REG 0x68
183#define C6DOFIMU8_OUT_MAG_RAW_Z_REG 0x6A
184#define C6DOFIMU8_INT_OIS_REG 0x6F
185#define C6DOFIMU8_CTRL1_OIS_REG 0x70
186#define C6DOFIMU8_CTRL2_OIS_REG 0x71
187#define C6DOFIMU8_CTRL3_OIS_REG 0x72
188#define C6DOFIMU8_X_OFS_USR_REG 0x73
189#define C6DOFIMU8_Y_OFS_USR_REG 0x74
190#define C6DOFIMU8_Z_OFS_USR_REG 0x75
197#define C6DOFIMU8_REG_ACCESS_EN 0x80
204#define C6DOFIMU8_DEC_FIFO_XL_SENS_NOT_IN_FIFO 0x00
205#define C6DOFIMU8_DEC_FIFO_XL_NO_DEC 0x01
206#define C6DOFIMU8_DEC_FIFO_XL_FACTOR2 0x02
207#define C6DOFIMU8_DEC_FIFO_XL_FACTOR3 0x03
208#define C6DOFIMU8_DEC_FIFO_XL_FACTOR4 0x04
209#define C6DOFIMU8_DEC_FIFO_XL_FACTOR8 0x05
210#define C6DOFIMU8_DEC_FIFO_XL_FACTOR16 0x06
211#define C6DOFIMU8_DEC_FIFO_XL_FACTOR32 0x07
212#define C6DOFIMU8_DEC_FIFO_G_SENS_NOT_IN_FIFO 0x00
213#define C6DOFIMU8_DEC_FIFO_G_NO_DEC 0x08
214#define C6DOFIMU8_DEC_FIFO_G_FACTOR2 0x10
215#define C6DOFIMU8_DEC_FIFO_G_FACTOR3 0x18
216#define C6DOFIMU8_DEC_FIFO_G_FACTOR4 0x20
217#define C6DOFIMU8_DEC_FIFO_G_FACTOR8 0x28
218#define C6DOFIMU8_DEC_FIFO_G_FACTOR16 0x30
219#define C6DOFIMU8_DEC_FIFO_G_FACTOR32 0x38
226#define C6DOFIMU8_FIFO_ODR_DIS 0x00
227#define C6DOFIMU8_FIFO_ODR_12_5_HZ 0x08
228#define C6DOFIMU8_FIFO_ODR_26_HZ 0x10
229#define C6DOFIMU8_FIFO_ODR_52_HZ 0x18
230#define C6DOFIMU8_FIFO_ODR_104_HZ 0x20
231#define C6DOFIMU8_FIFO_ODR_208_HZ 0x28
232#define C6DOFIMU8_FIFO_ODR_416_HZ 0x30
233#define C6DOFIMU8_FIFO_ODR_833_HZ 0x38
234#define C6DOFIMU8_FIFO_ODR_1660_HZ 0x40
235#define C6DOFIMU8_FIFO_ODR_3330_HZ 0x48
236#define C6DOFIMU8_FIFO_ODR_6660_HZ 0x50
237#define C6DOFIMU8_FIFO_BYPASS1_MODE 0x00
238#define C6DOFIMU8_FIFO_FIFO_MODE 0x01
239#define C6DOFIMU8_FIFO_CONT1_MODE 0x03
240#define C6DOFIMU8_FIFO_BYPASS2_MODE 0x04
241#define C6DOFIMU8_FIFO_CONT2_MODE 0x06
248#define C6DOFIMU8_DRDY_LATCHED_MODE 0x00
249#define C6DOFIMU8_DRDY_PULSED_MODE 0x80
256#define C6DOFIMU8_INT_PIN_FIFO_FULL_FLAG_EN 0x20
257#define C6DOFIMU8_INT_PIN_FIFO_OVERRUN_FLAG_EN 0x10
258#define C6DOFIMU8_INT_PIN_FIFO_THRESH_FLAG_EN 0x08
259#define C6DOFIMU8_INT1_PIN_BOOT_STATUS_FLAG_EN 0x04
260#define C6DOFIMU8_INT2_PIN_TEMP_DRDY_FLAG_EN 0x04
261#define C6DOFIMU8_INT_PIN_G_DRDY_FLAG_EN 0x02
262#define C6DOFIMU8_INT_PIN_XL_DRDY_FLAG_EN 0x01
269#define C6DOFIMU8_ODR_POWER_DOWN 0x00
270#define C6DOFIMU8_ODR_1_6_HZ 0x0B
271#define C6DOFIMU8_ODR_12_5_HZ 0x01
272#define C6DOFIMU8_ODR_26_HZ 0x02
273#define C6DOFIMU8_ODR_52_HZ 0x03
274#define C6DOFIMU8_ODR_104_HZ 0x04
275#define C6DOFIMU8_ODR_208_HZ 0x05
276#define C6DOFIMU8_ODR_416_HZ 0x06
277#define C6DOFIMU8_ODR_833_HZ 0x07
278#define C6DOFIMU8_ODR_1660_HZ 0x08
279#define C6DOFIMU8_ODR_3330_HZ 0x09
280#define C6DOFIMU8_ODR_6660_HZ 0x0A
281#define C6DOFIMU8_FS_XL_2G 0x00
282#define C6DOFIMU8_FS_XL_16G 0x01
283#define C6DOFIMU8_FS_XL_4G 0x02
284#define C6DOFIMU8_FS_XL_8G 0x03
285#define C6DOFIMU8_FS_G_250DPS 0x00
286#define C6DOFIMU8_FS_G_500DPS 0x01
287#define C6DOFIMU8_FS_G_1000DPS 0x02
288#define C6DOFIMU8_FS_G_2000DPS 0x03
289#define C6DOFIMU8_FS_G_125DPS 0x04
290#define C6DOFIMU8_BW_XL_1500_HZ 0x00
291#define C6DOFIMU8_BW_XL_400_HZ 0x01
298#define C6DOFIMU8_NORMAL_MODE 0x00
299#define C6DOFIMU8_REBOOT_MEM_CONTENT 0x80
300#define C6DOFIMU8_CONT_UPDATE 0x00
301#define C6DOFIMU8_READ_UPDATE 0x40
302#define C6DOFIMU8_INT_OUT_PADS_ACT_HIGH 0x00
303#define C6DOFIMU8_INT_OUT_PADS_ACT_LOW 0x20
304#define C6DOFIMU8_PADS_PUSH_PULL_MODE 0x00
305#define C6DOFIMU8_PADS_OPEN_DRAIN_MODE 0x10
306#define C6DOFIMU8_SPI_4_WIRE_INTER 0x00
307#define C6DOFIMU8_SPI_3_WIRE_INTER 0x08
308#define C6DOFIMU8_REG_ADDR_AUTO_INC_EN 0x04
309#define C6DOFIMU8_DATA_LSB 0x00
310#define C6DOFIMU8_DATA_MSB 0x02
311#define C6DOFIMU8_SW_RESET_CMD 0x01
318#define C6DOFIMU8_DEN_XL_EN 0x80
319#define C6DOFIMU8_G_SLEEP_MODE_EN 0x40
320#define C6DOFIMU8_INT1_PAD_ONLY_EN 0x20
321#define C6DOFIMU8_DEN_DRDY_INT1_EN 0x10
322#define C6DOFIMU8_DA_TIMER_EN 0x08
323#define C6DOFIMU8_I2C_INTER_DIS 0x04
324#define C6DOFIMU8_LPF1_SEL_G_EN 0x02
331#define C6DOFIMU8_NO_ROUNDING 0x00
332#define C6DOFIMU8_ROUND_XL_ONLY 0x20
333#define C6DOFIMU8_ROUND_G_ONLY 0x40
334#define C6DOFIMU8_ROUND_G_AND_XL 0x60
335#define C6DOFIMU8_DEN_ACT_LOW 0x00
336#define C6DOFIMU8_DEN_ACT_HIGH 0x10
337#define C6DOFIMU8_ST_G_NORMAL_MODE 0x00
338#define C6DOFIMU8_ST_G_POS_SIGN 0x04
339#define C6DOFIMU8_ST_G_NEG_SIGN 0x0C
340#define C6DOFIMU8_ST_XL_NORMAL_MODE 0x00
341#define C6DOFIMU8_ST_XL_POS_SIGN 0x01
342#define C6DOFIMU8_ST_XL_NEG_SIGN 0x02
349#define C6DOFIMU8_G_HP_OP_MODE_DIS 0x80
350#define C6DOFIMU8_G_HPF_EN 0x40
351#define C6DOFIMU8_G_HPF_16_MILLI_HZ 0x00
352#define C6DOFIMU8_G_HPF_65_MILLI_HZ 0x10
353#define C6DOFIMU8_G_HPF_260_MILLI_HZ 0x20
354#define C6DOFIMU8_G_HPF_1040_MILLI_HZ 0x30
355#define C6DOFIMU8_ROUNDING_EN 0x04
362#define C6DOFIMU8_DEN_X_LSB_STORED 0x80
363#define C6DOFIMU8_DEN_Y_LSB_STORED 0x40
364#define C6DOFIMU8_DEN_Z_LSB_STORED 0x20
365#define C6DOFIMU8_DEN_G_STAMPED 0x00
366#define C6DOFIMU8_DEN_XL_STAMPED 0x10
367#define C6DOFIMU8_SOFT_IRON_CORR_ALGO_EN 0x04
374#define C6DOFIMU8_FREE_FALL_EVENT_MASK 0x20
375#define C6DOFIMU8_SLEEP_EVENT_MASK 0x10
376#define C6DOFIMU8_WAKE_UP_EVENT_MASK 0x08
377#define C6DOFIMU8_X_WAKEUP_EVENT_MASK 0x04
378#define C6DOFIMU8_Y_WAKEUP_EVENT_MASK 0x02
379#define C6DOFIMU8_Z_WAKEUP_EVENT_MASK 0x01
381#define C6DOFIMU8_TAP_EVENT_MASK 0x40
382#define C6DOFIMU8_SINGLE_TAP_EVENT_MASK 0x20
383#define C6DOFIMU8_DOUBLE_TAP_EVENT_MASK 0x10
384#define C6DOFIMU8_TAP_SIGN_EVENT_MASK 0x08
385#define C6DOFIMU8_X_TAP_EVENT_MASK 0x04
386#define C6DOFIMU8_Y_TAP_EVENT_MASK 0x02
387#define C6DOFIMU8_Z_TAP_EVENT_MASK 0x01
394#define C6DOFIMU8_TEMP_DRDY_MASK 0x04
395#define C6DOFIMU8_G_DRDY_MASK 0x02
396#define C6DOFIMU8_XL_DRDY_MASK 0x01
403#define C6DOFIMU8_FIFO_WATERMARK_STATUS_MASK 0x80
404#define C6DOFIMU8_FIFO_OVERRUN_STATUS_MASK 0x40
405#define C6DOFIMU8_FIFO_FULL_SMART_STATUS_MASK 0x20
406#define C6DOFIMU8_FIFO_EMPTY_STATUS_MASK 0x10
413#define C6DOFIMU8_BASIC_INTERR_EN 0x80
414#define C6DOFIMU8_SLOPE_FILTER_APPLIED 0x00
415#define C6DOFIMU8_HPF_APPLIED 0x10
416#define C6DOFIMU8_TAP_X_EN 0x08
417#define C6DOFIMU8_TAP_Y_EN 0x04
418#define C6DOFIMU8_TAP_Z_EN 0x02
419#define C6DOFIMU8_INTERR_REQ_LATCHED 0x01
426#define C6DOFIMU8_EVENT_NOT_DETECTED 0x00
427#define C6DOFIMU8_EVENT_DETECTED 0x01
434#define C6DOFIMU8_INT_OCCURED 0x01
435#define C6DOFIMU8_ADDR_ERROR 0x02
436#define C6DOFIMU8_FULL_SCALE_ERROR 0x03
437#define C6DOFIMU8_DATA_RATE_ERROR 0x04
444#define C6DOFIMU8_LOG_HIGH 0x01
445#define C6DOFIMU8_LOG_LOW 0x00
455#define SPI_RD_CMD 0x80
456#define TEMP_LSB_RES 326.8
457#define TEMP_OFFSET 25
#define C6DOFIMU8_RETVAL
Definition c6dofimu8.h:91
uint8_t c6dofimu8_write_word(c6dofimu8_t *ctx, uint8_t reg_addr, uint16_t data_in)
Word Write function.
uint8_t c6dofimu8_write_byte(c6dofimu8_t *ctx, uint8_t reg_addr, uint8_t data_in)
Single Byte Write functions.
uint8_t c6dofimu8_get_int_2_pin(c6dofimu8_t *ctx)
INT2 Pin Check function.
uint8_t c6dofimu8_read_word(c6dofimu8_t *ctx, uint8_t reg_addr, uint16_t *data_out)
Word Read function.
void c6dofimu8_reset(c6dofimu8_t *ctx)
Device SW Reset function.
void c6dofimu8_generic_write(c6dofimu8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t c6dofimu8_set_fsr(c6dofimu8_t *ctx, uint8_t gyro_fsr, uint8_t accel_fsr)
Full Scale Setting function.
void c6dofimu8_generic_read(c6dofimu8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t c6dofimu8_write_bytes(c6dofimu8_t *ctx, uint8_t start_addr, uint8_t *data_in, uint8_t n_bytes)
Sequential Write function.
uint8_t c6dofimu8_get_drdy_status(c6dofimu8_t *ctx, uint8_t bit_mask)
Status Check function.
uint8_t c6dofimu8_set_odr(c6dofimu8_t *ctx, uint8_t gyro_odr, uint8_t accel_odr)
Data Rate Setting function.
uint8_t c6dofimu8_read_bytes(c6dofimu8_t *ctx, uint8_t start_addr, uint8_t *data_out, uint8_t n_bytes)
equential Read function.
void c6dofimu8_cfg_setup(c6dofimu8_cfg_t *cfg)
Config Object Initialization function.
uint8_t c6dofimu8_read_byte(c6dofimu8_t *ctx, uint8_t reg_addr, uint8_t *data_out)
Single Byte Read function.
void c6dofimu8_get_data(c6dofimu8_t *ctx, t_c6dofimu8_axis *accel_out, t_c6dofimu8_axis *gyro_out, int8_t *temp_out)
Data Get function.
uint8_t c6dofimu8_get_int_1_pin(c6dofimu8_t *ctx)
INT1 Pin Check function.
C6DOFIMU8_RETVAL c6dofimu8_init(c6dofimu8_t *ctx, c6dofimu8_cfg_t *cfg)
Initialization function.
void c6dofimu8_get_magnetometer_data(c6dofimu8_t *ctx, t_c6dofimu8_axis *magneto_out)
Magnetometer Data Get function.
void c6dofimu8_default_cfg(c6dofimu8_t *ctx)
Click Default Configuration function.
void(* c6dofimu8_master_io_t)(struct c6dofimu8_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition c6dofimu8.h:475
struct c6dofimu8_s c6dofimu8_t
Click ctx object definition.
uint8_t c6dofimu8_select_t
Communication type.
Definition c6dofimu8.h:470
Click configuration structure definition.
Definition c6dofimu8.h:521
pin_name_t it2
Definition c6dofimu8.h:533
c6dofimu8_select_t sel
Definition c6dofimu8.h:544
uint32_t i2c_speed
Definition c6dofimu8.h:538
pin_name_t it1
Definition c6dofimu8.h:534
spi_master_chip_select_polarity_t cs_polarity
Definition c6dofimu8.h:542
pin_name_t sck
Definition c6dofimu8.h:528
spi_master_mode_t spi_mode
Definition c6dofimu8.h:541
pin_name_t mosi
Definition c6dofimu8.h:527
uint32_t spi_speed
Definition c6dofimu8.h:540
pin_name_t scl
Definition c6dofimu8.h:524
pin_name_t miso
Definition c6dofimu8.h:526
pin_name_t sda
Definition c6dofimu8.h:525
pin_name_t cs
Definition c6dofimu8.h:529
uint8_t i2c_address
Definition c6dofimu8.h:539
Click ctx object definition.
Definition c6dofimu8.h:489
digital_out_t cs
Definition c6dofimu8.h:494
t_c6dofimu8_axis dev_axis
Definition c6dofimu8.h:513
spi_master_t spi
Definition c6dofimu8.h:499
digital_in_t it2
Definition c6dofimu8.h:492
uint8_t driver_sel
Definition c6dofimu8.h:509
uint8_t gyro_res
Definition c6dofimu8.h:510
i2c_master_t i2c
Definition c6dofimu8.h:498
c6dofimu8_master_io_t write_f
Definition c6dofimu8.h:505
uint8_t slave_address
Definition c6dofimu8.h:503
c6dofimu8_master_io_t read_f
Definition c6dofimu8.h:506
uint8_t accel_res
Definition c6dofimu8.h:511
c6dofimu8_select_t master_sel
Definition c6dofimu8.h:507
pin_name_t chip_select
Definition c6dofimu8.h:504
digital_in_t it1
Definition c6dofimu8.h:493
Definition c6dofimu8.h:477
double z
Definition c6dofimu8.h:481
double y
Definition c6dofimu8.h:480
double x
Definition c6dofimu8.h:479