41#define ADXL345_SPI_COMM 0
42#define ADXL345_I2C_COMM 1
45#define ADXL345_ADDRESS 0x1D
48#define ADXL345_SPI_READ (1 << 7)
49#define ADXL345_SPI_WRITE (0 << 7)
50#define ADXL345_SPI_MB (1 << 6)
53#define ADXL345_DEVID 0x00
54#define ADXL345_THRESH_TAP 0x1D
55#define ADXL345_OFSX 0x1E
56#define ADXL345_OFSY 0x1F
57#define ADXL345_OFSZ 0x20
58#define ADXL345_DUR 0x21
59#define ADXL345_LATENT 0x22
60#define ADXL345_WINDOW 0x23
61#define ADXL345_THRESH_ACT 0x24
62#define ADXL345_THRESH_INACT 0x25
63#define ADXL345_TIME_INACT 0x26
64#define ADXL345_ACT_INACT_CTL 0x27
66#define ADXL345_THRESH_FF 0x28
67#define ADXL345_TIME_FF 0x29
68#define ADXL345_TAP_AXES 0x2A
69#define ADXL345_ACT_TAP_STATUS 0x2B
70#define ADXL345_BW_RATE 0x2C
71#define ADXL345_POWER_CTL 0x2D
72#define ADXL345_INT_ENABLE 0x2E
73#define ADXL345_INT_MAP 0x2F
74#define ADXL345_INT_SOURCE 0x30
75#define ADXL345_DATA_FORMAT 0x31
76#define ADXL345_DATAX0 0x32
77#define ADXL345_DATAX1 0x33
78#define ADXL345_DATAY0 0x34
79#define ADXL345_DATAY1 0x35
80#define ADXL345_DATAZ0 0x36
81#define ADXL345_DATAZ1 0x37
82#define ADXL345_FIFO_CTL 0x38
83#define ADXL345_FIFO_STATUS 0x39
84#define ADXL345_TAP_SIGN 0x3A
85#define ADXL345_ORIENT_CONF 0x3B
86#define ADXL345_ORIENT 0x3C
89#define ADXL345_ACT_ACDC (1 << 7)
90#define ADXL345_ACT_X_EN (1 << 6)
91#define ADXL345_ACT_Y_EN (1 << 5)
92#define ADXL345_ACT_Z_EN (1 << 4)
93#define ADXL345_INACT_ACDC (1 << 3)
94#define ADXL345_INACT_X_EN (1 << 2)
95#define ADXL345_INACT_Y_EN (1 << 1)
96#define ADXL345_INACT_Z_EN (1 << 0)
99#define ADXL345_SUPPRESS (1 << 3)
100#define ADXL345_TAP_X_EN (1 << 2)
101#define ADXL345_TAP_Y_EN (1 << 1)
102#define ADXL345_TAP_Z_EN (1 << 0)
105#define ADXL345_ACT_X_SRC (1 << 6)
106#define ADXL345_ACT_Y_SRC (1 << 5)
107#define ADXL345_ACT_Z_SRC (1 << 4)
108#define ADXL345_ASLEEP (1 << 3)
109#define ADXL345_TAP_X_SRC (1 << 2)
110#define ADXL345_TAP_Y_SRC (1 << 1)
111#define ADXL345_TAP_Z_SRC (1 << 0)
114#define ADXL345_LOW_POWER (1 << 4)
115#define ADXL345_RATE(x) ((x) & 0xF)
118#define ADXL345_PCTL_LINK (1 << 5)
119#define ADXL345_PCTL_AUTO_SLEEP (1 << 4)
120#define ADXL345_PCTL_MEASURE (1 << 3)
121#define ADXL345_PCTL_SLEEP (1 << 2)
122#define ADXL345_PCTL_WAKEUP(x) ((x) & 0x3)
125#define ADXL345_DATA_READY (1 << 7)
126#define ADXL345_SINGLE_TAP (1 << 6)
127#define ADXL345_DOUBLE_TAP (1 << 5)
128#define ADXL345_ACTIVITY (1 << 4)
129#define ADXL345_INACTIVITY (1 << 3)
130#define ADXL345_FREE_FALL (1 << 2)
131#define ADXL345_WATERMARK (1 << 1)
132#define ADXL345_OVERRUN (1 << 0)
133#define ADXL345_ORIENTATION (1 << 0)
136#define ADXL345_SELF_TEST (1 << 7)
137#define ADXL345_SPI (1 << 6)
138#define ADXL345_INT_INVERT (1 << 5)
139#define ADXL345_FULL_RES (1 << 3)
140#define ADXL345_JUSTIFY (1 << 2)
141#define ADXL345_RANGE(x) ((x) & 0x3)
144#define ADXL345_RANGE_PM_2G 0
145#define ADXL345_RANGE_PM_4G 1
146#define ADXL345_RANGE_PM_8G 2
147#define ADXL345_RANGE_PM_16G 3
150#define ADXL345_FIFO_MODE(x) (((x) & 0x3) << 6)
151#define ADXL345_TRIGGER (1 << 5)
152#define ADXL345_SAMPLES(x) ((x) & 0x1F)
155#define ADXL345_FIFO_BYPASS 0
156#define ADXL345_FIFO_FIFO 1
157#define ADXL345_FIFO_STREAM 2
158#define ADXL345_FIFO_TRIGGER 3
161#define ADXL345_FIFO_TRIG (1 << 7)
162#define ADXL345_ENTRIES(x) ((x) & 0x3F)
165#define ADXL345_INT_ORIENT(x) (((x) & 0x1) << 7)
166#define ADXL345_DEAD_ZONE(x) (((x) & 0x7) << 4)
167#define ADXL345_INT_3D(x) (((x) & 0x1) << 3)
168#define ADXL345_DIVISOR(x) ((x) & 7)
171#define ADXL345_ID 0xE5
173#define ADXL346_ID 0xE6
176#define ADXL345_SCALE_FACTOR 0.0039
257 uint8_t register_address);
261 uint8_t register_address,
262 uint8_t register_value);
307 uint8_t inact_on_off,
310 uint8_t inact_thresh,
324 uint8_t orient_on_off,
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
void adxl345_set_inactivity_detection(struct adxl345_dev *dev, uint8_t inact_on_off, uint8_t inact_axes, uint8_t inact_ac_dc, uint8_t inact_thresh, uint8_t inact_time, uint8_t inact_int)
Enables/disables the inactivity detection.
Definition adxl345.c:436
int32_t adxl345_remove(struct adxl345_dev *dev)
Free the resources allocated by adxl345_init().
Definition adxl345.c:157
void adxl345_set_register_value(struct adxl345_dev *dev, uint8_t register_address, uint8_t register_value)
Writes data into a register.
Definition adxl345.c:85
void adxl345_set_orientation_detection(struct adxl345_dev *dev, uint8_t orient_int, uint8_t orient_on_off, uint8_t int_3d, enum adxl345_dead_zone_angle dead_zone, enum adxl345_divisor_bandwidth divisor)
Enables/disables the orientation detection (only for adxl346).
Definition adxl345.c:551
adxl345_divisor_bandwidth
ADXL346 Divisor bandwidth encoding.
Definition adxl345.h:206
@ ODR_DIV_9
Definition adxl345.h:207
@ ODR_DIV_100
Definition adxl345.h:210
@ ODR_DIV_400
Definition adxl345.h:212
@ ODR_DIV_50
Definition adxl345.h:209
@ ODR_DIV_200
Definition adxl345.h:211
@ ODR_DIV_1600
Definition adxl345.h:214
@ ODR_DIV_22
Definition adxl345.h:208
@ ODR_DIV_800
Definition adxl345.h:213
int32_t adxl345_init(struct adxl345_dev **device, struct adxl345_init_param init_param)
Initializes the communication peripheral and checks if the ADXL345 part is present.
Definition adxl345.c:121
void adxl345_set_range_resolution(struct adxl345_dev *dev, uint8_t g_range, uint8_t full_res)
Selects the measurement range.
Definition adxl345.c:627
void adxl345_get_g_xyz(struct adxl345_dev *dev, float *x, float *y, float *z)
Reads the raw output data of each axis and converts it to g.
Definition adxl345.c:249
adxl345_dead_zone_angle
ADXL346 Dead zone angle encoding.
Definition adxl345.h:191
@ DEGREES_30_8
Definition adxl345.h:197
@ DEGREES_36_1
Definition adxl345.h:198
@ DEGREES_41_4
Definition adxl345.h:199
@ DEGREES_15_2
Definition adxl345.h:194
@ DEGREES_5_1
Definition adxl345.h:192
@ DEGREES_25_5
Definition adxl345.h:196
@ DEGREES_10_2
Definition adxl345.h:193
@ DEGREES_20_4
Definition adxl345.h:195
adxl345_type
ADXL345 Supported devices.
Definition adxl345.h:182
@ ID_ADXL346
Definition adxl345.h:184
@ ID_ADXL345
Definition adxl345.h:183
void adxl345_set_tap_detection(struct adxl345_dev *dev, uint8_t tap_type, uint8_t tap_axes, uint8_t tap_dur, uint8_t tap_latent, uint8_t tap_window, uint8_t tap_thresh, uint8_t tap_int)
Enables/disables the tap detection.
Definition adxl345.c:293
uint8_t adxl345_get_register_value(struct adxl345_dev *dev, uint8_t register_address)
Reads the value of a register.
Definition adxl345.c:51
void adxl345_set_power_mode(struct adxl345_dev *dev, uint8_t pwr_mode)
Places the device into standby/measure mode.
Definition adxl345.c:179
void adxl345_set_offset(struct adxl345_dev *dev, uint8_t x_offset, uint8_t y_offset, uint8_t z_offset)
Sets an offset value for each axis (Offset Calibration).
Definition adxl345.c:598
void adxl345_set_free_fall_detection(struct adxl345_dev *dev, uint8_t ff_on_off, uint8_t ff_thresh, uint8_t ff_time, uint8_t ff_int)
Enables/disables the free-fall detection.
Definition adxl345.c:499
void adxl345_set_activity_detection(struct adxl345_dev *dev, uint8_t act_on_off, uint8_t act_axes, uint8_t act_ac_dc, uint8_t act_thresh, uint8_t act_int)
Enables/disables the activity detection.
Definition adxl345.c:370
void adxl345_get_xyz(struct adxl345_dev *dev, int16_t *x, int16_t *y, int16_t *z)
Reads the raw output data of each axis.
Definition adxl345.c:202
Header file of I2C Interface.
Header file of SPI Interface.
ADXL345 Device structure.
Definition adxl345.h:221
uint8_t communication_type
Definition adxl345.h:229
struct no_os_spi_desc * spi_desc
Definition adxl345.h:225
uint8_t selected_range
Definition adxl345.h:231
struct no_os_i2c_desc * i2c_desc
Definition adxl345.h:223
uint8_t full_resolution_set
Definition adxl345.h:233
enum adxl345_type dev_type
Definition adxl345.h:227
Structure holding the parameters for ADXL345 device initialization.
Definition adxl345.h:240
struct no_os_spi_init_param spi_init
Definition adxl345.h:244
uint8_t full_resolution_set
Definition adxl345.h:252
uint8_t selected_range
Definition adxl345.h:250
struct no_os_i2c_init_param i2c_init
Definition adxl345.h:242
enum adxl345_type dev_type
Definition adxl345.h:246
uint8_t communication_type
Definition adxl345.h:248
Definition ad9361_util.h:63
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128