41#ifdef PREINIT_SUPPORTED
45#ifdef MikroCCoreVersion
46 #if MikroCCoreVersion >= 1
51#include "drv_digital_out.h"
52#include "drv_digital_in.h"
53#include "drv_spi_master.h"
66#define ACCEL14_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
68 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
69 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
70 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.i2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
72 cfg.i1 = MIKROBUS( mikrobus, MIKROBUS_INT )
79#define ACCEL14_RETVAL uint8_t
81#define ACCEL14_OK 0x00
82#define ACCEL14_INIT_ERROR 0xFF
89#define ACCEL14_REG_PIN_CTRL 0x02
90#define ACCEL14_REG_FIFO_CTRL1 0x07
91#define ACCEL14_REG_FIFO_CTRL2 0x08
92#define ACCEL14_REG_FIFO_CTRL3 0x09
93#define ACCEL14_REG_FIFO_CTRL4 0x0A
94#define ACCEL14_REG_COUNTER_BDR_REG1 0x0B
95#define ACCEL14_REG_COUNTER_BDR_REG2 0x0C
96#define ACCEL14_REG_INT1_CTRL 0x0D
97#define ACCEL14_REG_INT2_CTRL 0x0E
98#define ACCEL14_REG_WHO_AM_I 0x0F
99#define ACCEL14_REG_CTRL1_XL 0x10
100#define ACCEL14_REG_CTRL3_C 0x12
101#define ACCEL14_REG_CTRL4_C 0x13
102#define ACCEL14_REG_CTRL5_C 0x14
103#define ACCEL14_REG_CTRL6_C 0x15
104#define ACCEL14_REG_CTRL7_C 0x16
105#define ACCEL14_REG_CTRL8_XL 0x17
106#define ACCEL14_REG_CTRL10_C 0x19
107#define ACCEL14_REG_ALL_INT_SRC 0x1A
108#define ACCEL14_REG_WAKE_UP_SRC 0x1B
109#define ACCEL14_REG_STATUS_REG 0x1E
110#define ACCEL14_REG_OUT_TEMP_L 0x20
111#define ACCEL14_REG_OUT_TEMP_H 0x21
112#define ACCEL14_REG_OUTX_L_A 0x28
113#define ACCEL14_REG_OUTX_H_A 0x29
114#define ACCEL14_REG_OUTY_L_A 0x2A
115#define ACCEL14_REG_OUTY_H_A 0x2B
116#define ACCEL14_REG_OUTZ_L_A 0x2C
117#define ACCEL14_REG_OUTZ_H_A 0x2D
118#define ACCEL14_REG_FIFO_STATUS1 0x3A
119#define ACCEL14_REG_FIFO_STATUS2 0x3B
120#define ACCEL14_REG_TIMESTAMP0 0x40
121#define ACCEL14_REG_TIMESTAMP1 0x41
122#define ACCEL14_REG_TIMESTAMP2 0x42
123#define ACCEL14_REG_TIMESTAMP3 0x43
124#define ACCEL14_REG_SLOPE_EN 0x56
125#define ACCEL14_REG_INTERRUPTS_EN 0x58
126#define ACCEL14_REG_WAKE_UP_THS 0x5B
127#define ACCEL14_REG_WAKE_UP_DUR 0x5C
128#define ACCEL14_REG_MD1_CFG 0x5E
129#define ACCEL14_REG_MD2_CFG 0x5F
130#define ACCEL14_REG_INTERNAL_FREQ_FINE 0x63
131#define ACCEL14_REG_X_OFS_USR 0x73
132#define ACCEL14_REG_Y_OFS_USR 0x74
133#define ACCEL14_REG_Z_OFS_USR 0x75
134#define ACCEL14_REG_FIFO_DATA_OUT_TAG 0x78
135#define ACCEL14_REG_FIFO_DATA_OUT_X_L 0x79
136#define ACCEL14_REG_FIFO_DATA_OUT_X_H 0x7A
137#define ACCEL14_REG_FIFO_DATA_OUT_Y_L 0x7B
138#define ACCEL14_REG_FIFO_DATA_OUT_Y_H 0x7C
139#define ACCEL14_REG_FIFO_DATA_OUT_Z_L 0x7D
140#define ACCEL14_REG_FIFO_DATA_OUT_Z_H 0x7E
147#define ACCEL14_ID_VALUE 0x7B
154#define ACCEL14_CTRL1_XL_POWER_BIT_MASK 0xE0
155#define ACCEL14_CTRL1_XL_POWER_DOWN 0x00
156#define ACCEL14_CTRL1_XL_POWER_UP 0xA0
158#define ACCEL14_CTRL1_XL_HIGH_RES_BIT_MASK 0x02
159#define ACCEL14_CTRL1_XL_HIGH_RES_FS 0x00
160#define ACCEL14_CTRL1_XL_HIGH_RES_SS 0x02
162#define ACCEL14_CTRL1_XL_GSEL_BIT_MASK 0x0C
163#define ACCEL14_CTRL1_XL_GSEL_2G 0x00
164#define ACCEL14_CTRL1_XL_GSEL_16G 0x04
165#define ACCEL14_CTRL1_XL_GSEL_4G 0x08
166#define ACCEL14_CTRL1_XL_GSEL_8G 0x0C
168#define ACCEL14_COEF_RES_2G 0.061
169#define ACCEL14_COEF_RES_4G 0.122
170#define ACCEL14_COEF_RES_8G 0.244
171#define ACCEL14_COEF_RES_16G 0.488
178#define ACCEL14_CTRL3_C_BOOT_NORMAL 0x00
179#define ACCEL14_CTRL3_C_BOOT_REBOOT 0x80
180#define ACCEL14_CTRL3_C_BDU_CONTINUOUS 0x00
181#define ACCEL14_CTRL3_C_BDU_READ_UPDATE 0x40
182#define ACCEL14_CTRL3_C_INT_ACTIVE_HIGH 0x00
183#define ACCEL14_CTRL3_C_INT_ACTIVE_LOW 0x20
184#define ACCEL14_CTRL3_C_PP_OD_PUSH_PULL 0x00
185#define ACCEL14_CTRL3_C_PP_OD_OPEN_DRAIN 0x10
186#define ACCEL14_CTRL3_C_SIM_SPI_4_WIRE 0x00
187#define ACCEL14_CTRL3_C_SIM_SPI_3_WIRE 0x08
188#define ACCEL14_CTRL3_C_IF_INC_DISABLE 0x00
189#define ACCEL14_CTRL3_C_IF_INC_ENABLE 0x04
190#define ACCEL14_CTRL3_C_SW_RESET_DIS 0x00
191#define ACCEL14_CTRL3_C_SW_RESET_EN 0x01
198#define ACCEL14_CTRL4_C_INT1_2_DIV 0x00
199#define ACCEL14_CTRL4_C_INT1_2_LOGIC_INT1 0x20
200#define ACCEL14_CTRL4_C_DRDY_MASK_DIS 0x00
201#define ACCEL14_CTRL4_C_DRDY_MASK_EN 0x10
202#define ACCEL14_CTRL4_C_SPI_I2C_EN 0x00
203#define ACCEL14_CTRL4_C_I2C_DISABLE 0x04
204#define ACCEL14_CTRL4_C_3REGOUT_EN 0x00
205#define ACCEL14_CTRL4_C_1AX_EN 0x01
212#define ACCEL14_CTRL5_C_ROUNDING_NO 0x00
213#define ACCEL14_CTRL5_C_ROUNDING_EN 0x20
214#define ACCEL14_CTRL5_C_ST_NORMAL 0x00
215#define ACCEL14_CTRL5_C_ST_POSITIVE 0x01
216#define ACCEL14_CTRL5_C_ST_NEGATIVE 0x02
223#define ACCEL14_CTRL6_C_USR_OFF_W_10 0x00
224#define ACCEL14_CTRL6_C_USR_OFF_W_2 0x08
225#define ACCEL14_CTRL6_C_SEL_3_AXES 0x00
226#define ACCEL14_CTRL6_C_SEL_X_AXES 0x01
227#define ACCEL14_CTRL6_C_SEL_Y_AXES 0x02
228#define ACCEL14_CTRL6_C_SEL_Z_AXES 0x03
235#define ACCEL14_CTRL7_C_USR_OFF_OUT 0x00
236#define ACCEL14_CTRL7_C_USR_ON_OUT 0x02
243#define ACCEL14_CTRL8_ODR_4 0x00
244#define ACCEL14_CTRL8_ODR_10 0x20
245#define ACCEL14_CTRL8_ODR_20 0x40
246#define ACCEL14_CTRL8_ODR_45 0x60
247#define ACCEL14_CTRL8_ODR_100 0x80
248#define ACCEL14_CTRL8_ODR_200 0xA0
249#define ACCEL14_CTRL8_ODR_400 0xC0
250#define ACCEL14_CTRL8_ODR_800 0xE0
251#define ACCEL14_CTRL8_HIGH_PASS_DIS 0x00
252#define ACCEL14_CTRL8_HIGH_PASS_EN 0x10
253#define ACCEL14_CTRL8_LPF2_HPF_DIS 0x00
254#define ACCEL14_CTRL8_LPF2_HPF_EN 0x08
261#define ACCEL14_CTRL10_TIMESTAMP_DIS 0x00
262#define ACCEL14_CTRL10_TIMESTAMP_EN 0x20
269#define ACCEL14_CHECK_ID_ERROR 0x00
270#define ACCEL14_CHECK_ID_SUCCESS 0x01
277#define ACCEL14_STATUS_DATA_READY 0x05
278#define ACCEL14_STATUS_TEMP_READY 0x04
279#define ACCEL14_STATUS_ACCEL_READY 0x01
280#define ACCEL14_NEW_DATA_NO_DATA 0x00
281#define ACCEL14_NEW_DATA_AVAILABLE 0x01
288#define ACCEL14_SPI_WRITE 0x00
289#define ACCEL14_SPI_READ 0x80
296#define ACCEL14_DUMMY 0x00
#define ACCEL14_RETVAL
Definition accel14.h:79
void accel14_default_cfg(accel14_t *ctx)
Click Default Configuration function.
void accel14_read_accel(accel14_t *ctx, accel14_accel_fs_xl_t *accel_fs)
Read Accel data function.
uint8_t accel14_check_communication(accel14_t *ctx)
Check communication function.
void accel14_generic_write(accel14_t *ctx, uint8_t reg, uint8_t tx_data)
Generic write function.
void accel14_cfg_setup(accel14_cfg_t *cfg)
Config Object Initialization function.
uint8_t accel14_check_int1(accel14_t *ctx)
Get interrupt 1 ststus function.
uint8_t accel14_check_accel_data_ready(accel14_t *ctx)
Check accel data ready function.
uint8_t accel14_check_int2(accel14_t *ctx)
Get interrupt 2 ststus function.
uint8_t accel14_check_temp_data_ready(accel14_t *ctx)
Check temperature data ready function.
ACCEL14_RETVAL accel14_init(accel14_t *ctx, accel14_cfg_t *cfg)
Initialization function.
void accel14_generic_transfer(accel14_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
uint8_t accel14_generic_read(accel14_t *ctx, uint8_t reg)
Generic read function.
void accel14_get_data(accel14_t *ctx, accel14_accel_t *accel_data)
Get Accel data function.
float accel14_get_temperature(accel14_t *ctx)
Get temperature function.
void accel14_multi_read(accel14_t *ctx, uint8_t reg, uint8_t *p_rx_data, uint8_t n_bytes)
Generic read sequence function.
float accel_x
Definition accel14.h:316
float accel_z
Definition accel14.h:318
float accel_y
Definition accel14.h:317
int16_t z
Definition accel14.h:310
int16_t x
Definition accel14.h:308
int16_t y
Definition accel14.h:309
Click configuration structure definition.
Definition accel14.h:343
pin_name_t i1
Definition accel14.h:354
spi_master_chip_select_polarity_t cs_polarity
Definition accel14.h:360
pin_name_t sck
Definition accel14.h:348
pin_name_t i2
Definition accel14.h:353
spi_master_mode_t spi_mode
Definition accel14.h:359
pin_name_t mosi
Definition accel14.h:347
uint32_t spi_speed
Definition accel14.h:358
pin_name_t miso
Definition accel14.h:346
pin_name_t cs
Definition accel14.h:349
Click ctx object definition.
Definition accel14.h:326
spi_master_t spi
Definition accel14.h:334
digital_in_t i2
Definition accel14.h:330
digital_in_t i1
Definition accel14.h:329
pin_name_t chip_select
Definition accel14.h:335