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"
68#define ACCEL2_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
70 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
71 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
72 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
73 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
74 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
75 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
82#define ACCEL2_MASTER_I2C 0
83#define ACCEL2_MASTER_SPI 1
90#define ACCEL2_RETVAL uint8_t
93#define ACCEL2_INIT_ERROR 0xFF
100#define ACCEL2_INFO1 0x0D
101#define ACCEL2_INFO2 0x0E
102#define ACCEL2_WHO_AM_I 0x0F
103#define ACCEL2_CTRL_REG3 0x23
104#define ACCEL2_CTRL_REG4 0x20
105#define ACCEL2_CTRL_REG5 0x24
106#define ACCEL2_CTRL_REG6 0x25
107#define ACCEL2_STATUS 0x27
108#define ACCEL2_OUT_T 0x0C
109#define ACCEL2_OFF_X 0x10
110#define ACCEL2_OFF_Y 0x11
111#define ACCEL2_OFF_Z 0x12
112#define ACCEL2_CS_X 0x13
113#define ACCEL2_CS_Y 0x14
114#define ACCEL2_CS_Z 0x15
115#define ACCEL2_LC_L 0x16
116#define ACCEL2_LC_H 0x17
117#define ACCEL2_STAT 0x18
118#define ACCEL2_VFC_1 0x1B
119#define ACCEL2_VFC_2 0x1C
120#define ACCEL2_VFC_3 0x1D
121#define ACCEL2_VFC_4 0x1E
122#define ACCEL2_THRS3 0x1F
123#define ACCEL2_OUT_X_L 0x28
124#define ACCEL2_OUT_X_H 0x29
125#define ACCEL2_OUT_Y_L 0x2A
126#define ACCEL2_OUT_Y_H 0x2B
127#define ACCEL2_OUT_Z_L 0x2C
128#define ACCEL2_OUT_Z_H 0x2D
129#define ACCEL2_FIFO_CTRL 0x2E
130#define ACCEL2_FIFO_SRC 0x2F
131#define ACCEL2_CTRL_REG1 0x21
132#define ACCEL2_ST1_1 0x40
133#define ACCEL2_ST2_1 0x41
134#define ACCEL2_ST3_1 0x42
135#define ACCEL2_ST4_1 0x43
136#define ACCEL2_ST5_1 0x44
137#define ACCEL2_ST6_1 0x45
138#define ACCEL2_ST7_1 0x46
139#define ACCEL2_ST8_1 0x47
140#define ACCEL2_ST9_1 0x48
141#define ACCEL2_ST10_1 0x49
142#define ACCEL2_ST11_1 0x4A
143#define ACCEL2_ST12_1 0x4B
144#define ACCEL2_ST13_1 0x4C
145#define ACCEL2_ST14_1 0x4D
146#define ACCEL2_ST15_1 0x4E
147#define ACCEL2_ST16_1 0x4F
148#define ACCEL2_TIM4_1 0x50
149#define ACCEL2_TIM3_1 0x51
150#define ACCEL2_TIM2_1_L 0x52
151#define ACCEL2_TIM2_1_H 0x53
152#define ACCEL2_TIM1_1_L 0x54
153#define ACCEL2_TIM1_1_H 0x55
154#define ACCEL2_THRS2_1 0x56
155#define ACCEL2_THRS1_1 0x57
156#define ACCEL2_MASK1_B 0x59
157#define ACCEL2_MASK1_A 0x5A
158#define ACCEL2_SETT1 0x5B
159#define ACCEL2_PR1 0x5C
166#define ACCEL2_I2C_ADDRESS = 0x1D
#define ACCEL2_RETVAL
Definition accel2.h:90
uint8_t accel2_check_id(accel2_t *ctx)
Check Accel 2 ID.
int16_t accel2_read_zaxis(accel2_t *ctx)
Function read Z axis.
int16_t accel2_read_xaxis(accel2_t *ctx)
Function read X axis.
void accel2_cfg_setup(accel2_cfg_t *cfg)
Config Object Initialization function.
void accel2_setting(accel2_t *ctx)
Initializes function.
void accel2_generic_write(accel2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
ACCEL2_RETVAL accel2_init(accel2_t *ctx, accel2_cfg_t *cfg)
Initialization function.
int16_t accel2_read_yaxis(accel2_t *ctx)
Function read Y axis.
void accel2_generic_read(accel2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t accel2_select_t
Communication type.
Definition accel2.h:179
struct accel2_s accel2_t
Click ctx object definition.
void(* accel2_master_io_t)(struct accel2_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition accel2.h:184
Click configuration structure definition.
Definition accel2.h:217
uint8_t spi_mode
Definition accel2.h:236
accel2_select_t sel
Definition accel2.h:239
uint32_t i2c_speed
Definition accel2.h:233
spi_master_chip_select_polarity_t cs_polarity
Definition accel2.h:237
pin_name_t sck
Definition accel2.h:224
pin_name_t mosi
Definition accel2.h:223
uint32_t spi_speed
Definition accel2.h:235
pin_name_t scl
Definition accel2.h:220
pin_name_t int_pin
Definition accel2.h:229
pin_name_t miso
Definition accel2.h:222
pin_name_t sda
Definition accel2.h:221
pin_name_t cs
Definition accel2.h:225
uint8_t i2c_address
Definition accel2.h:234
Click ctx object definition.
Definition accel2.h:190
digital_out_t cs
Definition accel2.h:192
spi_master_t spi
Definition accel2.h:201
accel2_master_io_t read_f
Definition accel2.h:208
digital_in_t int_pin
Definition accel2.h:196
accel2_master_io_t write_f
Definition accel2.h:207
i2c_master_t i2c
Definition accel2.h:200
uint8_t slave_address
Definition accel2.h:205
accel2_select_t master_sel
Definition accel2.h:209
pin_name_t chip_select
Definition accel2.h:206