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 ACCEL19_REG_OUT_T_L 0x0D
76#define ACCEL19_REG_OUT_T_H 0x0E
77#define ACCEL19_REG_WHO_AM_I 0x0F
78#define ACCEL19_REG_CTRL1 0x20
79#define ACCEL19_REG_CTRL2 0x21
80#define ACCEL19_REG_CTRL3 0x22
81#define ACCEL19_REG_CTRL4_INT1_PAD_CTRL 0x23
82#define ACCEL19_REG_CTRL5_INT2_PAD_CTRL 0x24
83#define ACCEL19_REG_CTRL6 0x25
84#define ACCEL19_REG_STATUS 0x27
85#define ACCEL19_REG_OUT_X_L 0x28
86#define ACCEL19_REG_OUT_X_H 0x29
87#define ACCEL19_REG_OUT_Y_L 0x2A
88#define ACCEL19_REG_OUT_Y_H 0x2B
89#define ACCEL19_REG_OUT_Z_L 0x2C
90#define ACCEL19_REG_OUT_Z_H 0x2D
91#define ACCEL19_REG_FIFO_CTRL 0x2E
92#define ACCEL19_REG_FIFO_SAMPLES 0x2F
93#define ACCEL19_REG_TAP_THS_X 0x30
94#define ACCEL19_REG_TAP_THS_Y 0x31
95#define ACCEL19_REG_TAP_THS_Z 0x32
96#define ACCEL19_REG_INT_DUR 0x33
97#define ACCEL19_REG_WAKE_UP_THS 0x34
98#define ACCEL19_REG_WAKE_UP_DUR 0x35
99#define ACCEL19_REG_FREE_FALL 0x36
100#define ACCEL19_REG_STATUS_DUP 0x37
101#define ACCEL19_REG_WAKE_UP_SRC 0x38
102#define ACCEL19_REG_TAP_SRC 0x39
103#define ACCEL19_REG_SIXD_SRC 0x3A
104#define ACCEL19_REG_ALL_INT_SRC 0x3B
105#define ACCEL19_REG_X_OFS_USR 0x3C
106#define ACCEL19_REG_Y_OFS_USR 0x3D
107#define ACCEL19_REG_Z_OFS_USR 0x3E
108#define ACCEL19_REG_CTRL7 0x3F
126#define ACCEL19_DEVICE_ID 0x44
132#define ACCEL19_CTRL1_ODR_BIT_MASK 0xF0
133#define ACCEL19_CTRL1_ODR_POWER_DOWN 0x00
134#define ACCEL19_CTRL1_ODR_LP_1_6_Hz 0x10
135#define ACCEL19_CTRL1_ODR_HP_12_5_Hz 0x10
136#define ACCEL19_CTRL1_ODR_HP_LP_12_5_Hz 0x20
137#define ACCEL19_CTRL1_ODR_HP_LP_25_Hz 0x30
138#define ACCEL19_CTRL1_ODR_HP_LP_50_Hz 0x40
139#define ACCEL19_CTRL1_ODR_HP_LP_100_Hz 0x50
140#define ACCEL19_CTRL1_ODR_HP_LP_200_Hz 0x60
141#define ACCEL19_CTRL1_ODR_LP_200_Hz 0x70
142#define ACCEL19_CTRL1_ODR_HP_400_Hz 0x70
143#define ACCEL19_CTRL1_ODR_HP_800_Hz 0x80
144#define ACCEL19_CTRL1_ODR_HP_1600_Hz 0x90
150#define ACCEL19_CTRL1_OP_MODE_BIT_MASK 0x0C
151#define ACCEL19_CTRL1_OP_MODE_LOW_POWER_MODE 0x00
152#define ACCEL19_CTRL1_OP_MODE_HIGH_POWER_MODE 0x04
153#define ACCEL19_CTRL1_OP_MODE_SINGLE_DATA_CONV 0x08
159#define ACCEL19_CTRL1_LP_MODE_BIT_MASK 0x03
160#define ACCEL19_CTRL1_LP_MODE1_RES_12_bit 0x00
161#define ACCEL19_CTRL1_LP_MODE2_RES_14_bit 0x01
162#define ACCEL19_CTRL1_LP_MODE3_RES_14_bit 0x02
163#define ACCEL19_CTRL1_LP_MODE4_RES_14_bit 0x03
169#define ACCEL19_CTRL2_SOFT_RESET 0x40
175#define ACCEL19_INT_DRDY 0x00
176#define ACCEL19_STATUS_DRDY 0x01
182#define ACCEL19_CTRL6_BW_FILT_BIT_MASK 0xC0
183#define ACCEL19_CTRL6_BW_FILT_ODR_2 0x00
184#define ACCEL19_CTRL6_BW_FILT_ODR_4 0x40
185#define ACCEL19_CTRL6_BW_FILT_ODR_10 0x80
186#define ACCEL19_CTRL6_BW_FILT_ODR_20 0xC0
192#define ACCEL19_CTRL6_FS_BIT_MASK 0x30
193#define ACCEL19_CTRL6_FS_2g 0x00
194#define ACCEL19_CTRL6_FS_4g 0x10
195#define ACCEL19_CTRL6_FS_8g 0x20
196#define ACCEL19_CTRL6_FS_16g 0x30
203#define ACCEL19_SET_DEV_ADDR_0 0x18
204#define ACCEL19_SET_DEV_ADDR_1 0x19
214#define ACCEL19_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
215#define ACCEL19_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
233#define ACCEL19_MAP_MIKROBUS( cfg, mikrobus ) \
234 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
235 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
236 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
237 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
238 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
239 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
240 cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
241 cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t(* accel19_master_io_t)(struct accel19_s *, uint8_t, uint8_t *, uint8_t)
Accel 19 Click driver interface.
Definition accel19.h:261
accel19_drv_t
Accel 19 Click driver selector.
Definition accel19.h:251
@ ACCEL19_DRV_SEL_I2C
Definition accel19.h:253
@ ACCEL19_DRV_SEL_SPI
Definition accel19.h:252
struct accel19_s accel19_t
Accel 19 Click context object.
accel19_return_value_t
Accel 19 Click return value data.
Definition accel19.h:328
@ ACCEL19_ERROR
Definition accel19.h:330
@ ACCEL19_OK
Definition accel19.h:329
err_t accel19_set_bw_filt_odr(accel19_t *ctx, uint8_t bw_filt_odr)
Accel 19 set digital filtering cutoff function.
uint8_t accel19_get_int_1(accel19_t *ctx)
Accel 19 get Interrupt 1 function.
err_t accel19_soft_reset(accel19_t *ctx)
Accel 19 soft reset function.
err_t accel19_init(accel19_t *ctx, accel19_cfg_t *cfg)
Accel 19 initialization function.
err_t accel19_set_control(accel19_t *ctx, uint8_t odr, uint8_t op_mode, uint8_t lp_mode)
Accel 19 set control function.
err_t accel19_check_device_id(accel19_t *ctx)
Accel 19 check device ID function.
err_t accel19_get_temperature(accel19_t *ctx, float *temperature)
Accel 19 get temperature function.
err_t accel19_default_cfg(accel19_t *ctx)
Accel 19 default configuration function.
err_t accel19_get_axis_data(accel19_t *ctx, accel19_axis_t *axis)
Accel 19 get accelerometer axis function.
void accel19_drv_interface_selection(accel19_cfg_t *cfg, accel19_drv_t drv_sel)
Accel 19 driver interface setup function.
err_t accel19_get_status(accel19_t *ctx, uint8_t *status)
Accel 19 get status function.
err_t accel19_generic_read(accel19_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Accel 19 data reading function.
uint8_t accel19_get_int_2(accel19_t *ctx)
Accel 19 get Interrupt 2 function.
void accel19_cfg_setup(accel19_cfg_t *cfg)
Accel 19 configuration object setup function.
err_t accel19_generic_write(accel19_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Accel 19 data writing function.
err_t accel19_set_full_scale(accel19_t *ctx, uint8_t full_scale)
Accel 19 set full scale function.
uint8_t accel19_data_ready(accel19_t *ctx)
Accel 19 data ready function.
This file contains SPI specific macros, functions, etc.
Accel 19 axis data structure.
Definition accel19.h:316
int16_t z
Definition accel19.h:319
int16_t x
Definition accel19.h:317
int16_t y
Definition accel19.h:318
Accel 19 Click configuration object.
Definition accel19.h:289
accel19_drv_t drv_sel
Definition accel19.h:307
uint32_t i2c_speed
Definition accel19.h:300
spi_master_chip_select_polarity_t cs_polarity
Definition accel19.h:305
pin_name_t in2
Definition accel19.h:297
pin_name_t sck
Definition accel19.h:294
spi_master_mode_t spi_mode
Definition accel19.h:304
pin_name_t mosi
Definition accel19.h:293
uint32_t spi_speed
Definition accel19.h:303
pin_name_t scl
Definition accel19.h:290
pin_name_t in1
Definition accel19.h:298
pin_name_t miso
Definition accel19.h:292
pin_name_t sda
Definition accel19.h:291
pin_name_t cs
Definition accel19.h:295
uint8_t i2c_address
Definition accel19.h:301
Accel 19 Click context object.
Definition accel19.h:268
digital_in_t in2
Definition accel19.h:269
accel19_master_io_t read_f
Definition accel19.h:280
accel19_master_io_t write_f
Definition accel19.h:279
spi_master_t spi
Definition accel19.h:273
accel19_drv_t drv_sel
Definition accel19.h:277
digital_in_t in1
Definition accel19.h:270
i2c_master_t i2c
Definition accel19.h:272
uint8_t slave_address
Definition accel19.h:275
pin_name_t chip_select
Definition accel19.h:276