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 C6DOFIMU6_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.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
82#define C6DOFIMU6_MASTER_I2C 0
83#define C6DOFIMU6_MASTER_SPI 1
90#define C6DOFIMU6_RETVAL uint8_t
92#define C6DOFIMU6_OK 0x00
93#define C6DOFIMU6_INIT_ERROR 0xFF
100#define C6DOFIMU6_I2C_SLAVE_ADR_GND 0x68
101#define C6DOFIMU6_I2C_SLAVE_ADR_VCC 0x69
108#define C6DOFIMU6_READ_BIT_MASK 0x80
109#define C6DOFIMU6_WRITE_BIT_MASK 0x7F
116#define C6DOFIMU6_SELF_TEST_X_GYRO 0x00
117#define C6DOFIMU6_SELF_TEST_Y_GYRO 0x01
118#define C6DOFIMU6_SELF_TEST_Z_GYRO 0x02
119#define C6DOFIMU6_SELF_TEST_X_ACCEL 0x0D
120#define C6DOFIMU6_SELF_TEST_Y_ACCEL 0x0E
121#define C6DOFIMU6_SELF_TEST_Z_ACCEL 0x0F
122#define C6DOFIMU6_XG_OFFS_USR_H 0x13
123#define C6DOFIMU6_XG_OFFS_USR_L 0x14
124#define C6DOFIMU6_YG_OFFS_USR_H 0x15
125#define C6DOFIMU6_YG_OFFS_USR_L 0x16
126#define C6DOFIMU6_ZG_OFFS_USR_H 0x17
127#define C6DOFIMU6_ZG_OFFS_USR_L 0x18
128#define C6DOFIMU6_SMPL_RT_DIV 0x19
129#define C6DOFIMU6_CFG 0x1A
130#define C6DOFIMU6_GYRO_CFG 0x1B
131#define C6DOFIMU6_ACCEL_CFG 0x1C
132#define C6DOFIMU6_ACCEL_CFG_2 0x1D
133#define C6DOFIMU6_LP_MODE_CTL 0x1E
134#define C6DOFIMU6_ACCEL_WOM_X_THR 0x20
135#define C6DOFIMU6_ACCEL_WOM_Y_THR 0x21
136#define C6DOFIMU6_ACCEL_WOM_Z_THR 0x22
137#define C6DOFIMU6_FIFO_EN 0x23
138#define C6DOFIMU6_INT_PIN_CFG 0x37
139#define C6DOFIMU6_INT_ENABLE 0x38
140#define C6DOFIMU6_DMP_INT_STAT 0x39
141#define C6DOFIMU6_INT_STAT 0x3A
142#define C6DOFIMU6_ACCEL_XOUT_H 0x3B
143#define C6DOFIMU6_ACCEL_XOUT_L 0x3C
144#define C6DOFIMU6_ACCEL_YOUT_H 0x3D
145#define C6DOFIMU6_ACCEL_YOUT_L 0x3E
146#define C6DOFIMU6_ACCEL_ZOUT_H 0x3F
147#define C6DOFIMU6_ACCEL_ZOUT_L 0x40
148#define C6DOFIMU6_TEMP_OUT_H 0x41
149#define C6DOFIMU6_TEMP_OUT_L 0x42
150#define C6DOFIMU6_GYRO_XOUT_H 0x43
151#define C6DOFIMU6_GYRO_XOUT_L 0x44
152#define C6DOFIMU6_GYRO_YOUT_H 0x45
153#define C6DOFIMU6_GYRO_YOUT_L 0x46
154#define C6DOFIMU6_GYRO_ZOUT_H 0x47
155#define C6DOFIMU6_GYRO_ZOUT_L 0x48
156#define C6DOFIMU6_SIGNAL_PATH_RST 0x68
157#define C6DOFIMU6_ACCEL_INTEL_CTL 0x69
158#define C6DOFIMU6_USER_CTL 0x6A
159#define C6DOFIMU6_PWR_MGMT_1 0x6B
160#define C6DOFIMU6_PWR_MGMT_2 0x6C
161#define C6DOFIMU6_FIFO_CNT_H 0x72
162#define C6DOFIMU6_FIFO_CNT_L 0x73
163#define C6DOFIMU6_FIFO_R_W 0x74
164#define C6DOFIMU6_WHO_AM_I 0x75
165#define C6DOFIMU6_XA_OFFS_H 0x77
166#define C6DOFIMU6_XA_OFFS_L 0x78
167#define C6DOFIMU6_YA_OFFS_H 0x7A
168#define C6DOFIMU6_YA_OFFS_L 0x7B
169#define C6DOFIMU6_ZA_OFFS_H 0x7D
170#define C6DOFIMU6_ZA_OFFS_L 0x7E
177#define C6DOFIMU6_CFG_FIFO_MODE 0x40
178#define C6DOFIMU6_CFG_EXT_SYNC_SET_1 0x08
179#define C6DOFIMU6_CFG_EXT_SYNC_SET_2 0x10
180#define C6DOFIMU6_CFG_EXT_SYNC_SET_3 0x18
181#define C6DOFIMU6_CFG_EXT_SYNC_SET_4 0x20
182#define C6DOFIMU6_CFG_EXT_SYNC_SET_5 0x28
183#define C6DOFIMU6_CFG_EXT_SYNC_SET_6 0x30
184#define C6DOFIMU6_CFG_EXT_SYNC_SET_7 0x38
185#define C6DOFIMU6_CFG_DLPF_CFG_0 0x00
186#define C6DOFIMU6_CFG_DLPF_CFG_1 0x01
187#define C6DOFIMU6_CFG_DLPF_CFG_2 0x02
188#define C6DOFIMU6_CFG_DLPF_CFG_3 0x03
189#define C6DOFIMU6_CFG_DLPF_CFG_4 0x04
190#define C6DOFIMU6_CFG_DLPF_CFG_5 0x05
191#define C6DOFIMU6_CFG_DLPF_CFG_6 0x06
192#define C6DOFIMU6_CFG_DLPF_CFG_7 0x07
199#define C6DOFIMU6_GYRO_CFG_XGYRO_STEN 0x80
200#define C6DOFIMU6_GYRO_CFG_YGYRO_STEN 0x40
201#define C6DOFIMU6_GYRO_CFG_ZGYRO_STEN 0x20
202#define C6DOFIMU6_GYRO_CFG_FS_SEL_2000 0x18
203#define C6DOFIMU6_GYRO_CFG_FS_SEL_1000 0x10
204#define C6DOFIMU6_GYRO_CFG_FS_SEL_500 0x08
205#define C6DOFIMU6_GYRO_CFG_FS_SEL_250 0x00
206#define C6DOFIMU6_GYRO_CFG_FCHOICE_B_2 0x02
207#define C6DOFIMU6_GYRO_CFG_FCHOICE_B_1 0x01
208#define C6DOFIMU6_GYRO_CFG_FCHOICE_B_0 0x00
215#define C6DOFIMU6_ACCEL_CFG_AX_ST_EN 0x80
216#define C6DOFIMU6_ACCEL_CFG_AY_ST_EN 0x40
217#define C6DOFIMU6_ACCEL_CFG_AZ_ST_EN 0x20
218#define C6DOFIMU6_ACCEL_CFG_FS_SEL_16G 0x18
219#define C6DOFIMU6_ACCEL_CFG_FS_SEL_8G 0x10
220#define C6DOFIMU6_ACCEL_CFG_FS_SEL_4G 0x08
221#define C6DOFIMU6_ACCEL_CFG_FS_SEL_2G 0x00
228#define C6DOFIMU6_ACCEL2_CFG_FIFO_SIZE_4KB 0x40
229#define C6DOFIMU6_ACCEL2_CFG_FIFO_SIZE_2KB 0x08
230#define C6DOFIMU6_ACCEL2_CFG_FIFO_SIZE_1KB 0x10
231#define C6DOFIMU6_ACCEL2_CFG_FIFO_SIZE_512B 0x18
232#define C6DOFIMU6_ACCEL2_CFG_DEC2_CFG_32 0x30
233#define C6DOFIMU6_ACCEL2_CFG_DEC2_CFG_16 0x20
234#define C6DOFIMU6_ACCEL2_CFG_DEC2_CFG_8 0x10
235#define C6DOFIMU6_ACCEL2_CFG_DEC2_CFG_4 0x00
236#define C6DOFIMU6_ACCEL2_CFG_FCHOICE_B 0x00
237#define C6DOFIMU6_ACCEL2_CFG_A_DLPF_CFG_0 0x00
238#define C6DOFIMU6_ACCEL2_CFG_A_DLPF_CFG_1 0x01
239#define C6DOFIMU6_ACCEL2_CFG_A_DLPF_CFG_2 0x02
240#define C6DOFIMU6_ACCEL2_CFG_A_DLPF_CFG_3 0x03
241#define C6DOFIMU6_ACCEL2_CFG_A_DLPF_CFG_4 0x04
242#define C6DOFIMU6_ACCEL2_CFG_A_DLPF_CFG_5 0x05
243#define C6DOFIMU6_ACCEL2_CFG_A_DLPF_CFG_6 0x06
244#define C6DOFIMU6_ACCEL2_CFG_A_DLPF_CFG_7 0x07
251#define C6DOFIMU6_FIFO_EN_TEMP_OUT 0x80
252#define C6DOFIMU6_FIFO_EN_GYRO_XOUT 0x40
253#define C6DOFIMU6_FIFO_EN_GYRO_YOUT 0x20
254#define C6DOFIMU6_FIFO_EN_GYRO_ZOUT 0x10
255#define C6DOFIMU6_FIFO_EN_ACCEL_XYZ_OUT 0x08
262#define C6DOFIMU6_INT_PIN_CFG_ACTL 0x80
263#define C6DOFIMU6_INT_PIN_CFG_OPEN 0x40
264#define C6DOFIMU6_INT_PIN_CFG_LATCH_INT_EN 0x20
265#define C6DOFIMU6_INT_PIN_CFG_INT_ANYRD_2CLR 0x10
266#define C6DOFIMU6_INT_PIN_CFG_ACTL_FSYNC 0x08
267#define C6DOFIMU6_INT_PIN_CFG_FSYNC_INT_MODE_EN 0x04
268#define C6DOFIMU6_INT_PIN_CFG_BYPASS_EN 0x02
275#define C6DOFIMU6_INT_ENABLE_WOM_X_INT_EN 0x80
276#define C6DOFIMU6_INT_ENABLE_WOM_Y_INT_EN 0x40
277#define C6DOFIMU6_INT_ENABLE_WOM_Z_INT_EN 0x20
278#define C6DOFIMU6_INT_ENABLE_FIFO_OVF_EN 0x10
279#define C6DOFIMU6_INT_ENABLE_GDRIVE_RDY_EN 0x04
280#define C6DOFIMU6_INT_ENABLE_DMP_INT_EN 0x02
281#define C6DOFIMU6_INT_ENABLE_RAW_RDY_EN 0x01
288#define C6DOFIMU6_INT_STAT_WOM_X_INT 0x80
289#define C6DOFIMU6_INT_STAT_WOM_Y_INT 0x40
290#define C6DOFIMU6_INT_STAT_WOM_Z_INT 0x20
291#define C6DOFIMU6_INT_STAT_FIFO_OVF_INT 0x10
292#define C6DOFIMU6_INT_STAT_GDRIVE_RDY_INT 0x04
293#define C6DOFIMU6_INT_STAT_DMP_INT 0x02
294#define C6DOFIMU6_INT_STAT_RAW_RDY_INT 0x01
301#define C6DOFIMU6_SIGNAL_PATH_RST_GYRO_RST 0x80
302#define C6DOFIMU6_SIGNAL_PATH_RST_ACCEL_RST 0x40
303#define C6DOFIMU6_SIGNAL_PATH_RST_TEMP_RST 0x20
310#define C6DOFIMU6_ACCEL_INTEL_CTL_INTEL_EN 0x80
311#define C6DOFIMU6_ACCEL_INTEL_CTL_INTEL_MODE_PREV_SAMP 0x40
312#define C6DOFIMU6_ACCEL_INTEL_CTL_INTEL_MODE_FIRST_SAMP 0x00
319#define C6DOFIMU6_USER_CTL_DMP_EN 0x80
320#define C6DOFIMU6_USER_CTL_FIFO_EN 0x40
321#define C6DOFIMU6_USER_CTL_I2C_IF_DIS 0x10
322#define C6DOFIMU6_USER_CTL_DMP_RST 0x08
323#define C6DOFIMU6_USER_CTL_FIFO_RST 0x04
324#define C6DOFIMU6_USER_CTL_SIG_COND_RST 0x01
331#define C6DOFIMU6_PWR_MGMT_1_DEV_RST 0x80
332#define C6DOFIMU6_PWR_MGMT_1_SLEEP 0x40
333#define C6DOFIMU6_PWR_MGMT_1_ACCEL_CYC 0x20
334#define C6DOFIMU6_PWR_MGMT_1_GYRO_STDBY 0x10
335#define C6DOFIMU6_PWR_MGMT_1_TEMP_DIS 0x08
336#define C6DOFIMU6_PWR_MGMT_1_CLKSEL_7 0x07
337#define C6DOFIMU6_PWR_MGMT_1_CLKSEL_6 0x06
338#define C6DOFIMU6_PWR_MGMT_1_CLKSEL_5 0x05
339#define C6DOFIMU6_PWR_MGMT_1_CLKSEL_4 0x04
340#define C6DOFIMU6_PWR_MGMT_1_CLKSEL_3 0x03
341#define C6DOFIMU6_PWR_MGMT_1_CLKSEL_2 0x02
342#define C6DOFIMU6_PWR_MGMT_1_CLKSEL_1 0x01
343#define C6DOFIMU6_PWR_MGMT_1_CLKSEL_0 0x00
350#define C6DOFIMU6_PWR_MGMT_2_LP_DIS 0x80
351#define C6DOFIMU6_PWR_MGMT_2_DMP_LP_DIS 0x40
352#define C6DOFIMU6_PWR_MGMT_2_DISABLE_XA 0x20
353#define C6DOFIMU6_PWR_MGMT_2_DISABLE_YA 0x10
354#define C6DOFIMU6_PWR_MGMT_2_DISABLE_ZA 0x08
355#define C6DOFIMU6_PWR_MGMT_2_DISABLE_XG 0x04
356#define C6DOFIMU6_PWR_MGMT_2_DISABLE_YG 0x02
357#define C6DOFIMU6_PWR_MGMT_2_DISABLE_ZG 0x01
364#define C6DOFIMU6_WHO_AM_I_VAL 0x98
371#define C6DOFIMU6_POWER_ON 0x01
372#define C6DOFIMU6_POWER_OFF 0x00
379#define C6DOFIMU6_GYRO_SENS_FS_SEL_2000 16.4
380#define C6DOFIMU6_GYRO_SENS_FS_SEL_1000 32.8
381#define C6DOFIMU6_GYRO_SENS_FS_SEL_500 65.5
382#define C6DOFIMU6_GYRO_SENS_FS_SEL_250 131.0
383#define C6DOFIMU6_ACCEL_SENS_FS_SEL_16G 2048.0
384#define C6DOFIMU6_ACCEL_SENS_FS_SEL_8G 4096.0
385#define C6DOFIMU6_ACCEL_SENS_FS_SEL_4G 8192.0
386#define C6DOFIMU6_ACCEL_SENS_FS_SEL_2G 16384.0
#define C6DOFIMU6_RETVAL
Definition c6dofimu6.h:90
uint8_t c6dofimu6_check_int_pin(c6dofimu6_t *ctx)
Check Interrupt state function.
int16_t c6dofimu6_read_accel_z(c6dofimu6_t *ctx)
Read Accelerometer Z-axis data function.
void c6dofimu6_default_cfg(c6dofimu6_t *ctx)
Click Default Configuration function.
int16_t c6dofimu6_read_accel_x(c6dofimu6_t *ctx)
Read Accelerometer X-axis data function.
C6DOFIMU6_RETVAL c6dofimu6_init(c6dofimu6_t *ctx, c6dofimu6_cfg_t *cfg)
Initialization function.
int16_t c6dofimu6_read_gyro_z(c6dofimu6_t *ctx)
Read Gyroscope Z-axis data function.
void c6dofimu6_generic_write(c6dofimu6_t *ctx, uint8_t reg, uint8_t *data_buf, uint16_t len)
Generic write function.
int16_t c6dofimu6_read_accel_y(c6dofimu6_t *ctx)
Read Accelerometer Y-axis data function.
void c6dofimu6_read_gyroscope(c6dofimu6_t *ctx, int16_t *gyro_x, int16_t *gyro_y, int16_t *gyro_z)
Read gyroscope data function.
void c6dofimu6_read_accelerometer(c6dofimu6_t *ctx, int16_t *accel_x, int16_t *accel_y, int16_t *accel_z)
Read accelerometer data function.
float c6dofimu6_read_temp_out(c6dofimu6_t *ctx)
Read temperture function.
int16_t c6dofimu6_read_gyro_x(c6dofimu6_t *ctx)
Read Gyroscope X-axis data function.
void c6dofimu6_generic_read(c6dofimu6_t *ctx, uint8_t reg, uint8_t *data_buf, uint16_t len)
Generic read function.
void c6dofimu6_angular_rate(c6dofimu6_t *ctx, float *x_ang_rte, float *y_ang_rte, float *z_ang_rte)
Read Angular Rate function.
void c6dofimu6_cfg_setup(c6dofimu6_cfg_t *cfg)
Config Object Initialization function.
void c6dofimu6_acceleration_rate(c6dofimu6_t *ctx, float *x_accel_rte, float *y_accel_rte, float *z_accel_rte)
Read acceleration Rate function.
int16_t c6dofimu6_read_gyro_y(c6dofimu6_t *ctx)
Read Gyroscope Y-axis data function.
void c6dofimu6_power(c6dofimu6_t *ctx, uint8_t on_off)
Power up function.
void(* c6dofimu6_master_io_t)(struct c6dofimu6_s *, uint8_t, uint8_t *, uint16_t)
Master Input/Output type.
Definition c6dofimu6.h:404
struct c6dofimu6_s c6dofimu6_t
Click ctx object definition.
uint8_t c6dofimu6_select_t
Communication type.
Definition c6dofimu6.h:399
Click configuration structure definition.
Definition c6dofimu6.h:438
c6dofimu6_select_t sel
Definition c6dofimu6.h:461
uint32_t i2c_speed
Definition c6dofimu6.h:454
spi_master_chip_select_polarity_t cs_polarity
Definition c6dofimu6.h:459
pin_name_t sck
Definition c6dofimu6.h:445
spi_master_mode_t spi_mode
Definition c6dofimu6.h:458
pin_name_t mosi
Definition c6dofimu6.h:444
uint32_t spi_speed
Definition c6dofimu6.h:457
pin_name_t scl
Definition c6dofimu6.h:441
pin_name_t int_pin
Definition c6dofimu6.h:450
pin_name_t miso
Definition c6dofimu6.h:443
pin_name_t sda
Definition c6dofimu6.h:442
pin_name_t cs
Definition c6dofimu6.h:446
uint8_t i2c_address
Definition c6dofimu6.h:455
Click ctx object definition.
Definition c6dofimu6.h:410
digital_out_t cs
Definition c6dofimu6.h:413
spi_master_t spi
Definition c6dofimu6.h:422
c6dofimu6_master_io_t read_f
Definition c6dofimu6.h:429
c6dofimu6_master_io_t write_f
Definition c6dofimu6.h:428
digital_in_t int_pin
Definition c6dofimu6.h:417
i2c_master_t i2c
Definition c6dofimu6.h:421
uint8_t slave_address
Definition c6dofimu6.h:426
c6dofimu6_select_t master_sel
Definition c6dofimu6.h:430
pin_name_t chip_select
Definition c6dofimu6.h:427