Loading...
Searching...
No Matches
adxl345.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Mesotic SAS
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include "periph/i2c.h"
28#include "periph/gpio.h"
29
33enum {
36};
37
41enum {
46};
47
51enum {
56};
57
61enum {
78};
79
83enum {
88};
89
93enum {
96};
97
101enum {
103 ADXL345_DATA_READY = 1,
107};
108
112typedef struct {
113 int16_t x;
114 int16_t y;
115 int16_t z;
117
121typedef struct {
122 uint8_t source;
123 uint8_t map;
124 uint8_t enable;
125 uint8_t thres_tap;
126 uint8_t thres_dur;
127 uint8_t thres_latent;
128 uint8_t thres_window;
129 uint8_t thres_act;
130 uint8_t thres_inact;
131 uint8_t time_inact;
132 uint8_t thres_ff;
133 uint8_t time_ff;
134 uint8_t act_inact;
135 uint8_t tap_axes;
137
141typedef struct {
143 uint8_t addr;
144 gpio_t int1;
145 gpio_t int2;
146 uint8_t offset[3];
147 uint8_t range;
148 uint8_t rate;
149 uint8_t full_res;
151
160
171int adxl345_init(adxl345_t *dev, const adxl345_params_t* params);
184void adxl345_read(const adxl345_t *dev, adxl345_data_t *data);
185
192
199
206
213
220
227void adxl345_set_bandwidth_rate(const adxl345_t *dev, uint8_t bw_rate);
228
237void adxl345_set_fifo_mode(const adxl345_t *dev, uint8_t mode,
238 uint8_t output, uint8_t value);
239
240#ifdef __cplusplus
241}
242#endif
243
Low-level GPIO peripheral driver interface definitions.
void adxl345_set_autosleep(const adxl345_t *dev)
Set autosleep mode.
void adxl345_set_bandwidth_rate(const adxl345_t *dev, uint8_t bw_rate)
Set bandwidth rate.
void adxl345_set_interrupt(const adxl345_t *dev)
set ADXL345's interrupts configuration
void adxl345_set_measure(const adxl345_t *dev)
set ADXL345's measure mode
void adxl345_read(const adxl345_t *dev, adxl345_data_t *data)
Read accelerometer's data.
int adxl345_init(adxl345_t *dev, const adxl345_params_t *params)
Initialize the ADXL345 accelerometer driver.
void adxl345_set_fifo_mode(const adxl345_t *dev, uint8_t mode, uint8_t output, uint8_t value)
Set fifo mode with its configuration.
void adxl345_set_sleep(const adxl345_t *dev)
Set sleep mode.
void adxl345_set_standby(const adxl345_t *dev)
Set standby mode.
@ ADXL345_INT2
Output interrupt on INT2 pin.
Definition adxl345.h:95
@ ADXL345_INT1
Output interrupt on INT1 pin.
Definition adxl345.h:94
@ ADXL345_ADDR_1D
I2C device address if Alt addr pin is high.
Definition adxl345.h:34
@ ADXL345_ADDR_53
I2C device address if Alt addr pin is low.
Definition adxl345.h:35
@ ADXL345_RATE_0HZ78
0.78 Hz Output Data Rate
Definition adxl345.h:65
@ ADXL345_RATE_200HZ
200 Hz Output Data Rate
Definition adxl345.h:73
@ ADXL345_RATE_0HZ1
0.1 Hz Output Data Rate
Definition adxl345.h:62
@ ADXL345_RATE_25HZ
25 Hz Output Data Rate
Definition adxl345.h:70
@ ADXL345_RATE_400HZ
400 Hz Output Data Rate
Definition adxl345.h:74
@ ADXL345_RATE_0HZ2
0.2 Hz Output Data Rate
Definition adxl345.h:63
@ ADXL345_RATE_12HZ50
12.5 Hz Output Data Rate
Definition adxl345.h:69
@ ADXL345_RATE_3200HZ
3200 Hz Output Data Rate
Definition adxl345.h:77
@ ADXL345_RATE_3HZ13
3.13 Hz Output Data Rate
Definition adxl345.h:67
@ ADXL345_RATE_1600HZ
1600 Hz Output Data Rate
Definition adxl345.h:76
@ ADXL345_RATE_1HZ56
1.56 Hz Output Data Rate
Definition adxl345.h:66
@ ADXL345_RATE_6HZ25
6.25 Hz Output Data Rate
Definition adxl345.h:68
@ ADXL345_RATE_0HZ39
0.39 Hz Output Data Rate
Definition adxl345.h:64
@ ADXL345_RATE_100HZ
100 Hz Output Data Rate
Definition adxl345.h:72
@ ADXL345_RATE_50HZ
50 Hz Output Data Rate
Definition adxl345.h:71
@ ADXL345_RATE_800HZ
800 Hz Output Data Rate
Definition adxl345.h:75
@ ADXL345_OK
everything was fine
Definition adxl345.h:102
@ ADXL345_NODATA
no data available
Definition adxl345.h:106
@ ADXL345_NODEV
no ADXL345 device found on the bus
Definition adxl345.h:105
@ ADXL345_NOI2C
I2C communication failed.
Definition adxl345.h:104
@ ADXL345_AUTOSLEEP_MODE
Autosleep mode.
Definition adxl345.h:45
@ ADXL345_MEASURE_MODE
Measure mode.
Definition adxl345.h:42
@ ADXL345_STANDBY_MODE
Standby mode.
Definition adxl345.h:43
@ ADXL345_SLEEP_MODE
Sleep mode.
Definition adxl345.h:44
@ ADXL345_RANGE_8G
+/- 8 g Full Scale Range
Definition adxl345.h:54
@ ADXL345_RANGE_2G
+/- 2 g Full Scale Range
Definition adxl345.h:52
@ ADXL345_RANGE_16G
+/- 16 g Full Scale Range
Definition adxl345.h:55
@ ADXL345_RANGE_4G
+/- 4 g Full Scale Range
Definition adxl345.h:53
@ ADXL345_FIFO
FIFO mode.
Definition adxl345.h:85
@ ADXL345_TRIGGER
FIFO trigger mode.
Definition adxl345.h:87
@ ADXL345_BYPASS
FIFO bypass mode.
Definition adxl345.h:84
@ ADXL345_STREAM
FIFO stream mode.
Definition adxl345.h:86
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
ADXL345 result vector struct.
Definition adxl345.h:112
int16_t y
Y-Axis measurement result.
Definition adxl345.h:114
int16_t x
X-Axis measurement result.
Definition adxl345.h:113
int16_t z
Z-Axis measurement result.
Definition adxl345.h:115
Interrupt configuration struct for the ADXL345 sensor.
Definition adxl345.h:121
uint8_t time_ff
Time threshold.
Definition adxl345.h:133
uint8_t tap_axes
Axis control for single tap/double tap.
Definition adxl345.h:135
uint8_t thres_inact
Inactivity threshold.
Definition adxl345.h:130
uint8_t thres_tap
Tap threshold.
Definition adxl345.h:125
uint8_t thres_latent
Tap latency.
Definition adxl345.h:127
uint8_t enable
Interrupt enable control.
Definition adxl345.h:124
uint8_t time_inact
Inactivity time.
Definition adxl345.h:131
uint8_t thres_dur
Tap duration.
Definition adxl345.h:126
uint8_t map
Interrupt mapping control.
Definition adxl345.h:123
uint8_t thres_window
Tap window.
Definition adxl345.h:128
uint8_t thres_ff
Free-fall threshold.
Definition adxl345.h:132
uint8_t source
Source of interrupts.
Definition adxl345.h:122
uint8_t act_inact
Enable ctrl for activity/inactivity detection.
Definition adxl345.h:134
uint8_t thres_act
Activity threshold.
Definition adxl345.h:129
Configuration struct for the ADXL345 sensor.
Definition adxl345.h:141
i2c_t i2c
I2C device which is used.
Definition adxl345.h:142
uint8_t range
Sensitivity configuration.
Definition adxl345.h:147
uint8_t rate
Configured sample rate for accel.
Definition adxl345.h:148
uint8_t full_res
Resolution bit.
Definition adxl345.h:149
gpio_t int2
accelerometer int2 pin
Definition adxl345.h:145
uint8_t addr
I2C address.
Definition adxl345.h:143
uint8_t offset[3]
offset axis
Definition adxl345.h:146
gpio_t int1
accelerometer int1 pin
Definition adxl345.h:144
Device descriptor for the ADXL345 sensor.
Definition adxl345.h:155
adxl345_interrupt_t interrupt
Interrupts configuration.
Definition adxl345.h:157
adxl345_params_t params
Device configuration.
Definition adxl345.h:156
int16_t scale_factor
Scale factor for converting value to mg.
Definition adxl345.h:158