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 ACCEL28_REG_TEMP_L 0x0B
76#define ACCEL28_REG_TEMP_H 0x0C
77#define ACCEL28_REG_WHO_AM_I 0x0F
78#define ACCEL28_REG_ACT_THS 0x1E
79#define ACCEL28_REG_ACT_DUS 0x1F
80#define ACCEL28_REG_CTRL1 0x20
81#define ACCEL28_REG_CTRL2 0x21
82#define ACCEL28_REG_CTRL3 0x22
83#define ACCEL28_REG_CTRL4 0x23
84#define ACCEL28_REG_CTRL5 0x24
85#define ACCEL28_REG_CTRL6 0x25
86#define ACCEL28_REG_CTRL7 0x26
87#define ACCEL28_REG_STATUS 0x27
88#define ACCEL28_REG_OUT_X_L 0x28
89#define ACCEL28_REG_OUT_X_H 0x29
90#define ACCEL28_REG_OUT_Y_L 0x2A
91#define ACCEL28_REG_OUT_Y_H 0x2B
92#define ACCEL28_REG_OUT_Z_L 0x2C
93#define ACCEL28_REG_OUT_Z_H 0x2D
94#define ACCEL28_REG_FIFO_CTRL 0x2E
95#define ACCEL28_REG_FIFO_SRC 0x2F
96#define ACCEL28_REG_IG_CFG1 0x30
97#define ACCEL28_REG_IG_SRC1 0x31
98#define ACCEL28_REG_IG_THS_X1 0x32
99#define ACCEL28_REG_IG_THS_Y1 0x33
100#define ACCEL28_REG_IG_THS_Z1 0x34
101#define ACCEL28_REG_IG_DUR1 0x35
102#define ACCEL28_REG_IG_CFG2 0x36
103#define ACCEL28_REG_IG_SRC2 0x37
104#define ACCEL28_REG_IG_THS2 0x38
105#define ACCEL28_REG_IG_DUR2 0x39
106#define ACCEL28_REG_XL_REFERENCE 0x3A
107#define ACCEL28_REG_XH_REFERENCE 0x3B
108#define ACCEL28_REG_YL_REFERENCE 0x3C
109#define ACCEL28_REG_YH_REFERENCE 0x3D
110#define ACCEL28_REG_ZL_REFERENCE 0x3E
111#define ACCEL28_REG_ZH_REFERENCE 0x3F
129#define ACCEL28_WHO_AM_I_VALUE 0x41
136#define ACCEL28_CTRL1_X_AXIS_ENABLE 0x01
137#define ACCEL28_CTRL1_Y_AXIS_ENABLE 0x02
138#define ACCEL28_CTRL1_Z_AXIS_ENABLE 0x04
139#define ACCEL28_CTRL1_BLOCK_DATA_UPATE_EN 0x08
140#define ACCEL28_CTRL1_ODR_POWER_DOWN 0x00
141#define ACCEL28_CTRL1_ODR_10HZ 0x10
142#define ACCEL28_CTRL1_ODR_50HZ 0x20
143#define ACCEL28_CTRL1_ODR_100HZ 0x30
144#define ACCEL28_CTRL1_ODR_200HZ 0x40
145#define ACCEL28_CTRL1_ODR_400HZ 0x50
146#define ACCEL28_CTRL1_ODR_800HZ 0x60
147#define ACCEL28_CTRL1_ODR_NA 0x70
148#define ACCEL28_CTRL1_HR_MODE 0x80
154#define ACCEL28_CTRL2_HP_ENABLE_INT2 0x01
155#define ACCEL28_CTRL2_HP_ENABLE_INT1 0x02
156#define ACCEL28_CTRL2_FDS_ENABLE 0x04
157#define ACCEL28_CTRL2_HPM_NORMAL_MODE 0x00
158#define ACCEL28_CTRL2_HPM_REF_SIGNAL_FILTERING 0x08
159#define ACCEL28_CTRL2_HPM_FREQ_DEV_50 0x00
160#define ACCEL28_CTRL2_HPM_FREQ_DEV_100 0x20
161#define ACCEL28_CTRL2_HPM_FREQ_DEV_9 0x40
162#define ACCEL28_CTRL2_HPM_FREQ_DEV_400 0x60
169#define ACCEL28_CTRL3_INT1_DRDY_EN 0x01
170#define ACCEL28_CTRL3_INT1_FTH 0x02
171#define ACCEL28_CTRL3_INT1_OVR 0x04
172#define ACCEL28_CTRL3_INT1_IG1 0x08
173#define ACCEL28_CTRL3_INT1_IG2 0x10
174#define ACCEL28_CTRL3_INT1_INACT_EN 0x20
175#define ACCEL28_CTRL3_STOP_FTH 0x40
176#define ACCEL28_CTRL3_FIFO_EN 0x80
183#define ACCEL28_CTRL4_SPI_MODE_3_WIRE 0x01
184#define ACCEL28_CTRL4_SPI_MODE_4_WIRE 0x00
185#define ACCEL28_CTRL4_I2C_DISABLED 0x02
186#define ACCEL28_CTRL4_I2C_ENABLED 0x00
187#define ACCEL28_CTRL4_ADD_INC_ENABLED 0x04
188#define ACCEL28_CTRL4_BW_SCALE_ODR 0x00
189#define ACCEL28_CTRL4_BW_SCALE_BW 0x08
190#define ACCEL28_CTRL4_FS_2G 0x00
191#define ACCEL28_CTRL4_FS_4G 0x20
192#define ACCEL28_CTRL4_FS_8G 0x30
193#define ACCEL28_CTRL4_FS_MASK 0x30
194#define ACCEL28_CTRL4_BW_400HZ 0x00
195#define ACCEL28_CTRL4_BW_200HZ 0x40
196#define ACCEL28_CTRL4_BW_100HZ 0x80
197#define ACCEL28_CTRL4_BW_50HZ 0xC0
204#define ACCEL28_CTRL5_INT_PUSH_PULL 0x00
205#define ACCEL28_CTRL5_INT_OPEN_DRAIN 0x01
206#define ACCEL28_CTRL5_INT_ACTIVE_HIGH 0x00
207#define ACCEL28_CTRL5_INT_ACTIVE_LOW 0x02
208#define ACCEL28_CTRL5_NORMAL_MODE 0x00
209#define ACCEL28_CTRL5_POSITIVE_SELF_TEST 0x04
210#define ACCEL28_CTRL5_NEGATIVE_SELF_TEST 0x08
211#define ACCEL28_CTRL5_DEC_UDATE_OFF 0x00
212#define ACCEL28_CTRL5_DEC_UDATE_2_SAMPLES 0x10
213#define ACCEL28_CTRL5_DEC_UDATE_4_SAMPLES 0x20
214#define ACCEL28_CTRL5_DEC_UDATE_8_SAMPLES 0x30
215#define ACCEL28_CTRL5_SW_RESET 0x40
216#define ACCEL28_CTRL5_DEBUG_MODE 0x80
223#define ACCEL28_CTRL6_INT2_DRDY 0x01
224#define ACCEL28_CTRL6_INT2_FTH 0x02
225#define ACCEL28_CTRL6_INT2_EMPTY 0x04
226#define ACCEL28_CTRL6_INT2_IG1 0x08
227#define ACCEL28_CTRL6_INT2_IG2 0x10
228#define ACCEL28_CTRL6_INT2_BOOT 0x20
229#define ACCEL28_CTRL6_BOOT 0x80
236#define ACCEL28_STATUS_X_DATA_AVL 0x01
237#define ACCEL28_STATUS_Y_DATA_AVL 0x02
238#define ACCEL28_STATUS_Z_DATA_AVL 0x04
239#define ACCEL28_STATUS_ZYX_DATA_AVL 0x08
240#define ACCEL28_STATUS_X_DATA_OVERRUN 0x10
241#define ACCEL28_STATUS_Y_DATA_OVERRUN 0x20
242#define ACCEL28_STATUS_Z_DATA_OVERRUN 0x40
243#define ACCEL28_STATUS_ZYX_DATA_OVERRUN 0x80
250#define ACCEL28_2G_DATA_CONV 0.061f
251#define ACCEL28_4G_DATA_CONV 0.122f
252#define ACCEL28_8G_DATA_CONV 0.244f
259#define ACCEL28_PIN_STATE_HIGH 0x01
260#define ACCEL28_PIN_STATE_LOW 0x00
267#define ACCEL28_DEVICE_ADDRESS_0 0x1E
268#define ACCEL28_DEVICE_ADDRESS_1 0x1D
278#define ACCEL28_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
279#define ACCEL28_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
297#define ACCEL28_MAP_MIKROBUS( cfg, mikrobus ) \
298 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
299 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
300 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
301 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
302 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
303 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
304 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
accel28_drv_t
Accel 28 Click driver selector.
Definition accel28.h:314
@ ACCEL28_DRV_SEL_SPI
Definition accel28.h:315
@ ACCEL28_DRV_SEL_I2C
Definition accel28.h:316
struct accel28_s accel28_t
Accel 28 Click context object.
err_t(* accel28_master_io_t)(struct accel28_s *, uint8_t, uint8_t *, uint8_t)
Accel 28 Click driver interface.
Definition accel28.h:324
accel28_return_value_t
Accel 28 Click return value data.
Definition accel28.h:388
@ ACCEL28_OK
Definition accel28.h:389
@ ACCEL28_ERROR
Definition accel28.h:390
void accel28_cfg_setup(accel28_cfg_t *cfg)
Accel 28 configuration object setup function.
uint8_t accel28_get_int_state(accel28_t *ctx)
Accel 28 interrupt reading function.
err_t accel28_generic_read(accel28_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Accel 28 data reading function.
void accel28_drv_interface_selection(accel28_cfg_t *cfg, accel28_drv_t drv_sel)
Accel 28 driver interface setup function.
err_t accel28_read_reg(accel28_t *ctx, uint8_t reg, uint8_t *data_out)
Accel 28 register data reading function.
err_t accel28_write_reg(accel28_t *ctx, uint8_t reg, uint8_t data_in)
Accel 28 register data writing function.
err_t accel28_get_data(accel28_t *ctx, accel28_data_t *data_out)
Accel 28 data reading function.
err_t accel28_sw_reset(accel28_t *ctx)
Accel 28 SW reset function.
err_t accel28_get_raw_data(accel28_t *ctx, accel28_data_t *data_out)
Accel 28 raw data reading function.
err_t accel28_init(accel28_t *ctx, accel28_cfg_t *cfg)
Accel 28 initialization function.
err_t accel28_default_cfg(accel28_t *ctx)
Accel 28 default configuration function.
err_t accel28_generic_write(accel28_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Accel 28 data writing function.
This file contains SPI specific macros, functions, etc.
Accel 28 Click configuration object.
Definition accel28.h:351
accel28_drv_t drv_sel
Definition accel28.h:367
uint32_t i2c_speed
Definition accel28.h:360
spi_master_chip_select_polarity_t cs_polarity
Definition accel28.h:365
pin_name_t sck
Definition accel28.h:356
spi_master_mode_t spi_mode
Definition accel28.h:364
pin_name_t mosi
Definition accel28.h:355
uint32_t spi_speed
Definition accel28.h:363
pin_name_t scl
Definition accel28.h:352
pin_name_t int_pin
Definition accel28.h:358
pin_name_t miso
Definition accel28.h:354
pin_name_t sda
Definition accel28.h:353
pin_name_t cs
Definition accel28.h:357
uint8_t i2c_address
Definition accel28.h:361
Accel 28 Click data object.
Definition accel28.h:376
float y_data
Definition accel28.h:378
float z_data
Definition accel28.h:379
float x_data
Definition accel28.h:377
Accel 28 Click context object.
Definition accel28.h:331
spi_master_t spi
Definition accel28.h:335
accel28_drv_t drv_sel
Definition accel28.h:339
accel28_master_io_t write_f
Definition accel28.h:341
digital_in_t int_pin
Definition accel28.h:332
i2c_master_t i2c
Definition accel28.h:334
uint8_t slave_address
Definition accel28.h:337
accel28_master_io_t read_f
Definition accel28.h:342
pin_name_t chip_select
Definition accel28.h:338