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 ACCEL3_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.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
81#define ACCEL3_MASTER_I2C 0
82#define ACCEL3_MASTER_SPI 1
89#define ACCEL3_RETVAL uint8_t
92#define ACCEL3_INIT_ERROR 0xFF
99#define ACCEL3_I2C_ADDRESS 0x18
106#define ACCEL3_REG_WHO_AM_I 0x0F
107#define ACCEL3_REG_HP_FILTER_RESET 0x25
108#define ACCEL3_REG_REFERENCE 0x26
109#define ACCEL3_REG_STATUS 0x27
116#define ACCEL3_CTRL_REG1 0x20
117#define ACCEL3_CTRL_REG2 0x21
118#define ACCEL3_CTRL_REG3 0x22
119#define ACCEL3_CTRL_REG4 0x23
120#define ACCEL3_CTRL_REG5 0x24
127#define ACCEL3_OUT_X_L 0x28
128#define ACCEL3_OUT_X_H 0x29
129#define ACCEL3_OUT_Y_L 0x2A
130#define ACCEL3_OUT_Y_H 0x2B
131#define ACCEL3_OUT_Z_L 0x2C
132#define ACCEL3_OUT_Z_H 0x2D
139#define ACCEL3_ENABLE_AXIS 0x27
140#define ACCEL3_FULL_SCALE 0x00
141#define ACCEL3_DATA_MASK 0x80
142#define ACCEL3_DEVICE_IDENTIFIER 0x32
143#define ACCEL3_TRUE 0x00
144#define ACCEL3_FALSE 0x01
145#define ACCEL3_START_VALUE 0x00
248 // End constants group
257 // End variable group
#define ACCEL3_RETVAL
Definition accel3.h:89
void accel3_default_cfg(accel3_t *ctx, accel3_cfg_t *cfg)
Click Default Configuration function.
uint8_t accel3_check_id(accel3_t *ctx)
Check Accel 3 ID function.
void accel3_cfg_setup(accel3_cfg_t *cfg)
Config Object Initialization function.
void accel3_generic_write(accel3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void accel3_read_data(accel3_t *ctx, accel3_data_t *accel3_data)
Get accelerometer data function.
ACCEL3_RETVAL accel3_init(accel3_t *ctx, accel3_cfg_t *cfg)
Initialization function.
void accel3_generic_read(accel3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void(* accel3_master_io_t)(struct accel3_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition accel3.h:164
uint8_t accel3_select_t
Communication type.
Definition accel3.h:159
struct accel3_s accel3_t
Click ctx object definition.
accel3_data_t accel3_data
Definition main.c:32
Click configuration structure definition.
Definition accel3.h:195
uint8_t spi_mode
Definition accel3.h:214
uint32_t i2c_speed
Definition accel3.h:211
spi_master_chip_select_polarity_t cs_polarity
Definition accel3.h:215
accel3_select_t sel
Definition accel3.h:217
pin_name_t sck
Definition accel3.h:202
pin_name_t mosi
Definition accel3.h:201
uint32_t spi_speed
Definition accel3.h:213
pin_name_t scl
Definition accel3.h:198
pin_name_t int_pin
Definition accel3.h:207
pin_name_t miso
Definition accel3.h:200
pin_name_t sda
Definition accel3.h:199
pin_name_t cs
Definition accel3.h:203
uint8_t i2c_address
Definition accel3.h:212
Accel data object definition.
Definition accel3.h:232
int16_t z
Definition accel3.h:235
int16_t x
Definition accel3.h:233
int16_t y
Definition accel3.h:234
Click ctx object definition.
Definition accel3.h:170
digital_out_t cs
Definition accel3.h:174
spi_master_t spi
Definition accel3.h:179
i2c_master_t i2c
Definition accel3.h:178
accel3_master_io_t read_f
Definition accel3.h:186
digital_out_t int_pin
Definition accel3.h:173
accel3_select_t master_sel
Definition accel3.h:187
uint8_t slave_address
Definition accel3.h:183
accel3_master_io_t write_f
Definition accel3.h:185
pin_name_t chip_select
Definition accel3.h:184