Loading...
Searching...
No Matches
adxl345.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Mesotic SAS
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
24#ifndef ADXL345_H
25#define ADXL345_H
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include "periph/i2c.h"
32#include "periph/gpio.h"
33
37enum {
40};
41
45enum {
50};
51
55enum {
60};
61
65enum {
82};
83
87enum {
92};
93
97enum {
101
105enum {
110 ADXL345_NODATA = -3
112
116typedef struct {
117 int16_t x;
118 int16_t y;
119 int16_t z;
121
125typedef struct {
126 uint8_t source;
127 uint8_t map;
128 uint8_t enable;
129 uint8_t thres_tap;
130 uint8_t thres_dur;
131 uint8_t thres_latent;
132 uint8_t thres_window;
133 uint8_t thres_act;
134 uint8_t thres_inact;
135 uint8_t time_inact;
136 uint8_t thres_ff;
137 uint8_t time_ff;
138 uint8_t act_inact;
139 uint8_t tap_axes;
141
145typedef struct {
147 uint8_t addr;
148 gpio_t int1;
149 gpio_t int2;
150 uint8_t offset[3];
151 uint8_t range;
152 uint8_t rate;
153 uint8_t full_res;
155
164
175int adxl345_init(adxl345_t *dev, const adxl345_params_t* params);
188void adxl345_read(const adxl345_t *dev, adxl345_data_t *data);
189
196
203
210
217
224
231void adxl345_set_bandwidth_rate(const adxl345_t *dev, uint8_t bw_rate);
232
241void adxl345_set_fifo_mode(const adxl345_t *dev, uint8_t mode,
242 uint8_t output, uint8_t value);
243
244#ifdef __cplusplus
245}
246#endif
247
248#endif /* ADXL345_H */
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_ADDR_1D
I2C device address if Alt addr pin is high.
Definition adxl345.h:38
@ ADXL345_ADDR_53
I2C device address if Alt addr pin is low.
Definition adxl345.h:39
@ ADXL345_RATE_0HZ78
0.78 Hz Output Data Rate
Definition adxl345.h:69
@ ADXL345_RATE_200HZ
200 Hz Output Data Rate
Definition adxl345.h:77
@ ADXL345_RATE_0HZ1
0.1 Hz Output Data Rate
Definition adxl345.h:66
@ ADXL345_RATE_25HZ
25 Hz Output Data Rate
Definition adxl345.h:74
@ ADXL345_RATE_400HZ
400 Hz Output Data Rate
Definition adxl345.h:78
@ ADXL345_RATE_0HZ2
0.2 Hz Output Data Rate
Definition adxl345.h:67
@ ADXL345_RATE_12HZ50
12.5 Hz Output Data Rate
Definition adxl345.h:73
@ ADXL345_RATE_3200HZ
3200 Hz Output Data Rate
Definition adxl345.h:81
@ ADXL345_RATE_3HZ13
3.13 Hz Output Data Rate
Definition adxl345.h:71
@ ADXL345_RATE_1600HZ
1600 Hz Output Data Rate
Definition adxl345.h:80
@ ADXL345_RATE_1HZ56
1.56 Hz Output Data Rate
Definition adxl345.h:70
@ ADXL345_RATE_6HZ25
6.25 Hz Output Data Rate
Definition adxl345.h:72
@ ADXL345_RATE_0HZ39
0.39 Hz Output Data Rate
Definition adxl345.h:68
@ ADXL345_RATE_100HZ
100 Hz Output Data Rate
Definition adxl345.h:76
@ ADXL345_RATE_50HZ
50 Hz Output Data Rate
Definition adxl345.h:75
@ ADXL345_RATE_800HZ
800 Hz Output Data Rate
Definition adxl345.h:79
@ ADXL345_DATA_READY
new data ready to be read
Definition adxl345.h:107
@ ADXL345_OK
everything was fine
Definition adxl345.h:106
@ ADXL345_NODATA
no data available
Definition adxl345.h:110
@ ADXL345_NODEV
no ADXL345 device found on the bus
Definition adxl345.h:109
@ ADXL345_NOI2C
I2C communication failed.
Definition adxl345.h:108
@ ADXL345_FIFO
FIFO mode.
Definition adxl345.h:89
@ ADXL345_TRIGGER
FIFO trigger mode.
Definition adxl345.h:91
@ ADXL345_BYPASS
FIFO bypass mode.
Definition adxl345.h:88
@ ADXL345_STREAM
FIFO stream mode.
Definition adxl345.h:90
@ ADXL345_AUTOSLEEP_MODE
Autosleep mode.
Definition adxl345.h:49
@ ADXL345_MEASURE_MODE
Measure mode.
Definition adxl345.h:46
@ ADXL345_STANDBY_MODE
Standby mode.
Definition adxl345.h:47
@ ADXL345_SLEEP_MODE
Sleep mode.
Definition adxl345.h:48
@ ADXL345_RANGE_8G
+/- 8 g Full Scale Range
Definition adxl345.h:58
@ ADXL345_RANGE_2G
+/- 2 g Full Scale Range
Definition adxl345.h:56
@ ADXL345_RANGE_16G
+/- 16 g Full Scale Range
Definition adxl345.h:59
@ ADXL345_RANGE_4G
+/- 4 g Full Scale Range
Definition adxl345.h:57
@ ADXL345_INT2
Output interrupt on INT2 pin.
Definition adxl345.h:99
@ ADXL345_INT1
Output interrupt on INT1 pin.
Definition adxl345.h:98
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
ADXL345 result vector struct.
Definition adxl345.h:116
int16_t y
Y-Axis measurement result.
Definition adxl345.h:118
int16_t x
X-Axis measurement result.
Definition adxl345.h:117
int16_t z
Z-Axis measurement result.
Definition adxl345.h:119
Interrupt configuration struct for the ADXL345 sensor.
Definition adxl345.h:125
uint8_t time_ff
Time threshold.
Definition adxl345.h:137
uint8_t tap_axes
Axis control for single tap/double tap.
Definition adxl345.h:139
uint8_t thres_inact
Inactivity threshold.
Definition adxl345.h:134
uint8_t thres_tap
Tap threshold.
Definition adxl345.h:129
uint8_t thres_latent
Tap latency.
Definition adxl345.h:131
uint8_t enable
Interrupt enable control.
Definition adxl345.h:128
uint8_t time_inact
Inactivity time.
Definition adxl345.h:135
uint8_t thres_dur
Tap duration.
Definition adxl345.h:130
uint8_t map
Interrupt mapping control.
Definition adxl345.h:127
uint8_t thres_window
Tap window.
Definition adxl345.h:132
uint8_t thres_ff
Free-fall threshold.
Definition adxl345.h:136
uint8_t source
Source of interrupts.
Definition adxl345.h:126
uint8_t act_inact
Enable ctrl for activity/inactivity detection.
Definition adxl345.h:138
uint8_t thres_act
Activity threshold.
Definition adxl345.h:133
Configuration struct for the ADXL345 sensor.
Definition adxl345.h:145
i2c_t i2c
I2C device which is used.
Definition adxl345.h:146
uint8_t range
Sensitivity configuration.
Definition adxl345.h:151
uint8_t rate
Configured sample rate for accel
Definition adxl345.h:152
uint8_t full_res
Resolution bit.
Definition adxl345.h:153
gpio_t int2
accelerometer int2 pin
Definition adxl345.h:149
uint8_t addr
I2C address.
Definition adxl345.h:147
gpio_t int1
accelerometer int1 pin
Definition adxl345.h:148
Device descriptor for the ADXL345 sensor.
Definition adxl345.h:159
adxl345_interrupt_t interrupt
Interrupts configuration
Definition adxl345.h:161
adxl345_params_t params
Device configuration.
Definition adxl345.h:160
int16_t scale_factor
Scale factor for converting value to mg.
Definition adxl345.h:162