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 ACCEL22_REG_DEVID_AD 0x00
76#define ACCEL22_REG_DEVID_MST 0x01
77#define ACCEL22_REG_PART_ID 0x02
78#define ACCEL22_REG_REV_ID 0x03
79#define ACCEL22_REG_SERIAL_NUMBER_3 0x04
80#define ACCEL22_REG_SERIAL_NUMBER_2 0x05
81#define ACCEL22_REG_SERIAL_NUMBER_1 0x06
82#define ACCEL22_REG_SERIAL_NUMBER_0 0x07
83#define ACCEL22_REG_XDATA 0x08
84#define ACCEL22_REG_YDATA 0x09
85#define ACCEL22_REG_ZDATA 0x0A
86#define ACCEL22_REG_STATUS 0x0B
87#define ACCEL22_REG_FIFO_ENTRIES_L 0x0C
88#define ACCEL22_REG_FIFO_ENTRIES_H 0x0D
89#define ACCEL22_REG_XDATA_H 0x0E
90#define ACCEL22_REG_XDATA_L 0x0F
91#define ACCEL22_REG_YDATA_H 0x10
92#define ACCEL22_REG_YDATA_L 0x11
93#define ACCEL22_REG_ZDATA_H 0x12
94#define ACCEL22_REG_ZDATA_L 0x13
95#define ACCEL22_REG_TEMP_H 0x14
96#define ACCEL22_REG_TEMP_L 0x15
97#define ACCEL22_REG_EX_ADC_H 0x16
98#define ACCEL22_REG_EX_ADC_L 0x17
99#define ACCEL22_REG_I2C_FIFO_DATA 0x18
100#define ACCEL22_REG_SOFT_RESET 0x19
101#define ACCEL22_REG_THRESH_ACT_H 0x20
102#define ACCEL22_REG_THRESH_ACT_L 0x21
103#define ACCEL22_REG_TIME_ACT 0x22
104#define ACCEL22_REG_THRESH_INACT_H 0x23
105#define ACCEL22_REG_THRESH_INACT_L 0x24
106#define ACCEL22_REG_TIME_INACT_H 0x25
107#define ACCEL22_REG_TIME_INACT_L 0x26
108#define ACCEL22_REG_ACT_INACT_CTL 0x27
109#define ACCEL22_REG_FIFO_CONTROL 0x28
110#define ACCEL22_REG_FIFO_SAMPLES 0x29
111#define ACCEL22_REG_INTMAP1_LOWER 0x2A
112#define ACCEL22_REG_INTMAP2_LOWER 0x2B
113#define ACCEL22_REG_FILTER_CTL 0x2C
114#define ACCEL22_REG_POWER_CTL 0x2D
115#define ACCEL22_REG_SELF_TEST 0x2E
116#define ACCEL22_REG_TAP_THRESH 0x2F
117#define ACCEL22_REG_TAP_DUR 0x30
118#define ACCEL22_REG_TAP_LATENT 0x31
119#define ACCEL22_REG_TAP_WINDOW 0x32
120#define ACCEL22_REG_X_OFFSET 0x33
121#define ACCEL22_REG_Y_OFFSET 0x34
122#define ACCEL22_REG_Z_OFFSET 0x35
123#define ACCEL22_REG_X_SENS 0x36
124#define ACCEL22_REG_Y_SENS 0x37
125#define ACCEL22_REG_Z_SENS 0x38
126#define ACCEL22_REG_TIMER_CTL 0x39
127#define ACCEL22_REG_INTMAP1_UPPER 0x3A
128#define ACCEL22_REG_INTMAP2_UPPER 0x3B
129#define ACCEL22_REG_ADC_CTL 0x3C
130#define ACCEL22_REG_TEMP_CTL 0x3D
131#define ACCEL22_REG_TEMP_ADC_OVER_THRSH_H 0x3E
132#define ACCEL22_REG_TEMP_ADC_OVER_THRSH_L 0x3F
133#define ACCEL22_REG_TEMP_ADC_UNDER_THRSH_H 0x40
134#define ACCEL22_REG_TEMP_ADC_UNDER_THRSH_L 0x41
135#define ACCEL22_REG_TEMP_ADC_TIMER 0x42
136#define ACCEL22_REG_AXIS_MASK 0x43
137#define ACCEL22_REG_STATUS_COPY 0x44
138#define ACCEL22_REG_STATUS_2 0x45
156#define ACCEL22_INTMAP1_LOWER_INT_LOW 0x80
157#define ACCEL22_INTMAP1_LOWER_AWAKE 0x40
158#define ACCEL22_INTMAP1_LOWER_INACT 0x20
159#define ACCEL22_INTMAP1_LOWER_ACT 0x10
160#define ACCEL22_INTMAP1_LOWER_FIFO_OR 0x08
161#define ACCEL22_INTMAP1_LOWER_FIFO_WM 0x04
162#define ACCEL22_INTMAP1_LOWER_FIFO_RDY 0x02
163#define ACCEL22_INTMAP1_LOWER_DATA_RDY 0x01
169#define ACCEL22_POWER_CTL_EXT_CLK 0x40
170#define ACCEL22_POWER_CTL_NOISE_NORMAL 0x00
171#define ACCEL22_POWER_CTL_NOISE_LOW 0x10
172#define ACCEL22_POWER_CTL_NOISE_ULTRALOW 0x20
173#define ACCEL22_POWER_CTL_NOISE_BIT_MASK 0x30
174#define ACCEL22_POWER_CTL_WAKEUP 0x08
175#define ACCEL22_POWER_CTL_AUTOSLEEP 0x04
176#define ACCEL22_POWER_CTL_STANDBY_MODE 0x00
177#define ACCEL22_POWER_CTL_MEASUREMENT_MODE 0x02
183#define ACCEL22_SOFT_RESET 0x52
189#define ACCEL22_ENABLE_TEMPERATURE 0x01
190#define ACCEL22_ENABLE_ADC 0x01
196#define ACCEL22_ACCEL_2G_RES 0.25
197#define ACCEL22_ACCEL_4G_RES 0.5
198#define ACCEL22_ACCEL_8G_RES 1.0
199#define ACCEL22_ROOM_TEMPERATURE 25.0
200#define ACCEL22_TEMPERATURE_BIAS 165
201#define ACCEL22_TEMPERATURE_RES 54.0
202#define ACCEL22_TEMPERATURE_CAL_SAMPLE_NUM 100
203#define ACCEL22_ADC_VREG 1.098
204#define ACCEL22_ADC_RES 0x3FFF
205#define ACCEL22_ADC_OFFSET 0x2000
211#define ACCEL22_ADI_DEVICE_ID 0xAD
212#define ACCEL22_MEMS_DEVICE_ID 0x1D
213#define ACCEL22_PART_ID 0xF7
219#define ACCEL22_SPI_WRITE_REG 0x0A
220#define ACCEL22_SPI_READ_REG 0x0B
221#define ACCEL22_SPI_READ_FIFO 0x0D
228#define ACCEL22_DEVICE_ADDRESS_0 0x1D
229#define ACCEL22_DEVICE_ADDRESS_1 0x53
239#define ACCEL22_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
240#define ACCEL22_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
258#define ACCEL22_MAP_MIKROBUS( cfg, mikrobus ) \
259 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
260 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
261 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
262 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
263 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
264 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
265 cfg.int2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
266 cfg.int1 = MIKROBUS( mikrobus, MIKROBUS_INT )
accel22_odr_t
Accel 22 Click output data rate.
Definition accel22.h:367
@ ACCEL22_200HZ
Definition accel22.h:372
@ ACCEL22_12p5HZ
Definition accel22.h:368
@ ACCEL22_ODR_BIT_MASK
Definition accel22.h:374
@ ACCEL22_400HZ
Definition accel22.h:373
@ ACCEL22_50HZ
Definition accel22.h:370
@ ACCEL22_100HZ
Definition accel22.h:371
@ ACCEL22_25HZ
Definition accel22.h:369
accel22_range_t
Accel 22 Click accel range selection.
Definition accel22.h:354
@ ACCEL22_8G
Definition accel22.h:357
@ ACCEL22_2G
Definition accel22.h:355
@ ACCEL22_RANGE_BIT_MASK
Definition accel22.h:358
@ ACCEL22_4G
Definition accel22.h:356
accel22_drv_t
Accel 22 Click driver selector.
Definition accel22.h:276
@ ACCEL22_DRV_SEL_SPI
Definition accel22.h:277
@ ACCEL22_DRV_SEL_I2C
Definition accel22.h:278
accel22_return_value_t
Accel 22 Click return value data.
Definition accel22.h:383
@ ACCEL22_ERROR
Definition accel22.h:385
@ ACCEL22_OK
Definition accel22.h:384
err_t(* accel22_master_io_t)(struct accel22_s *, uint8_t, uint8_t *, uint8_t)
Accel 22 Click driver interface.
Definition accel22.h:286
struct accel22_s accel22_t
Accel 22 Click context object.
uint8_t accel22_get_int2_pin(accel22_t *ctx)
Accel 22 get int2 pin function.
err_t accel22_get_axes(accel22_t *ctx, accel22_axes_t *axes)
Accel 22 get axes function.
err_t accel22_read_register(accel22_t *ctx, uint8_t reg, uint8_t *data_out)
Accel 22 read register function.
err_t accel22_default_cfg(accel22_t *ctx)
Accel 22 default configuration function.
err_t accel22_init(accel22_t *ctx, accel22_cfg_t *cfg)
Accel 22 initialization function.
err_t accel22_calibrate_temperature(accel22_t *ctx, float room_temperature)
Accel 22 calibrate temperature function.
err_t accel22_get_adc(accel22_t *ctx, float *v_adc)
Accel 22 get adc function.
err_t accel22_enable_temperature_measurement(accel22_t *ctx)
Accel 22 enable temperature measurement function.
err_t accel22_set_filter_config(accel22_t *ctx, accel22_range_t range, accel22_odr_t odr)
Accel 22 set filter config function.
void accel22_drv_interface_selection(accel22_cfg_t *cfg, accel22_drv_t drv_sel)
Accel 22 driver interface setup function.
err_t accel22_generic_read(accel22_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Accel 22 data reading function.
err_t accel22_generic_write(accel22_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Accel 22 data writing function.
err_t accel22_write_register(accel22_t *ctx, uint8_t reg, uint8_t data_in)
Accel 22 write register function.
err_t accel22_enable_adc_measurement(accel22_t *ctx)
Accel 22 enable ADC measurement function.
err_t accel22_check_communication(accel22_t *ctx)
Accel 22 check communication function.
void accel22_cfg_setup(accel22_cfg_t *cfg)
Accel 22 configuration object setup function.
uint8_t accel22_get_int1_pin(accel22_t *ctx)
Accel 22 get int1 pin function.
err_t accel22_get_temperature(accel22_t *ctx, float *temperature)
Accel 22 get temperature function.
This file contains SPI specific macros, functions, etc.
Accel 22 Click Axes data structure.
Definition accel22.h:342
float y
Definition accel22.h:344
float x
Definition accel22.h:343
float z
Definition accel22.h:345
Accel 22 Click configuration object.
Definition accel22.h:316
pin_name_t int1
Definition accel22.h:324
pin_name_t int2
Definition accel22.h:323
uint32_t i2c_speed
Definition accel22.h:326
spi_master_chip_select_polarity_t cs_polarity
Definition accel22.h:331
pin_name_t sck
Definition accel22.h:321
spi_master_mode_t spi_mode
Definition accel22.h:330
pin_name_t mosi
Definition accel22.h:320
uint32_t spi_speed
Definition accel22.h:329
pin_name_t scl
Definition accel22.h:317
pin_name_t miso
Definition accel22.h:319
pin_name_t sda
Definition accel22.h:318
pin_name_t cs
Definition accel22.h:322
accel22_drv_t drv_sel
Definition accel22.h:333
uint8_t i2c_address
Definition accel22.h:327
Accel 22 Click context object.
Definition accel22.h:293
digital_in_t int2
Definition accel22.h:294
spi_master_t spi
Definition accel22.h:298
accel22_master_io_t read_f
Definition accel22.h:305
float resolution
Definition accel22.h:306
accel22_master_io_t write_f
Definition accel22.h:304
digital_in_t int1
Definition accel22.h:295
i2c_master_t i2c
Definition accel22.h:297
float room_temp_offset
Definition accel22.h:307
uint8_t slave_address
Definition accel22.h:300
pin_name_t chip_select
Definition accel22.h:301
accel22_drv_t drv_sel
Definition accel22.h:302