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"
67#define ACCEL10_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
71 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
72 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
73 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
74 cfg.it1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
75 cfg.it2 = MIKROBUS( mikrobus, MIKROBUS_INT )
82#define ACCEL10_MASTER_I2C 0
83#define ACCEL10_MASTER_SPI 1
90#define ACCEL10_RETVAL uint8_t
92#define ACCEL10_OK 0x00
93#define ACCEL10_INIT_ERROR 0xFF
100#define ACCEL10_SLAVE_ADDRESS_GND 0x18
101#define ACCEL10_SLAVE_ADDRESS_VCC 0x19
108#define ACCEL10_REG_OUT_T_L 0x0D
109#define ACCEL10_REG_OUT_T_H 0x0E
110#define ACCEL10_REG_WHO_AM_I 0x0F
111#define ACCEL10_REG_CTRL1 0x20
112#define ACCEL10_REG_CTRL2 0x21
113#define ACCEL10_REG_CTRL3 0x22
114#define ACCEL10_REG_CTRL4_INT1_PAD_CTRL 0x23
115#define ACCEL10_REG_CTRL5_INT2_PAD_CTRL 0x24
116#define ACCEL10_REG_CTRL6 0x25
117#define ACCEL10_REG_OUT_T 0x26
118#define ACCEL10_REG_STATUS 0x27
119#define ACCEL10_REG_OUT_X_L 0x28
120#define ACCEL10_REG_OUT_X_H 0x29
121#define ACCEL10_REG_OUT_Y_L 0x2A
122#define ACCEL10_REG_OUT_Y_H 0x2B
123#define ACCEL10_REG_OUT_Z_L 0x2C
124#define ACCEL10_REG_OUT_Z_H 0x2D
125#define ACCEL10_REG_FIFO_CTRL 0x2E
126#define ACCEL10_REG_FIFO_SAMPLES 0x2F
127#define ACCEL10_REG_TAP_THS_X 0x30
128#define ACCEL10_REG_TAP_THS_Y 0x31
129#define ACCEL10_REG_TAP_THS_Z 0x32
130#define ACCEL10_REG_INT_DUR 0x33
131#define ACCEL10_REG_WAKE_UP_THS 0x34
132#define ACCEL10_REG_WAKE_UP_DUR 0x35
133#define ACCEL10_REG_FREE_FALL 0x36
134#define ACCEL10_REG_STATUS_DUP 0x37
135#define ACCEL10_REG_WAKE_UP_SRC 0x38
136#define ACCEL10_REG_TAP_SRC 0x39
137#define ACCEL10_REG_SIXD_SRC 0x3A
138#define ACCEL10_REG_ALL_INT_SRC 0x3B
139#define ACCEL10_REG_X_OFS_USR 0x3C
140#define ACCEL10_REG_Y_OFS_USR 0x3D
141#define ACCEL10_REG_Z_OFS_USR 0x3E
142#define ACCEL10_REG_CTRL_REG7 0x3F
149#define ACCEL10_WHO_AM_I_DEFAULT_VALUE 0x44
161#define ACCEL10_LP_MODE_1 0x00
162#define ACCEL10_LP_MODE_2 0x01
163#define ACCEL10_LP_MODE_3 0x02
164#define ACCEL10_LP_MODE_4 0x03
171#define ACCEL10_MODE_LOW_POWER 0x00
172#define ACCEL10_MODE_HIGH_PERF 0x04
173#define ACCEL10_MODE_SINGLE_CONV 0x08
180#define ACCEL10_ODR_POWER_DOWN 0x00
181#define ACCEL10_ODR_12_5_1_6HZ 0x10
182#define ACCEL10_ODR_12_5Hz 0x20
183#define ACCEL10_ODR_25Hz 0x30
184#define ACCEL10_ODR_50Hz 0x40
185#define ACCEL10_ODR_100Hz 0x50
186#define ACCEL10_ODR_200Hz 0x60
187#define ACCEL10_ODR_400_200Hz 0x70
188#define ACCEL10_ODR_800_200Hz 0x80
189#define ACCEL10_ODR_1600_200Hz 0x90
203#define ACCEL10_SIM_4_WIRE 0x00
204#define ACCEL10_SIM_3_WIRE 0x01
211#define ACCEL10_I2C_ENABLE_I2C_AND_SPI 0x00
212#define ACCEL10_I2C_ENABLE_SPI_ONLY 0x02
219#define ACCEL10_IF_ADD_INC_DISABLE 0x00
220#define ACCEL10_IF_ADD_INC_ENABLE 0x04
227#define ACCEL10_BDU_CONTINUOUS_UPDATE 0x00
228#define ACCEL10_BDU_NOT_UPDATE_MSB_LSB 0x08
235#define ACCEL10_CS_PU_DISC_CONNECT 0x00
236#define ACCEL10_CS_PU_DISC_DISCONNECT 0x10
243#define ACCEL10_SOFT_RESET_DISABLE 0x00
244#define ACCEL10_SOFT_RESET_ENABLE 0x40
251#define ACCEL10_BOOT_DISABLE 0x00
252#define ACCEL10_BOOT_ENABLE 0x80
266#define ACCEL10_SLP_MODE_1_CONV_START 0x01
273#define ACCEL10_SLP_MODE_SEL_EN_INT2 0x00
274#define ACCEL10_SLP_MODE_SEL_EN_MODE1 0x02
281#define ACCEL10_H_LACTIVE_HIGH 0x00
282#define ACCEL10_H_LACTIVE_LOW 0x08
289#define ACCEL10_LIR_NOT_LATCHED 0x00
290#define ACCEL10_LIR_LATCHED 0x10
297#define ACCEL10_PP_OD_PUSH_PULL 0x00
298#define ACCEL10_PP_OD_OPEN_DRAIN 0x20
305#define ACCEL10_ST_NORMAL 0x00
306#define ACCEL10_ST_POSITIVE 0x40
307#define ACCEL10_ST_NEGATIVE 0x80
320#define ACCEL10_INT1_DRDY_DISABLE 0x00
321#define ACCEL10_INT1_DRDY_ENABLE 0x01
328#define ACCEL10_INT1_FTH_DISABLE 0x00
329#define ACCEL10_INT1_FTH_ENABLE 0x02
336#define ACCEL10_INT1_DIFF5_DISABLE 0x00
337#define ACCEL10_INT1_DIFF5_ENABLE 0x04
344#define ACCEL10_INT1_TAP_DISABLE 0x00
345#define ACCEL10_INT1_TAP_ENABLE 0x08
352#define ACCEL10_INT1_FF_DISABLE 0x00
353#define ACCEL10_INT1_FF_ENABLE 0x10
360#define ACCEL10_INT1_WU_DISABLE 0x00
361#define ACCEL10_INT1_WU_ENABLE 0x20
368#define ACCEL10_INT1_SINGLE_TAP_DISABLE 0x00
369#define ACCEL10_INT1_SINGLE_TAP_ENABLE 0x40
376#define ACCEL10_INT1_6D_DISABLE 0x00
377#define ACCEL10_INT1_6D_ENABLE 0x80
389#define ACCEL10_INT2_DRDY_DISABLE 0x00
390#define ACCEL10_INT2_DRDY_ENABLE 0x01
397#define ACCEL10_INT2_FTH_DISABLE 0x00
398#define ACCEL10_INT2_FTH_ENABLE 0x02
405#define ACCEL10_INT2_DIFF5_DISABLE 0x00
406#define ACCEL10_INT2_DIFF5_ENABLE 0x04
413#define ACCEL10_INT2_OVR_DISABLE 0x00
414#define ACCEL10_INT2_OVR_ENABLE 0x08
421#define ACCEL10_INT2_DRDY_T_DISABLE 0x00
422#define ACCEL10_INT2_DRDY_T_ENABLE 0x10
429#define ACCEL10_INT2_BOOT_DISABLE 0x00
430#define ACCEL10_INT2_BOOT_ENABLE 0x20
437#define ACCEL10_INT2_SLEEP_CHG_DISABLE 0x00
438#define ACCEL10_INT2_SLEEP_CHG_ENABLE 0x40
445#define ACCEL10_INT2_SLEEP_STATE_DISABLE 0x00
446#define ACCEL10_INT2_SLEEP_STATE_ENABLE 0x80
458#define ACCEL10_LOW_NOISE_DISABLE 0x00
459#define ACCEL10_LOW_NOISE_ENABLE 0x04
466#define ACCEL10_FSD_LOW_PASS 0x00
467#define ACCEL10_FSD_HIGH_PASS 0x08
474#define ACCEL10_FS_2G 0x00
475#define ACCEL10_FS_4G 0x10
476#define ACCEL10_FS_8G 0x20
477#define ACCEL10_FS_16G 0x30
484#define ACCEL10_BW_FILT_ODR2 0x00
485#define ACCEL10_BW_FILT_ODR4 0x40
486#define ACCEL10_BW_FILT_ODR10 0x80
487#define ACCEL10_BW_FILT_ODR20 0xC0
495#define ACCEL10_STATUS_DATA_READY 0x01
502#define ACCEL10_ERROR 0x00
503#define ACCEL10_SUCCESS 0x01
#define ACCEL10_RETVAL
Definition accel10.h:90
void accel10_generic_read(accel10_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void accel10_cfg_setup(accel10_cfg_t *cfg)
Config Object Initialization function.
uint8_t accel10_check_it2(accel10_t *ctx)
Get interrupt 2 ststus function.
void accel10_get_data(accel10_t *ctx, accel10_data_t *p_accel_data)
Read Accel data function.
void accel10_generic_write(accel10_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
ACCEL10_RETVAL accel10_check_id(accel10_t *ctx)
Check ID function.
ACCEL10_RETVAL accel10_init(accel10_t *ctx, accel10_cfg_t *cfg)
Initialization function.
void accel10_default_cfg(accel10_t *ctx)
Click Default Configuration function.
uint8_t accel10_check_data_ready(accel10_t *ctx)
Check data ready function.
int8_t accel10_read_temperature(accel10_t *ctx)
Read temperature function.
uint8_t accel10_check_it1(accel10_t *ctx)
Get interrupt 1 ststus function.
void accel10_soft_reset(accel10_t *ctx)
Soft reset function.
void(* accel10_master_io_t)(struct accel10_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition accel10.h:521
struct accel10_s accel10_t
Click ctx object definition.
uint8_t accel10_select_t
Communication type.
Definition accel10.h:516
Click configuration structure definition.
Definition accel10.h:553
pin_name_t it2
Definition accel10.h:566
uint32_t i2c_speed
Definition accel10.h:570
pin_name_t it1
Definition accel10.h:565
spi_master_chip_select_polarity_t cs_polarity
Definition accel10.h:575
pin_name_t sck
Definition accel10.h:560
spi_master_mode_t spi_mode
Definition accel10.h:574
pin_name_t mosi
Definition accel10.h:559
uint32_t spi_speed
Definition accel10.h:573
pin_name_t scl
Definition accel10.h:556
pin_name_t miso
Definition accel10.h:558
pin_name_t sda
Definition accel10.h:557
accel10_select_t sel
Definition accel10.h:577
pin_name_t cs
Definition accel10.h:561
uint8_t i2c_address
Definition accel10.h:571
Accel data structure definition.
Definition accel10.h:585
int16_t z
Definition accel10.h:588
int16_t x
Definition accel10.h:586
int16_t y
Definition accel10.h:587
Click ctx object definition.
Definition accel10.h:527
digital_out_t cs
Definition accel10.h:530
spi_master_t spi
Definition accel10.h:537
digital_in_t it2
Definition accel10.h:532
accel10_master_io_t write_f
Definition accel10.h:543
accel10_select_t master_sel
Definition accel10.h:545
i2c_master_t i2c
Definition accel10.h:536
uint8_t slave_address
Definition accel10.h:541
accel10_master_io_t read_f
Definition accel10.h:544
pin_name_t chip_select
Definition accel10.h:542
digital_in_t it1
Definition accel10.h:531