39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
73#define ACCEL24_REG_INT_SRC0 0x00
74#define ACCEL24_REG_INT_CLR0 0x00
75#define ACCEL24_REG_INT_SRC1 0x01
76#define ACCEL24_REG_INT_CLR1 0x01
77#define ACCEL24_REG_STATUS 0x02
78#define ACCEL24_REG_XOUT_MSB 0x03
79#define ACCEL24_REG_XOUT_LSB 0x04
80#define ACCEL24_REG_YOUT_MSB 0x05
81#define ACCEL24_REG_YOUT_LSB 0x06
82#define ACCEL24_REG_ZOUT_MSB 0x07
83#define ACCEL24_REG_ZOUT_LSB 0x08
84#define ACCEL24_REG_TOUT 0x09
85#define ACCEL24_REG_INT_MASK0 0x0A
86#define ACCEL24_REG_INT_MASK1 0x0B
87#define ACCEL24_REG_DETECTION 0x0C
88#define ACCEL24_REG_CONTROL 0x0D
89#define ACCEL24_REG_WHO_AM_I 0x0F
107#define ACCEL24_INT_SRC0_CHORZ 0x80
108#define ACCEL24_INT_SRC0_CHORXY 0x40
109#define ACCEL24_INT_SRC0_SHYM 0x08
110#define ACCEL24_INT_SRC0_SHYP 0x04
111#define ACCEL24_INT_SRC0_SHXM 0x02
112#define ACCEL24_INT_SRC0_SHXP 0x01
118#define ACCEL24_INT_CLR0_ORZC 0x80
119#define ACCEL24_INT_CLR0_ORXYC 0x40
120#define ACCEL24_INT_CLR0_SHYMC 0x08
121#define ACCEL24_INT_CLR0_SHYPC 0x04
122#define ACCEL24_INT_CLR0_SHXMC 0x02
123#define ACCEL24_INT_CLR0_SHXPC 0x01
124#define ACCEL24_INT_CLR0_ALL 0xCF
130#define ACCEL24_INT_SRC1_TILT 0x80
131#define ACCEL24_INT_SRC1_ORZ 0x40
132#define ACCEL24_INT_SRC1_ORXY_X_PLUS 0x00
133#define ACCEL24_INT_SRC1_ORXY_Y_PLUS 0x10
134#define ACCEL24_INT_SRC1_ORXY_X_MINUS 0x20
135#define ACCEL24_INT_SRC1_ORXY_Y_MINUS 0x30
136#define ACCEL24_INT_SRC1_ORXY_MASK 0x30
137#define ACCEL24_INT_SRC1_DRDY 0x01
143#define ACCEL24_INT_CLR1_SW_RST 0x10
144#define ACCEL24_INT_CLR1_DRDYC 0x01
150#define ACCEL24_STATUS_ORD 0x10
151#define ACCEL24_STATUS_ORIZ_MSB 0x08
152#define ACCEL24_STATUS_ORIZ_LSB 0x04
153#define ACCEL24_STATUS_ORIXY_MSB 0x02
154#define ACCEL24_STATUS_ORIXY_LSB 0x01
160#define ACCEL24_INT_MASK0_ORZE 0x80
161#define ACCEL24_INT_MASK0_ORXYE 0x40
162#define ACCEL24_INT_MASK0_SHYME 0x08
163#define ACCEL24_INT_MASK0_SHYPE 0x04
164#define ACCEL24_INT_MASK0_SHXME 0x02
165#define ACCEL24_INT_MASK0_SHXPE 0x01
166#define ACCEL24_INT_MASK0_NONE 0x00
167#define ACCEL24_INT_MASK0_ALL 0xCF
173#define ACCEL24_INT_MASK1_TC 0x80
174#define ACCEL24_INT_MASK1_DRDYE 0x01
180#define ACCEL24_DETECTION_SHM 0x80
181#define ACCEL24_DETECTION_SHTH_0p25G 0x00
182#define ACCEL24_DETECTION_SHTH_0p5G 0x10
183#define ACCEL24_DETECTION_SHTH_0p75G 0x20
184#define ACCEL24_DETECTION_SHTH_1G 0x30
185#define ACCEL24_DETECTION_SHTH_1p25G 0x40
186#define ACCEL24_DETECTION_SHTH_1p5G 0x50
187#define ACCEL24_DETECTION_SHTH_1p75G 0x60
188#define ACCEL24_DETECTION_SHTH_2G 0x70
189#define ACCEL24_DETECTION_SHTH_MASK 0x70
190#define ACCEL24_DETECTION_SHC_8 0x00
191#define ACCEL24_DETECTION_SHC_16 0x04
192#define ACCEL24_DETECTION_SHC_32 0x08
193#define ACCEL24_DETECTION_SHC_64 0x0C
194#define ACCEL24_DETECTION_SHC_MASK 0x0C
195#define ACCEL24_DETECTION_ORC_16 0x00
196#define ACCEL24_DETECTION_ORC_32 0x01
197#define ACCEL24_DETECTION_ORC_64 0x02
198#define ACCEL24_DETECTION_ORC_128 0x03
199#define ACCEL24_DETECTION_ORC_MASK 0x03
200#define ACCEL24_DETECTION_NONE 0x00
206#define ACCEL24_CONTROL_ST 0x80
207#define ACCEL24_CONTROL_FSR_2G 0x00
208#define ACCEL24_CONTROL_FSR_4G 0x20
209#define ACCEL24_CONTROL_FSR_8G 0x40
210#define ACCEL24_CONTROL_FSR_UNDEFINED 0x60
211#define ACCEL24_CONTROL_FSR_MASK 0x60
212#define ACCEL24_CONTROL_PD 0x01
218#define ACCEL24_ACCEL_RESOLUTION 2048.0f
219#define ACCEL24_TEMP_SENSITIVITY 0.586f
220#define ACCEL24_TEMP_NOMINAL 25.0f
226#define ACCEL24_FSR_2G 0
227#define ACCEL24_FSR_4G 1
228#define ACCEL24_FSR_8G 2
234#define ACCEL24_WHO_AM_I 0x05
235#define ACCEL24_WHO_AM_I_MASK 0x0F
242#define ACCEL24_DEVICE_ADDRESS 0x15
260#define ACCEL24_MAP_MIKROBUS( cfg, mikrobus ) \
261 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
262 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
263 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
accel24_return_value_t
Accel 24 Click return value data.
Definition accel24.h:321
@ ACCEL24_OK
Definition accel24.h:322
@ ACCEL24_ERROR
Definition accel24.h:323
err_t accel24_default_cfg(accel24_t *ctx)
Accel 24 default configuration function.
uint8_t accel24_get_int_pin(accel24_t *ctx)
Accel 24 get int pin function.
err_t accel24_read_data(accel24_t *ctx, accel24_data_t *data_out)
Accel 24 read data function.
err_t accel24_init(accel24_t *ctx, accel24_cfg_t *cfg)
Accel 24 initialization function.
err_t accel24_write_register(accel24_t *ctx, uint8_t reg, uint8_t data_in)
Accel 24 write register function.
err_t accel24_set_full_scale_range(accel24_t *ctx, uint8_t fsr)
Accel 24 set full scale range function.
err_t accel24_read_register(accel24_t *ctx, uint8_t reg, uint8_t *data_out)
Accel 24 read register function.
err_t accel24_soft_reset(accel24_t *ctx)
Accel 24 soft reset function.
err_t accel24_generic_read(accel24_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Accel 24 I2C reading function.
void accel24_cfg_setup(accel24_cfg_t *cfg)
Accel 24 configuration object setup function.
err_t accel24_generic_write(accel24_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Accel 24 I2C writing function.
err_t accel24_check_communication(accel24_t *ctx)
Accel 24 check communication function.
Accel 24 Click configuration object.
Definition accel24.h:292
uint32_t i2c_speed
Definition accel24.h:298
pin_name_t scl
Definition accel24.h:293
pin_name_t int_pin
Definition accel24.h:296
pin_name_t sda
Definition accel24.h:294
uint8_t i2c_address
Definition accel24.h:299
Accel 24 Click data structure.
Definition accel24.h:308
float y
Definition accel24.h:310
float x
Definition accel24.h:309
float z
Definition accel24.h:311
float temperature
Definition accel24.h:312
Accel 24 Click context object.
Definition accel24.h:273
digital_in_t int_pin
Definition accel24.h:275
i2c_master_t i2c
Definition accel24.h:278
float fsr_sens
Definition accel24.h:283
uint8_t slave_address
Definition accel24.h:281