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 C6DOFIMU5_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 C6DOFIMU5_RETVAL uint8_t
84#define C6DOFIMU5_OK 0x00
85#define C6DOFIMU5_INIT_ERROR 0xFF
92#define C6DOFIMU5_I2C_SLAVE_ADR 0x63
99#define C6DOFIMU5_READ_BIT_MASK 0x80
100#define C6DOFIMU5_WRITE_BIT_MASK 0x7F
107#define C6DOFIMU5_SELF_TEST_X_GYRO 0x00
108#define C6DOFIMU5_SELF_TEST_Y_GYRO 0x01
109#define C6DOFIMU5_SELF_TEST_Z_GYRO 0x02
110#define C6DOFIMU5_SELF_TEST_X_ACCEL 0x0D
111#define C6DOFIMU5_SELF_TEST_Y_ACCEL 0x0E
112#define C6DOFIMU5_SELF_TEST_Z_ACCEL 0x0F
113#define C6DOFIMU5_XG_OFFS_USR_H 0x13
114#define C6DOFIMU5_XG_OFFS_USR_L 0x14
115#define C6DOFIMU5_YG_OFFS_USR_H 0x15
116#define C6DOFIMU5_YG_OFFS_USR_L 0x16
117#define C6DOFIMU5_ZG_OFFS_USR_H 0x17
118#define C6DOFIMU5_ZG_OFFS_USR_L 0x18
119#define C6DOFIMU5_SMPL_RT_DIV 0x19
120#define C6DOFIMU5_CFG 0x1A
121#define C6DOFIMU5_GYRO_CFG 0x1B
122#define C6DOFIMU5_ACCEL_CFG 0x1C
123#define C6DOFIMU5_ACCEL_CFG_2 0x1D
124#define C6DOFIMU5_LP_MODE_CTL 0x1E
125#define C6DOFIMU5_ACCEL_WOM_X_THR 0x20
126#define C6DOFIMU5_ACCEL_WOM_Y_THR 0x21
127#define C6DOFIMU5_ACCEL_WOM_Z_THR 0x22
128#define C6DOFIMU5_FIFO_EN 0x23
129#define C6DOFIMU5_INT_PIN_CFG 0x37
130#define C6DOFIMU5_INT_ENABLE 0x38
131#define C6DOFIMU5_DMP_INT_STAT 0x39
132#define C6DOFIMU5_INT_STAT 0x3A
133#define C6DOFIMU5_ACCEL_XOUT_H 0x3B
134#define C6DOFIMU5_ACCEL_XOUT_L 0x3C
135#define C6DOFIMU5_ACCEL_YOUT_H 0x3D
136#define C6DOFIMU5_ACCEL_YOUT_L 0x3E
137#define C6DOFIMU5_ACCEL_ZOUT_H 0x3F
138#define C6DOFIMU5_ACCEL_ZOUT_L 0x40
139#define C6DOFIMU5_TEMP_OUT_H 0x41
140#define C6DOFIMU5_TEMP_OUT_L 0x42
141#define C6DOFIMU5_GYRO_XOUT_H 0x43
142#define C6DOFIMU5_GYRO_XOUT_L 0x44
143#define C6DOFIMU5_GYRO_YOUT_H 0x45
144#define C6DOFIMU5_GYRO_YOUT_L 0x46
145#define C6DOFIMU5_GYRO_ZOUT_H 0x47
146#define C6DOFIMU5_GYRO_ZOUT_L 0x48
147#define C6DOFIMU5_SIGNAL_PATH_RST 0x68
148#define C6DOFIMU5_ACCEL_INTEL_CTL 0x69
149#define C6DOFIMU5_USER_CTL 0x6A
150#define C6DOFIMU5_PWR_MGMT_1 0x6B
151#define C6DOFIMU5_PWR_MGMT_2 0x6C
152#define C6DOFIMU5_FIFO_CNT_H 0x72
153#define C6DOFIMU5_FIFO_CNT_L 0x73
154#define C6DOFIMU5_FIFO_R_W 0x74
155#define C6DOFIMU5_WHO_AM_I 0x75
156#define C6DOFIMU5_XA_OFFS_H 0x77
157#define C6DOFIMU5_XA_OFFS_L 0x78
158#define C6DOFIMU5_YA_OFFS_H 0x7A
159#define C6DOFIMU5_YA_OFFS_L 0x7B
160#define C6DOFIMU5_ZA_OFFS_H 0x7D
161#define C6DOFIMU5_ZA_OFFS_L 0x7E
168#define C6DOFIMU5_CFG_FIFO_MODE 0x40
169#define C6DOFIMU5_CFG_EXT_SYNC_SET_1 0x08
170#define C6DOFIMU5_CFG_EXT_SYNC_SET_2 0x10
171#define C6DOFIMU5_CFG_EXT_SYNC_SET_3 0x18
172#define C6DOFIMU5_CFG_EXT_SYNC_SET_4 0x20
173#define C6DOFIMU5_CFG_EXT_SYNC_SET_5 0x28
174#define C6DOFIMU5_CFG_EXT_SYNC_SET_6 0x30
175#define C6DOFIMU5_CFG_EXT_SYNC_SET_7 0x38
176#define C6DOFIMU5_CFG_DLPF_CFG_0 0x00
177#define C6DOFIMU5_CFG_DLPF_CFG_1 0x01
178#define C6DOFIMU5_CFG_DLPF_CFG_2 0x02
179#define C6DOFIMU5_CFG_DLPF_CFG_3 0x03
180#define C6DOFIMU5_CFG_DLPF_CFG_4 0x04
181#define C6DOFIMU5_CFG_DLPF_CFG_5 0x05
182#define C6DOFIMU5_CFG_DLPF_CFG_6 0x06
183#define C6DOFIMU5_CFG_DLPF_CFG_7 0x07
190#define C6DOFIMU5_GYRO_CFG_XGYRO_STEN 0x80
191#define C6DOFIMU5_GYRO_CFG_YGYRO_STEN 0x40
192#define C6DOFIMU5_GYRO_CFG_ZGYRO_STEN 0x20
193#define C6DOFIMU5_GYRO_CFG_FS_SEL_2000 0x18
194#define C6DOFIMU5_GYRO_CFG_FS_SEL_1000 0x10
195#define C6DOFIMU5_GYRO_CFG_FS_SEL_500 0x08
196#define C6DOFIMU5_GYRO_CFG_FS_SEL_250 0x00
197#define C6DOFIMU5_GYRO_CFG_FCHOICE_B_2 0x02
198#define C6DOFIMU5_GYRO_CFG_FCHOICE_B_1 0x01
199#define C6DOFIMU5_GYRO_CFG_FCHOICE_B_0 0x00
206#define C6DOFIMU5_ACCEL_CFG_AX_ST_EN 0x80
207#define C6DOFIMU5_ACCEL_CFG_AY_ST_EN 0x40
208#define C6DOFIMU5_ACCEL_CFG_AZ_ST_EN 0x20
209#define C6DOFIMU5_ACCEL_CFG_FS_SEL_16G 0x18
210#define C6DOFIMU5_ACCEL_CFG_FS_SEL_8G 0x10
211#define C6DOFIMU5_ACCEL_CFG_FS_SEL_4G 0x08
212#define C6DOFIMU5_ACCEL_CFG_FS_SEL_2G 0x00
219#define C6DOFIMU5_ACCEL2_CFG_FIFO_SIZE_4KB 0x40
220#define C6DOFIMU5_ACCEL2_CFG_FIFO_SIZE_2KB 0x08
221#define C6DOFIMU5_ACCEL2_CFG_FIFO_SIZE_1KB 0x10
222#define C6DOFIMU5_ACCEL2_CFG_FIFO_SIZE_512B 0x18
223#define C6DOFIMU5_ACCEL2_CFG_DEC2_CFG_32 0x30
224#define C6DOFIMU5_ACCEL2_CFG_DEC2_CFG_16 0x20
225#define C6DOFIMU5_ACCEL2_CFG_DEC2_CFG_8 0x10
226#define C6DOFIMU5_ACCEL2_CFG_DEC2_CFG_4 0x00
227#define C6DOFIMU5_ACCEL2_CFG_FCHOICE_B 0x00
228#define C6DOFIMU5_ACCEL2_CFG_A_DLPF_CFG_0 0x00
229#define C6DOFIMU5_ACCEL2_CFG_A_DLPF_CFG_1 0x01
230#define C6DOFIMU5_ACCEL2_CFG_A_DLPF_CFG_2 0x02
231#define C6DOFIMU5_ACCEL2_CFG_A_DLPF_CFG_3 0x03
232#define C6DOFIMU5_ACCEL2_CFG_A_DLPF_CFG_4 0x04
233#define C6DOFIMU5_ACCEL2_CFG_A_DLPF_CFG_5 0x05
234#define C6DOFIMU5_ACCEL2_CFG_A_DLPF_CFG_6 0x06
235#define C6DOFIMU5_ACCEL2_CFG_A_DLPF_CFG_7 0x07
242#define C6DOFIMU5_FIFO_EN_TEMP_OUT 0x80
243#define C6DOFIMU5_FIFO_EN_GYRO_XOUT 0x40
244#define C6DOFIMU5_FIFO_EN_GYRO_YOUT 0x20
245#define C6DOFIMU5_FIFO_EN_GYRO_ZOUT 0x10
246#define C6DOFIMU5_FIFO_EN_ACCEL_XYZ_OUT 0x08
253#define C6DOFIMU5_INT_PIN_CFG_ACTL 0x80
254#define C6DOFIMU5_INT_PIN_CFG_OPEN 0x40
255#define C6DOFIMU5_INT_PIN_CFG_LATCH_INT_EN 0x20
256#define C6DOFIMU5_INT_PIN_CFG_INT_ANYRD_2CLR 0x10
257#define C6DOFIMU5_INT_PIN_CFG_ACTL_FSYNC 0x08
258#define C6DOFIMU5_INT_PIN_CFG_FSYNC_INT_MODE_EN 0x04
259#define C6DOFIMU5_INT_PIN_CFG_BYPASS_EN 0x02
266#define C6DOFIMU5_INT_ENABLE_WOM_X_INT_EN 0x80
267#define C6DOFIMU5_INT_ENABLE_WOM_Y_INT_EN 0x40
268#define C6DOFIMU5_INT_ENABLE_WOM_Z_INT_EN 0x20
269#define C6DOFIMU5_INT_ENABLE_FIFO_OVF_EN 0x10
270#define C6DOFIMU5_INT_ENABLE_GDRIVE_RDY_EN 0x04
271#define C6DOFIMU5_INT_ENABLE_DMP_INT_EN 0x02
272#define C6DOFIMU5_INT_ENABLE_RAW_RDY_EN 0x01
279#define C6DOFIMU5_INT_STAT_WOM_X_INT 0x80
280#define C6DOFIMU5_INT_STAT_WOM_Y_INT 0x40
281#define C6DOFIMU5_INT_STAT_WOM_Z_INT 0x20
282#define C6DOFIMU5_INT_STAT_FIFO_OVF_INT 0x10
283#define C6DOFIMU5_INT_STAT_GDRIVE_RDY_INT 0x04
284#define C6DOFIMU5_INT_STAT_DMP_INT 0x02
285#define C6DOFIMU5_INT_STAT_RAW_RDY_INT 0x01
292#define C6DOFIMU5_SIGNAL_PATH_RST_GYRO_RST 0x80
293#define C6DOFIMU5_SIGNAL_PATH_RST_ACCEL_RST 0x40
294#define C6DOFIMU5_SIGNAL_PATH_RST_TEMP_RST 0x20
301#define C6DOFIMU5_ACCEL_INTEL_CTL_INTEL_EN 0x80
302#define C6DOFIMU5_ACCEL_INTEL_CTL_INTEL_MODE_PREV_SAMP 0x40
303#define C6DOFIMU5_ACCEL_INTEL_CTL_INTEL_MODE_FIRST_SAMP 0x00
310#define C6DOFIMU5_USER_CTL_DMP_EN 0x80
311#define C6DOFIMU5_USER_CTL_FIFO_EN 0x40
312#define C6DOFIMU5_USER_CTL_I2C_IF_DIS 0x10
313#define C6DOFIMU5_USER_CTL_DMP_RST 0x08
314#define C6DOFIMU5_USER_CTL_FIFO_RST 0x04
315#define C6DOFIMU5_USER_CTL_SIG_COND_RST 0x01
322#define C6DOFIMU5_PWR_MGMT_1_DEV_RST 0x80
323#define C6DOFIMU5_PWR_MGMT_1_SLEEP 0x40
324#define C6DOFIMU5_PWR_MGMT_1_ACCEL_CYC 0x20
325#define C6DOFIMU5_PWR_MGMT_1_GYRO_STDBY 0x10
326#define C6DOFIMU5_PWR_MGMT_1_TEMP_DIS 0x08
327#define C6DOFIMU5_PWR_MGMT_1_CLKSEL_7 0x07
328#define C6DOFIMU5_PWR_MGMT_1_CLKSEL_6 0x06
329#define C6DOFIMU5_PWR_MGMT_1_CLKSEL_5 0x05
330#define C6DOFIMU5_PWR_MGMT_1_CLKSEL_4 0x04
331#define C6DOFIMU5_PWR_MGMT_1_CLKSEL_3 0x03
332#define C6DOFIMU5_PWR_MGMT_1_CLKSEL_2 0x02
333#define C6DOFIMU5_PWR_MGMT_1_CLKSEL_1 0x01
334#define C6DOFIMU5_PWR_MGMT_1_CLKSEL_0 0x00
341#define C6DOFIMU5_PWR_MGMT_2_LP_DIS 0x80
342#define C6DOFIMU5_PWR_MGMT_2_DMP_LP_DIS 0x40
343#define C6DOFIMU5_PWR_MGMT_2_DISABLE_XA 0x20
344#define C6DOFIMU5_PWR_MGMT_2_DISABLE_YA 0x10
345#define C6DOFIMU5_PWR_MGMT_2_DISABLE_ZA 0x08
346#define C6DOFIMU5_PWR_MGMT_2_DISABLE_XG 0x04
347#define C6DOFIMU5_PWR_MGMT_2_DISABLE_YG 0x02
348#define C6DOFIMU5_PWR_MGMT_2_DISABLE_ZG 0x01
355#define C6DOFIMU5_WHO_AM_I_VAL 0x03
362#define C6DOFIMU5_MEAS_CMD_LP_TRANS_T_FIRST 0x609C
363#define C6DOFIMU5_MEAS_CMD_N_TRANS_T_FIRST 0x6825
364#define C6DOFIMU5_MEAS_CMD_LN_TRANS_T_FIRST 0x70DF
365#define C6DOFIMU5_MEAS_CMD_ULN_TRANS_T_FIRST 0x7866
366#define C6DOFIMU5_MEAS_CMD_LP_TRANS_P_FIRST 0x401A
367#define C6DOFIMU5_MEAS_CMD_N_TRANS_P_FIRST 0x48A3
368#define C6DOFIMU5_MEAS_CMD_LN_TRANS_P_FIRST 0x5059
369#define C6DOFIMU5_MEAS_CMD_ULN_TRANS_P_FIRST 0x58E0
370#define C6DOFIMU5_DEVICE_SOFT_RESET_CMD 0x805D
371#define C6DOFIMU5_READ_ID_REGISTER 0xEFC8
372#define C6DOFIMU5_INCREMENTAL_READ 0xC7F7
373#define C6DOFIMU5_ADR_REG_MOVE_POINTER 0xC595
380#define C6DOFIMU5_POWER_ON 0x01
381#define C6DOFIMU5_POWER_OFF 0x00
388#define C6DOFIMU5_GYRO_SENS_FS_SEL_2000 16.4
389#define C6DOFIMU5_GYRO_SENS_FS_SEL_1000 32.8
390#define C6DOFIMU5_GYRO_SENS_FS_SEL_500 65.5
391#define C6DOFIMU5_GYRO_SENS_FS_SEL_250 131.0
392#define C6DOFIMU5_ACCEL_SENS_FS_SEL_16G 2048.0
393#define C6DOFIMU5_ACCEL_SENS_FS_SEL_8G 4096.0
394#define C6DOFIMU5_ACCEL_SENS_FS_SEL_4G 8192.0
395#define C6DOFIMU5_ACCEL_SENS_FS_SEL_2G 16384.0
402#define C6DOFIMU5_LUT_LOWER 3670016.0
403#define C6DOFIMU5_LUT_UPPER 12058624.0
404#define C6DOFIMU5_QUADR_FACTOR 0.000000059604644775390625
405#define C6DOFIMU5_OFFST_FACTOR 2048.0
406#define C6DOFIMU5_P_PA_CALIB_0 45000.0
407#define C6DOFIMU5_P_PA_CALIB_1 80000.0
408#define C6DOFIMU5_P_PA_CALIB_2 105000.0
#define C6DOFIMU5_RETVAL
Definition c6dofimu5.h:82
int16_t c6dofimu5_read_accel_y(c6dofimu5_t *ctx)
Read Accelerometer Y-axis data function.
void c6dofimu5_default_cfg(c6dofimu5_t *ctx)
Click Default Configuration function.
int16_t c6dofimu5_read_accel_x(c6dofimu5_t *ctx)
Read Accelerometer X-axis data function.
uint8_t c6dofimu5_baro_id_read(c6dofimu5_t *ctx)
Barometer ID Readout function.
void c6dofimu5_power(c6dofimu5_t *ctx, uint8_t on_off)
Power up function.
void c6dofimu5_angular_rate(c6dofimu5_t *ctx, float *x_ang_rte, float *y_ang_rte, float *z_ang_rte)
Read Angular Rate function.
void c6dofimu5_baro_read(c6dofimu5_t *ctx, uint16_t cmd, uint8_t *data_out, uint16_t n_bytes)
Barometer Read function.
int16_t c6dofimu5_read_accel_z(c6dofimu5_t *ctx)
Read Accelerometer Z-axis data function.
int16_t c6dofimu5_read_gyro_x(c6dofimu5_t *ctx)
Read Gyroscope X-axis data function.
int16_t c6dofimu5_read_gyro_z(c6dofimu5_t *ctx)
Read Gyroscope Z-axis data function.
void c6dofimu5_baro_settings(c6dofimu5_t *ctx)
I2C Barometer Settings function.
void c6dofimu5_read_bytes(c6dofimu5_t *ctx, uint8_t reg, uint8_t *rd_data, uint16_t n_bytes)
Generic read function.
void c6dofimu5_cfg_setup(c6dofimu5_cfg_t *cfg)
Config Object Initialization function.
float c6dofimu5_read_temp_out(c6dofimu5_t *ctx)
Read temperture function.
void c6dofimu5_read_raw_data(c6dofimu5_t *ctx, uint32_t *pres, uint16_t *temp)
Read raw data function.
C6DOFIMU5_RETVAL c6dofimu5_init(c6dofimu5_t *ctx, c6dofimu5_cfg_t *cfg)
Initialization function.
void c6dofimu5_acceleration_rate(c6dofimu5_t *ctx, float *x_accel_rte, float *y_accel_rte, float *z_accel_rte)
Read acceleration Rate function.
uint8_t c6dofimu5_check_int_pin(c6dofimu5_t *ctx)
Check Interrupt state function.
int16_t c6dofimu5_read_gyro_y(c6dofimu5_t *ctx)
Read Gyroscope Y-axis data function.
void c6dofimu5_baro_write(c6dofimu5_t *ctx, uint8_t *data_in, uint16_t n_bytes)
Barometer Write function.
void c6dofimu5_process_data(c6dofimu5_t *ctx, c6dofimu5_process_data_t *process_d)
Process data function.
void c6dofimu5_baro_soft_rst(c6dofimu5_t *ctx)
Soft Reset Command function.
void c6dofimu5_read_gyroscope(c6dofimu5_t *ctx, int16_t *gyro_x, int16_t *gyro_y, int16_t *gyro_z)
Read gyroscope data function.
void c6dofimu5_write_bytes(c6dofimu5_t *ctx, uint8_t reg, uint8_t *wr_data, uint16_t n_bytes)
Generic write function.
void c6dofimu5_read_accelerometer(c6dofimu5_t *ctx, int16_t *accel_x, int16_t *accel_y, int16_t *accel_z)
Read accelerometer data function.
struct c6dofimu5_s c6dofimu5_t
Click ctx object definition.
Click configuration structure definition.
Definition c6dofimu5.h:457
uint32_t i2c_speed
Definition c6dofimu5.h:473
spi_master_chip_select_polarity_t cs_polarity
Definition c6dofimu5.h:478
pin_name_t sck
Definition c6dofimu5.h:464
spi_master_mode_t spi_mode
Definition c6dofimu5.h:477
pin_name_t mosi
Definition c6dofimu5.h:463
uint32_t spi_speed
Definition c6dofimu5.h:476
pin_name_t scl
Definition c6dofimu5.h:460
pin_name_t int_pin
Definition c6dofimu5.h:469
pin_name_t miso
Definition c6dofimu5.h:462
pin_name_t sda
Definition c6dofimu5.h:461
pin_name_t cs
Definition c6dofimu5.h:465
uint8_t i2c_address
Definition c6dofimu5.h:474
Definition c6dofimu5.h:419
uint16_t t_raw
Definition c6dofimu5.h:421
uint32_t p_raw
Definition c6dofimu5.h:420
float pressure
Definition c6dofimu5.h:422
float temperature
Definition c6dofimu5.h:423
Click ctx object definition.
Definition c6dofimu5.h:430
digital_out_t cs
Definition c6dofimu5.h:433
spi_master_t spi
Definition c6dofimu5.h:439
float sens_const_1
Definition c6dofimu5.h:447
float sens_const_0
Definition c6dofimu5.h:446
float sens_const_2
Definition c6dofimu5.h:448
float sens_const_3
Definition c6dofimu5.h:449
digital_in_t int_pin
Definition c6dofimu5.h:434
i2c_master_t i2c
Definition c6dofimu5.h:438
uint8_t slave_address
Definition c6dofimu5.h:443
pin_name_t chip_select
Definition c6dofimu5.h:444