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"
66#define ACCEL8_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.da = MIKROBUS( mikrobus, MIKROBUS_AN ); \
70 cfg.cl = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
78#define ACCEL8_RETVAL uint8_t
81#define ACCEL8_INIT_ERROR 0xFF
88#define ACCEL8_REG_SELF_TEST_X 0x0D
89#define ACCEL8_REG_SELF_TEST_Y 0x0E
90#define ACCEL8_REG_SELF_TEST_Z 0x0F
91#define ACCEL8_REG_SELF_TEST_A 0x10
92#define ACCEL8_REG_SMPLRT_DIV 0x19
93#define ACCEL8_REG_CONFIG 0x1A
94#define ACCEL8_REG_GYRO_CONFIG 0x1B
95#define ACCEL8_REG_ACCEL_CONFIG 0x1C
96#define ACCEL8_REG_FIFO_EN 0x23
97#define ACCEL8_REG_I2C_MST_CTRL 0x24
98#define ACCEL8_REG_I2C_SLV0_ADDR 0x25
99#define ACCEL8_REG_I2C_SLV0_REG 0x26
100#define ACCEL8_REG_I2C_SLV0_CTRL 0x27
101#define ACCEL8_REG_I2C_SLV1_ADDR 0x28
102#define ACCEL8_REG_I2C_SLV1_REG 0x29
103#define ACCEL8_REG_I2C_SLV1_CTRL 0x2A
104#define ACCEL8_REG_I2C_SLV2_ADDR 0x2B
105#define ACCEL8_REG_I2C_SLV2_REG 0x2C
106#define ACCEL8_REG_I2C_SLV2_CTRL 0x2D
107#define ACCEL8_REG_I2C_SLV3_ADDR 0x2E
108#define ACCEL8_REG_I2C_SLV3_REG 0x2F
109#define ACCEL8_REG_I2C_SLV3_CTRL 0x30
110#define ACCEL8_REG_I2C_SLV4_ADDR 0x31
111#define ACCEL8_REG_I2C_SLV4_REG 0x32
112#define ACCEL8_REG_I2C_SLV4_DO 0x33
113#define ACCEL8_REG_I2C_SLV4_CTRL 0x34
114#define ACCEL8_REG_I2C_SLV4_DI 0x35
115#define ACCEL8_REG_I2C_MST_STATUS 0x36
116#define ACCEL8_REG_INT_PIN_CFG 0x37
117#define ACCEL8_REG_INT_ENABLE 0x38
118#define ACCEL8_REG_INT_STATUS 0x3A
119#define ACCEL8_REG_ACCEL_XOUT_H 0x3B
120#define ACCEL8_REG_ACCEL_XOUT_L 0x3C
121#define ACCEL8_REG_ACCEL_YOUT_H 0x3D
122#define ACCEL8_REG_ACCEL_YOUT_L 0x3E
123#define ACCEL8_REG_ACCEL_ZOUT_H 0x3F
124#define ACCEL8_REG_ACCEL_ZOUT_L 0x40
125#define ACCEL8_REG_TEMP_OUT_H 0x41
126#define ACCEL8_REG_TEMP_OUT_L 0x42
127#define ACCEL8_REG_GYRO_XOUT_H 0x43
128#define ACCEL8_REG_GYRO_XOUT_L 0x44
129#define ACCEL8_REG_GYRO_YOUT_H 0x45
130#define ACCEL8_REG_GYRO_YOUT_L 0x46
131#define ACCEL8_REG_GYRO_ZOUT_H 0x47
132#define ACCEL8_REG_GYRO_ZOUT_L 0x48
133#define ACCEL8_REG_EXT_SENS_DATA_00 0x49
134#define ACCEL8_REG_EXT_SENS_DATA_01 0x4A
135#define ACCEL8_REG_EXT_SENS_DATA_02 0x4B
136#define ACCEL8_REG_EXT_SENS_DATA_03 0x4C
137#define ACCEL8_REG_EXT_SENS_DATA_04 0x4D
138#define ACCEL8_REG_EXT_SENS_DATA_05 0x4E
139#define ACCEL8_REG_EXT_SENS_DATA_06 0x4F
140#define ACCEL8_REG_EXT_SENS_DATA_07 0x50
141#define ACCEL8_REG_EXT_SENS_DATA_08 0x51
142#define ACCEL8_REG_EXT_SENS_DATA_09 0x52
143#define ACCEL8_REG_EXT_SENS_DATA_10 0x53
144#define ACCEL8_REG_EXT_SENS_DATA_11 0x54
145#define ACCEL8_REG_EXT_SENS_DATA_12 0x55
146#define ACCEL8_REG_EXT_SENS_DATA_13 0x56
147#define ACCEL8_REG_EXT_SENS_DATA_14 0x57
148#define ACCEL8_REG_EXT_SENS_DATA_15 0x58
149#define ACCEL8_REG_EXT_SENS_DATA_16 0x59
150#define ACCEL8_REG_EXT_SENS_DATA_17 0x5A
151#define ACCEL8_REG_EXT_SENS_DATA_18 0x5B
152#define ACCEL8_REG_EXT_SENS_DATA_19 0x5C
153#define ACCEL8_REG_EXT_SENS_DATA_20 0x5D
154#define ACCEL8_REG_EXT_SENS_DATA_21 0x5E
155#define ACCEL8_REG_EXT_SENS_DATA_22 0x5F
156#define ACCEL8_REG_EXT_SENS_DATA_23 0x60
157#define ACCEL8_REG_I2C_SLV0_DO 0x63
158#define ACCEL8_REG_I2C_SLV1_DO 0x64
159#define ACCEL8_REG_I2C_SLV2_DO 0x65
160#define ACCEL8_REG_I2C_SLV3_DO 0x66
161#define ACCEL8_REG_I2C_MST_DELAY_CTRL 0x67
162#define ACCEL8_REG_SIGNAL_PATH_RESET 0x68
163#define ACCEL8_REG_USER_CTRL 0x6A
164#define ACCEL8_REG_PWR_MGMT_1 0x6B
165#define ACCEL8_REG_PWR_MGMT_2 0x6C
166#define ACCEL8_REG_FIFO_COUNTH 0x72
167#define ACCEL8_REG_FIFO_COUNTL 0x73
168#define ACCEL8_REG_FIFO_R_W 0x74
169#define ACCEL8_REG_WHO_AM_I 0x75
176#define ACCEL8_CFG_EXT_SYNC_INPUT_DISABLED 0x00 << 3
177#define ACCEL8_CFG_EXT_SYNC_TEMP_OUTPUT 0x01 << 3
178#define ACCEL8_CFG_EXT_SYNC_GYRO_X_OUTPUT 0x02 << 3
179#define ACCEL8_CFG_EXT_SYNC_GYRO_Y_OUTPUT 0x03 << 3
180#define ACCEL8_CFG_EXT_SYNC_GYRO_Z_OUTPUT 0x04 << 3
181#define ACCEL8_CFG_EXT_SYNC_ACCEL_X_OUTPUT 0x05 << 3
182#define ACCEL8_CFG_EXT_SYNC_ACCEL_Y_OUTPUT 0x06 << 3
183#define ACCEL8_CFG_EXT_SYNC_ACCEL_Z_OUTPUT 0x07 << 3
184#define ACCEL8_CFG_DLPF_CFG_BW_A260_G256 0x00
185#define ACCEL8_CFG_DLPF_CFG_BW_A184_G188 0x01
186#define ACCEL8_CFG_DLPF_CFG_BW_A94_G98 0x02
187#define ACCEL8_CFG_DLPF_CFG_BW_A44_G42 0x03
188#define ACCEL8_CFG_DLPF_CFG_BW_A21_G20 0x04
189#define ACCEL8_CFG_DLPF_CFG_BW_A10_G10 0x05
190#define ACCEL8_CFG_DLPF_CFG_BW_A5_G5 0x06
197#define ACCEL8_GYRO_CFG_X_SELF_TEST 0x80
198#define ACCEL8_GYRO_CFG_Y_SELF_TEST 0x40
199#define ACCEL8_GYRO_CFG_Z_SELF_TEST 0x20
200#define ACCEL8_GYRO_CFG_FULL_SCALE_RANGE_250dbs 0x00
201#define ACCEL8_GYRO_CFG_FULL_SCALE_RANGE_500dbs 0x08
202#define ACCEL8_GYRO_CFG_FULL_SCALE_RANGE_1000dbs 0x10
203#define ACCEL8_GYRO_CFG_FULL_SCALE_RANGE_2000dbs 0x18
210#define ACCEL8_ACCEL_CFG_X_SELF_TEST 0x80
211#define ACCEL8_ACCEL_CFG_Y_SELF_TEST 0x40
212#define ACCEL8_ACCEL_CFG_Z_SELF_TEST 0x20
213#define ACCEL8_ACCEL_CFG_FULL_SCALE_RANGE_2g 0x00
214#define ACCEL8_ACCEL_CFG_FULL_SCALE_RANGE_4g 0x08
215#define ACCEL8_ACCEL_CFG_FULL_SCALE_RANGE_8g 0x10
216#define ACCEL8_ACCEL_CFG_FULL_SCALE_RANGE_16g 0x18
223#define ACCEL8_FIFO_ENABLE_TEMP 0x80
224#define ACCEL8_FIFO_ENABLE_X_AXIS_GYRO 0x40
225#define ACCEL8_FIFO_ENABLE_Y_AXIS_GYRO 0x20
226#define ACCEL8_FIFO_ENABLE_Z_AXIS_GYRO 0x10
227#define ACCEL8_FIFO_ENABLE_ACCEL 0x08
228#define ACCEL8_FIFO_ENABLE_EXT_SENS_DATA_SLV2 0x04
229#define ACCEL8_FIFO_ENABLE_EXT_SENS_DATA_SLV1 0x02
230#define ACCEL8_FIFO_ENABLE_EXT_SENS_DATA_SLV0 0x01
237#define ACCEL8_I2C_MST_CTRL_MUL_MST_ENABLE 0x80
238#define ACCEL8_I2C_MST_CTRL_WAIT_FOR_ES 0x40
239#define ACCEL8_I2C_MST_CTRL_EXT_SENS_DATA_SLV3 0x20
240#define ACCEL8_I2C_MST_CTRL_I2C_RESTART_BETWEEN_READS 0x00
241#define ACCEL8_I2C_MST_CTRL_I2C_STOP_AND_START 0x10
242#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_348kHz 0x00
243#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_333kHz 0x01
244#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_320kHz 0x02
245#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_308kHz 0x03
246#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_296kHz 0x04
247#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_286kHz 0x05
248#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_276kHz 0x06
249#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_367kHz 0x07
250#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_358kHz 0x08
251#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_500kHz 0x09
252#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_471kHz 0x0A
253#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_444kHz 0x0B
254#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_421kHz 0x0C
255#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_400kHz 0x0D
256#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_381kHz 0x0E
257#define ACCEL8_I2C_MST_CTRL_I2C_CLOCK_364kHz 0x0F
264#define ACCEL8_INTC_INT_PIN_IS_ACTIVE_HIGH 0x00
265#define ACCEL8_INTC_INT_PIN_IS_ACTIVE_LOW 0x80
266#define ACCEL8_INTC_INT_PIN_IS_CONFIGURED_AS_PUSH_PULL 0x00
267#define ACCEL8_INTC_INT_PIN_IS_CONFIGURED_AS_OPEN_DRAIN 0x40
268#define ACCEL8_INTC_LATCH_INT_ENABLE 0x20
269#define ACCEL8_INTC_INT_READ_CLEAR 0x10
270#define ACCEL8_INTC_FSYNC_INT_LEVEL_ACTIVE_HIGH 0x00
271#define ACCEL8_INTC_FSYNC_INT_LEVEL_ACTIVE_LOW 0x08
272#define ACCEL8_INTC_FSYNC_INT_ENABLE 0x04
273#define ACCEL8_INTC_I2C_BYPASS_ENABLE 0x02
274#define ACCEL8_INTC_I2C_BYPASS_DISABLE 0x00
281#define ACCEL8_INTE_FIFO_OFLOW_ENABLE 0x10
282#define ACCEL8_INTE_I2C_MST_INT_ENABLE 0x08
283#define ACCEL8_INTE_DATA_RDY_ENABLE 0x01
290#define ACCEL8_INTS_FIFO_OFLOW 0x10
291#define ACCEL8_INTS_I2C_MST_INT 0x08
292#define ACCEL8_INTS_DATA_RDY 0x01
299#define ACCEL8_ACCEL_X_AXIS_DATA 0x3B
300#define ACCEL8_ACCEL_Y_AXIS_DATA 0x3D
301#define ACCEL8_ACCEL_Z_AXIS_DATA 0x3F
302#define ACCEL8_TEMP_DATA 0x41
303#define ACCEL8_GYRO_X_AXIS_DATA 0x43
304#define ACCEL8_GYRO_Y_AXIS_DATA 0x45
305#define ACCEL8_GYRO_Z_AXIS_DATA 0x47
312#define ACCEL8_GYRO_RESET 0x04
313#define ACCEL8_ACCEL_RESET 0x02
314#define ACCEL8_TEMP_RESET 0x01
321#define ACCEL8_UC_FIFO_ENABLE 0x40
322#define ACCEL8_UC_I2C_MASTER_MODE 0x20
323#define ACCEL8_UC_FIFO_RESET 0x04
324#define ACCEL8_UC_I2C_MASTER_RESET 0x02
325#define ACCEL8_UC_SIG_COND_RESET 0x01
332#define ACCEL8_PM1_DEVICE_RESET 0x80
333#define ACCEL8_PM1_GO_TO_SLEEP 0x40
334#define ACCEL8_PM1_CYCLE 0x20
335#define ACCEL8_PM1_TEMP_DISABLE 0x08
336#define ACCEL8_PM1_CLKSEL_INTERNAL_8MHZ_OSCILLATOR 0x00
337#define ACCEL8_PM1_CLKSEL_PLL_WITH_X_AXIS_GYROSCOPE 0x01
338#define ACCEL8_PM1_CLKSEL_PLL_WITH_Y_AXIS_GYROSCOPE 0x02
339#define ACCEL8_PM1_CLKSEL_PLL_WITH_Z_AXIS_GYROSCOPE 0x03
340#define ACCEL8_PM1_CLKSEL_PLL_WITH_EXTERNAL_32_768kHz 0x04
341#define ACCEL8_PM1_CLKSEL_PLL_WITH_EXTERNAL_19_2kHz 0x05
342#define ACCEL8_PM1_CLKSEL_STOPS_THE_CLOCK 0x07
349#define ACCEL8_PM2_LP_WAKE_CTRL_WAKE_UP_FREQ_1_25Hz 0x00
350#define ACCEL8_PM2_LP_WAKE_CTRL_WAKE_UP_FREQ_5Hz 0x40
351#define ACCEL8_PM2_LP_WAKE_CTRL_WAKE_UP_FREQ_20Hz 0x80
352#define ACCEL8_PM2_LP_WAKE_CTRL_WAKE_UP_FREQ_40Hz 0xC0
353#define ACCEL8_PM2_LP_WAKE_CTRL_X_AXIS_ACCEL_STANDBY_MODE 0x20
354#define ACCEL8_PM2_LP_WAKE_CTRL_Y_AXIS_ACCEL_STANDBY_MODE 0x10
355#define ACCEL8_PM2_LP_WAKE_CTRL_Z_AXIS_ACCEL_STANDBY_MODE 0x08
356#define ACCEL8_PM2_LP_WAKE_CTRL_X_AXIS_GYRO_STANDBY_MODE 0x04
357#define ACCEL8_PM2_LP_WAKE_CTRL_Y_AXIS_GYRO_STANDBY_MODE 0x02
358#define ACCEL8_PM2_LP_WAKE_CTRL_Z_AXIS_GYRO_STANDBY_MODE 0x01
365#define ACCEL8_DEVICE_SLAVE_ADDRESS_ADD 0x69
366#define ACCEL8_DEVICE_SLAVE_ADDRESS_SEL 0x68
#define ACCEL8_RETVAL
Definition accel8.h:78
void accel8_cfg_setup(accel8_cfg_t *cfg)
Config Object Initialization function.
void accel8_get_accel_axis(accel8_t *ctx, int16_t *x_axis, int16_t *y_axis, int16_t *z_axis)
Functions for read Accel axis data.
uint8_t accel8_get_interrupt(accel8_t *ctx)
Functions for read INT pin state.
void accel8_generic_write(accel8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void accel8_default_cfg(accel8_t *ctx, uint8_t accel_cfg, uint8_t gyro_cfg, range_retval_t *rng)
Click Default Configuration function.
uint16_t accel8_read_data(accel8_t *ctx, uint8_t reg)
Generic read function.
void accel8_get_gyro_axis(accel8_t *ctx, int16_t *x_axis, int16_t *y_axis, int16_t *z_axis)
Functions for read Gyro axis data.
void accel8_generic_read(accel8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
ACCEL8_RETVAL accel8_init(accel8_t *ctx, accel8_cfg_t *cfg)
Initialization function.
float accel8_get_temperature(accel8_t *ctx)
Functions for read Temperature data in C.
Click configuration structure definition.
Definition accel8.h:401
pin_name_t da
Definition accel8.h:409
pin_name_t cl
Definition accel8.h:410
uint32_t i2c_speed
Definition accel8.h:415
pin_name_t scl
Definition accel8.h:404
pin_name_t int_pin
Definition accel8.h:411
pin_name_t sda
Definition accel8.h:405
uint8_t i2c_address
Definition accel8.h:416
Click ctx object definition.
Definition accel8.h:380
digital_in_t cl
Definition accel8.h:384
digital_in_t da
Definition accel8.h:383
digital_in_t int_pin
Definition accel8.h:385
i2c_master_t i2c
Definition accel8.h:389
uint8_t slave_address
Definition accel8.h:393
Click range structure definition.
Definition accel8.h:424
uint8_t accel_range
Definition accel8.h:427
uint16_t gyro_range
Definition accel8.h:428