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"
52#include "drv_spi_master.h"
75#define ACCEL27_REG_DEVID_AD 0x00
76#define ACCEL27_REG_DEVID_MST 0x01
77#define ACCEL27_REG_PARTID 0x02
78#define ACCEL27_REG_REVID 0x03
79#define ACCEL27_REG_STATUS 0x04
80#define ACCEL27_REG_STATUS2 0x05
81#define ACCEL27_REG_FIFO_ENTRIES2 0x06
82#define ACCEL27_REG_FIFO_ENTRIES 0x07
83#define ACCEL27_REG_XDATA_H 0x08
84#define ACCEL27_REG_XDATA_L 0x09
85#define ACCEL27_REG_YDATA_H 0x0A
86#define ACCEL27_REG_YDATA_L 0x0B
87#define ACCEL27_REG_ZDATA_H 0x0C
88#define ACCEL27_REG_ZDATA_L 0x0D
89#define ACCEL27_REG_MAXPEAK_X_H 0x15
90#define ACCEL27_REG_MAXPEAK_X_L 0x16
91#define ACCEL27_REG_MAXPEAK_Y_H 0x17
92#define ACCEL27_REG_MAXPEAK_Y_L 0x18
93#define ACCEL27_REG_MAXPEAK_Z_H 0x19
94#define ACCEL27_REG_MAXPEAK_Z_L 0x1A
95#define ACCEL27_REG_OFFSET_X 0x20
96#define ACCEL27_REG_OFFSET_Y 0x21
97#define ACCEL27_REG_OFFSET_Z 0x22
98#define ACCEL27_REG_THRESH_ACT_X_H 0x23
99#define ACCEL27_REG_THRESH_ACT_X_L 0x24
100#define ACCEL27_REG_THRESH_ACT_Y_H 0x25
101#define ACCEL27_REG_THRESH_ACT_Y_L 0x26
102#define ACCEL27_REG_THRESH_ACT_Z_H 0x27
103#define ACCEL27_REG_THRESH_ACT_Z_L 0x28
104#define ACCEL27_REG_TIME_ACT 0x29
105#define ACCEL27_REG_THRESH_INACT_X_H 0x2A
106#define ACCEL27_REG_THRESH_INACT_X_L 0x2B
107#define ACCEL27_REG_THRESH_INACT_Y_H 0x2C
108#define ACCEL27_REG_THRESH_INACT_Y_L 0x2D
109#define ACCEL27_REG_THRESH_INACT_Z_H 0x2E
110#define ACCEL27_REG_THRESH_INACT_Z_L 0x2F
111#define ACCEL27_REG_TIME_INACT_H 0x30
112#define ACCEL27_REG_TIME_INACT_L 0x31
113#define ACCEL27_REG_THRESH_ACT2_X_H 0x32
114#define ACCEL27_REG_THRESH_ACT2_X_L 0x33
115#define ACCEL27_REG_THRESH_ACT2_Y_H 0x34
116#define ACCEL27_REG_THRESH_ACT2_Y_L 0x35
117#define ACCEL27_REG_THRESH_ACT2_Z_H 0x36
118#define ACCEL27_REG_THRESH_ACT2_Z_L 0x37
119#define ACCEL27_REG_HPF 0x38
120#define ACCEL27_REG_FIFO_SAMPLES 0x39
121#define ACCEL27_REG_FIFO_CTL 0x3A
122#define ACCEL27_REG_INT1_MAP 0x3B
123#define ACCEL27_REG_INT2_MAP 0x3C
124#define ACCEL27_REG_TIMING 0x3D
125#define ACCEL27_REG_MEASURE 0x3E
126#define ACCEL27_REG_POWER_CTL 0x3F
127#define ACCEL27_REG_SELF_TEST 0x40
128#define ACCEL27_REG_RESET 0x41
129#define ACCEL27_REG_FIFO_DATA 0x42
147#define ACCEL27_INT_MAP_INT_LOW 0x80
148#define ACCEL27_INT_MAP_AWAKE 0x40
149#define ACCEL27_INT_MAP_ACT 0x20
150#define ACCEL27_INT_MAP_INACT 0x10
151#define ACCEL27_INT_MAP_DATA_RDY 0x01
157#define ACCEL27_TIMING_ODR_320HZ 0x00
158#define ACCEL27_TIMING_ODR_640HZ 0x20
159#define ACCEL27_TIMING_ODR_1280HZ 0x40
160#define ACCEL27_TIMING_ODR_25600HZ 0x60
161#define ACCEL27_TIMING_ODR_5120HZ 0x80
162#define ACCEL27_TIMING_ODR_MASK 0xE0
163#define ACCEL27_TIMING_WAKEUP_RATE_65_MS 0x00
164#define ACCEL27_TIMING_WAKEUP_RATE_130_MS 0x04
165#define ACCEL27_TIMING_WAKEUP_RATE_260_MS 0x08
166#define ACCEL27_TIMING_WAKEUP_RATE_640_MS 0x0C
167#define ACCEL27_TIMING_WAKEUP_RATE_2560_MS 0x10
168#define ACCEL27_TIMING_WAKEUP_RATE_5120_MS 0x14
169#define ACCEL27_TIMING_WAKEUP_RATE_10240_MS 0x18
170#define ACCEL27_TIMING_WAKEUP_RATE_30720_MS 0x1C
171#define ACCEL27_TIMING_WAKEUP_RATE_MASK 0x1C
172#define ACCEL27_TIMING_EXT_CLK 0x02
173#define ACCEL27_TIMING_EXT_SYNC 0x01
179#define ACCEL27_POWER_CTL_I2C_HSM_EN 0x80
180#define ACCEL27_POWER_CTL_INSTANT_ON_THRESH 0x20
181#define ACCEL27_POWER_CTL_FLT_SETL_462_5_MS 0x00
182#define ACCEL27_POWER_CTL_FLT_SETL_4_OF_ODR 0x10
183#define ACCEL27_POWER_CTL_FLT_SETL_MASK 0x10
184#define ACCEL27_POWER_CTL_LPF_DISABLE 0x08
185#define ACCEL27_POWER_CTL_HPF_DISABLE 0x04
186#define ACCEL27_POWER_CTL_MODE_STANDBY 0x00
187#define ACCEL27_POWER_CTL_MODE_WAKE_UP 0x01
188#define ACCEL27_POWER_CTL_MODE_INSTANT_ON 0x02
189#define ACCEL27_POWER_CTL_MODE_MEASUREMENT 0x03
190#define ACCEL27_POWER_CTL_MODE_MASK 0x03
196#define ACCEL27_RESET 0x52
202#define ACCEL27_DEVID_AD 0xAD
203#define ACCEL27_DEVID_MST 0x1D
204#define ACCEL27_DEVID_PRODUCT 0xFA
210#define ACCEL27_SCALE_FACTOR_LSB_PER_G 5.0f
217#define ACCEL27_DEVICE_ADDRESS_0 0x1D
218#define ACCEL27_DEVICE_ADDRESS_1 0x53
228#define ACCEL27_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
229#define ACCEL27_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
247#define ACCEL27_MAP_MIKROBUS( cfg, mikrobus ) \
248 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
249 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
250 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
251 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
252 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
253 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
254 cfg.int2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
255 cfg.int1 = MIKROBUS( mikrobus, MIKROBUS_INT )
accel27_return_value_t
Accel 27 Click return value data.
Definition accel27.h:341
@ ACCEL27_OK
Definition accel27.h:342
@ ACCEL27_ERROR
Definition accel27.h:343
struct accel27_s accel27_t
Accel 27 Click context object.
err_t(* accel27_master_io_t)(struct accel27_s *, uint8_t, uint8_t *, uint8_t)
Accel 27 Click driver interface.
Definition accel27.h:275
accel27_drv_t
Accel 27 Click driver selector.
Definition accel27.h:265
@ ACCEL27_DRV_SEL_SPI
Definition accel27.h:266
@ ACCEL27_DRV_SEL_I2C
Definition accel27.h:267
err_t accel27_read_register(accel27_t *ctx, uint8_t reg, uint8_t *data_out)
Accel 27 read register function.
err_t accel27_generic_read(accel27_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Accel 27 data reading function.
err_t accel27_reset_device(accel27_t *ctx)
Accel 27 reset device function.
void accel27_cfg_setup(accel27_cfg_t *cfg)
Accel 27 configuration object setup function.
err_t accel27_get_axes(accel27_t *ctx, accel27_axes_t *axes)
Accel 27 get axes function.
err_t accel27_init(accel27_t *ctx, accel27_cfg_t *cfg)
Accel 27 initialization function.
uint8_t accel27_get_int2_pin(accel27_t *ctx)
Accel 27 get int2 pin function.
void accel27_drv_interface_selection(accel27_cfg_t *cfg, accel27_drv_t drv_sel)
Accel 27 driver interface setup function.
err_t accel27_default_cfg(accel27_t *ctx)
Accel 27 default configuration function.
err_t accel27_check_communication(accel27_t *ctx)
Accel 27 check communication function.
err_t accel27_write_register(accel27_t *ctx, uint8_t reg, uint8_t data_in)
Accel 27 write register function.
err_t accel27_generic_write(accel27_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Accel 27 data writing function.
uint8_t accel27_get_int1_pin(accel27_t *ctx)
Accel 27 get int1 pin function.
This file contains SPI specific macros, functions, etc.
Accel 27 Click Axes data structure.
Definition accel27.h:329
float y
Definition accel27.h:331
float x
Definition accel27.h:330
float z
Definition accel27.h:332
Accel 27 Click configuration object.
Definition accel27.h:303
pin_name_t int1
Definition accel27.h:311
accel27_drv_t drv_sel
Definition accel27.h:320
pin_name_t int2
Definition accel27.h:310
uint32_t i2c_speed
Definition accel27.h:313
spi_master_chip_select_polarity_t cs_polarity
Definition accel27.h:318
pin_name_t sck
Definition accel27.h:308
spi_master_mode_t spi_mode
Definition accel27.h:317
pin_name_t mosi
Definition accel27.h:307
uint32_t spi_speed
Definition accel27.h:316
pin_name_t scl
Definition accel27.h:304
pin_name_t miso
Definition accel27.h:306
pin_name_t sda
Definition accel27.h:305
pin_name_t cs
Definition accel27.h:309
uint8_t i2c_address
Definition accel27.h:314
Accel 27 Click context object.
Definition accel27.h:282
accel27_drv_t drv_sel
Definition accel27.h:291
digital_in_t int2
Definition accel27.h:283
spi_master_t spi
Definition accel27.h:287
digital_in_t int1
Definition accel27.h:284
i2c_master_t i2c
Definition accel27.h:286
accel27_master_io_t write_f
Definition accel27.h:293
uint8_t slave_address
Definition accel27.h:289
accel27_master_io_t read_f
Definition accel27.h:294
pin_name_t chip_select
Definition accel27.h:290