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 C6DOFIMU_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 C6DOFIMU_MASTER_I2C 0
83#define C6DOFIMU_MASTER_SPI 1
90#define C6DOFIMU_RETVAL uint8_t
92#define C6DOFIMU_OK 0x00
93#define C6DOFIMU_INIT_ERROR 0xFF
100#define C6DOFIMU_SLAVE_ADDRESS 0x6B;
107#define C6DOFIMU_FUNC_CFG_ACCESS 0x01
109#define C6DOFIMU_FIFO_CTRL1 0x06
110#define C6DOFIMU_FIFO_CTRL2 0x07
111#define C6DOFIMU_FIFO_CTRL3 0x08
112#define C6DOFIMU_FIFO_CTRL4 0x09
113#define C6DOFIMU_FIFO_CTRL5 0x0A
115#define C6DOFIMU_ORIENT_CFG_G 0x0B
117#define C6DOFIMU_INT1_CTRL 0x0D
118#define C6DOFIMU_INT2_CTRL 0x0E
120#define C6DOFIMU_CTRL1_XL 0x10
121#define C6DOFIMU_CTRL2_G 0x11
122#define C6DOFIMU_CTRL3_C 0x12
123#define C6DOFIMU_CTRL4_C 0x13
124#define C6DOFIMU_CTRL5_C 0x14
125#define C6DOFIMU_CTRL6_C 0x15
126#define C6DOFIMU_CTRL7_G 0x16
127#define C6DOFIMU_CTRL8_XL 0x17
128#define C6DOFIMU_CTRL9_XL 0x18
129#define C6DOFIMU_CTRL10_C 0x19
136#define C6DOFIMU_OUT_TEMP_L 0x20
137#define C6DOFIMU_OUT_TEMP_H 0x21
139#define C6DOFIMU_OUTX_L_G 0x22
140#define C6DOFIMU_OUTX_H_G 0x23
141#define C6DOFIMU_OUTY_L_G 0x24
142#define C6DOFIMU_OUTY_H_G 0x25
143#define C6DOFIMU_OUTZ_L_G 0x26
144#define C6DOFIMU_OUTZ_H_G 0x27
146#define C6DOFIMU_OUTX_L_XL 0x28
147#define C6DOFIMU_OUTX_H_XL 0x29
148#define C6DOFIMU_OUTY_L_XL 0x2A
149#define C6DOFIMU_OUTY_H_XL 0x2B
150#define C6DOFIMU_OUTZ_L_XL 0x2C
151#define C6DOFIMU_OUTZ_H_XL 0x2D
153#define C6DOFIMU_FIFO_DATA_OUT_L 0x3E
154#define C6DOFIMU_FIFO_DATA_OUT_H 0x3F
156#define C6DOFIMU_TIMESTAMP0_REG 0x40
157#define C6DOFIMU_TIMESTAMP1_REG 0x41
158#define C6DOFIMU_TIMESTAMP2_REG 0x42
160#define C6DOFIMU_STEP_COUNTER_L 0x4B
161#define C6DOFIMU_STEP_COUNTER_H 0x4C
168#define C6DOFIMU_STATUS_REG 0x1E
170#define C6DOFIMU_FIFO_STATUS1 0x3A
171#define C6DOFIMU_FIFO_STATUS2 0x3B
172#define C6DOFIMU_FIFO_STATUS3 0x3C
173#define C6DOFIMU_FIFO_STATUS4 0x3D
175#define C6DOFIMU_TIMESTAMP_L 0x49
176#define C6DOFIMU_TIMESTAMP_H 0x4A
178#define C6DOFIMU_WHO_AM_I 0x0F
185#define C6DOFIMU_WAKE_UP_SRC 0x1B
186#define C6DOFIMU_TAP_SRC 0x1C
187#define C6DOFIMU_D6D_SRC 0x1D
189#define C6DOFIMU_FUN_SRC 0x53
191#define C6DOFIMU_TAP_CFG 0x58
192#define C6DOFIMU_TAP_THS_6D 0x59
193#define C6DOFIMU_INT_DUR2 0x5A
194#define C6DOFIMU_WAKE_UP_THS 0x5B
195#define C6DOFIMU_WAKE_UP_DUR 0x5C
196#define C6DOFIMU_FREE_FALL 0x5D
197#define C6DOFIMU_MD1_CFG 0x5E
198#define C6DOFIMU_MD2_CFG 0x5F
205#define C6DOFIMU_CFG_BIT_0 0x01
206#define C6DOFIMU_CFG_BIT_1 0x02
207#define C6DOFIMU_CFG_BIT_2 0x04
208#define C6DOFIMU_CFG_BIT_3 0x08
209#define C6DOFIMU_CFG_BIT_4 0x10
210#define C6DOFIMU_CFG_BIT_5 0x20
211#define C6DOFIMU_CFG_BIT_6 0x40
212#define C6DOFIMU_CFG_BIT_7 0x80
219#define C6DOFIMU_ACCEL_READ_MODE 0x00
220#define C6DOFIMU_GYRO_READ_MODE 0x01
#define C6DOFIMU_RETVAL
Definition c6dofimu.h:90
C6DOFIMU_RETVAL c6dofimu_init(c6dofimu_t *ctx, c6dofimu_cfg_t *cfg)
Initialization function.
void c6dofimu_default_cfg(c6dofimu_t *ctx)
Click Default Configuration function.
void c6dofimu_generic_read(c6dofimu_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void c6dofimu_cfg_setup(c6dofimu_cfg_t *cfg)
Config Object Initialization function.
void c6dofimu_generic_write(c6dofimu_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t c6dofimu_digital_read_int(c6dofimu_t *ctx)
Digital read interrupt function.
void c6dofimu_read_axis_data(c6dofimu_t *ctx, uint8_t read_mode)
Read axis data function.
float c6dofimu_read_temperature(c6dofimu_t *ctx)
Read temperature data function.
uint8_t c6dofimu_select_t
Communication type.
Definition c6dofimu.h:233
void(* c6dofimu_master_io_t)(struct c6dofimu_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition c6dofimu.h:238
struct c6dofimu_s c6dofimu_t
Click ctx object definition.
Gyro/Accel Axis structure.
Definition c6dofimu.h:244
int16_t z
Definition c6dofimu.h:247
int16_t x
Definition c6dofimu.h:245
int16_t y
Definition c6dofimu.h:246
Click configuration structure definition.
Definition c6dofimu.h:285
c6dofimu_select_t sel
Definition c6dofimu.h:307
uint32_t i2c_speed
Definition c6dofimu.h:301
spi_master_chip_select_polarity_t cs_polarity
Definition c6dofimu.h:305
pin_name_t sck
Definition c6dofimu.h:292
spi_master_mode_t spi_mode
Definition c6dofimu.h:304
pin_name_t mosi
Definition c6dofimu.h:291
uint32_t spi_speed
Definition c6dofimu.h:303
pin_name_t scl
Definition c6dofimu.h:288
pin_name_t int_pin
Definition c6dofimu.h:297
pin_name_t miso
Definition c6dofimu.h:290
pin_name_t sda
Definition c6dofimu.h:289
pin_name_t cs
Definition c6dofimu.h:293
uint8_t i2c_address
Definition c6dofimu.h:302
Click ctx object definition.
Definition c6dofimu.h:255
digital_out_t cs
Definition c6dofimu.h:257
spi_master_t spi
Definition c6dofimu.h:266
c6dofimu_master_io_t write_f
Definition c6dofimu.h:272
c6dofimu_master_io_t read_f
Definition c6dofimu.h:273
c6dofimu_select_t master_sel
Definition c6dofimu.h:274
digital_in_t int_pin
Definition c6dofimu.h:261
i2c_master_t i2c
Definition c6dofimu.h:265
c6dofimu_axis_t accel_axis
Definition c6dofimu.h:276
uint8_t slave_address
Definition c6dofimu.h:270
pin_name_t chip_select
Definition c6dofimu.h:271
c6dofimu_axis_t gyro_axis
Definition c6dofimu.h:277