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
9#pragma once
10
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include "periph/i2c.h"
31#include "periph/gpio.h"
32
36enum {
39};
40
44enum {
49};
50
54enum {
59};
60
64enum {
81};
82
86enum {
91};
92
96enum {
99};
100
104enum {
106 ADXL345_DATA_READY = 1,
110};
111
115typedef struct {
116 int16_t x;
117 int16_t y;
118 int16_t z;
120
124typedef struct {
125 uint8_t source;
126 uint8_t map;
127 uint8_t enable;
128 uint8_t thres_tap;
129 uint8_t thres_dur;
130 uint8_t thres_latent;
131 uint8_t thres_window;
132 uint8_t thres_act;
133 uint8_t thres_inact;
134 uint8_t time_inact;
135 uint8_t thres_ff;
136 uint8_t time_ff;
137 uint8_t act_inact;
138 uint8_t tap_axes;
140
144typedef struct {
146 uint8_t addr;
147 gpio_t int1;
148 gpio_t int2;
149 uint8_t offset[3];
150 uint8_t range;
151 uint8_t rate;
152 uint8_t full_res;
154
163
174int adxl345_init(adxl345_t *dev, const adxl345_params_t* params);
187void adxl345_read(const adxl345_t *dev, adxl345_data_t *data);
188
195
202
209
216
223
230void adxl345_set_bandwidth_rate(const adxl345_t *dev, uint8_t bw_rate);
231
240void adxl345_set_fifo_mode(const adxl345_t *dev, uint8_t mode,
241 uint8_t output, uint8_t value);
242
243#ifdef __cplusplus
244}
245#endif
246
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:98
@ ADXL345_INT1
Output interrupt on INT1 pin.
Definition adxl345.h:97
@ ADXL345_ADDR_1D
I2C device address if Alt addr pin is high.
Definition adxl345.h:37
@ ADXL345_ADDR_53
I2C device address if Alt addr pin is low.
Definition adxl345.h:38
@ ADXL345_RATE_0HZ78
0.78 Hz Output Data Rate
Definition adxl345.h:68
@ ADXL345_RATE_200HZ
200 Hz Output Data Rate
Definition adxl345.h:76
@ ADXL345_RATE_0HZ1
0.1 Hz Output Data Rate
Definition adxl345.h:65
@ ADXL345_RATE_25HZ
25 Hz Output Data Rate
Definition adxl345.h:73
@ ADXL345_RATE_400HZ
400 Hz Output Data Rate
Definition adxl345.h:77
@ ADXL345_RATE_0HZ2
0.2 Hz Output Data Rate
Definition adxl345.h:66
@ ADXL345_RATE_12HZ50
12.5 Hz Output Data Rate
Definition adxl345.h:72
@ ADXL345_RATE_3200HZ
3200 Hz Output Data Rate
Definition adxl345.h:80
@ ADXL345_RATE_3HZ13
3.13 Hz Output Data Rate
Definition adxl345.h:70
@ ADXL345_RATE_1600HZ
1600 Hz Output Data Rate
Definition adxl345.h:79
@ ADXL345_RATE_1HZ56
1.56 Hz Output Data Rate
Definition adxl345.h:69
@ ADXL345_RATE_6HZ25
6.25 Hz Output Data Rate
Definition adxl345.h:71
@ ADXL345_RATE_0HZ39
0.39 Hz Output Data Rate
Definition adxl345.h:67
@ ADXL345_RATE_100HZ
100 Hz Output Data Rate
Definition adxl345.h:75
@ ADXL345_RATE_50HZ
50 Hz Output Data Rate
Definition adxl345.h:74
@ ADXL345_RATE_800HZ
800 Hz Output Data Rate
Definition adxl345.h:78
@ ADXL345_OK
everything was fine
Definition adxl345.h:105
@ ADXL345_NODATA
no data available
Definition adxl345.h:109
@ ADXL345_NODEV
no ADXL345 device found on the bus
Definition adxl345.h:108
@ ADXL345_NOI2C
I2C communication failed.
Definition adxl345.h:107
@ ADXL345_AUTOSLEEP_MODE
Autosleep mode.
Definition adxl345.h:48
@ ADXL345_MEASURE_MODE
Measure mode.
Definition adxl345.h:45
@ ADXL345_STANDBY_MODE
Standby mode.
Definition adxl345.h:46
@ ADXL345_SLEEP_MODE
Sleep mode.
Definition adxl345.h:47
@ ADXL345_RANGE_8G
+/- 8 g Full Scale Range
Definition adxl345.h:57
@ ADXL345_RANGE_2G
+/- 2 g Full Scale Range
Definition adxl345.h:55
@ ADXL345_RANGE_16G
+/- 16 g Full Scale Range
Definition adxl345.h:58
@ ADXL345_RANGE_4G
+/- 4 g Full Scale Range
Definition adxl345.h:56
@ ADXL345_FIFO
FIFO mode.
Definition adxl345.h:88
@ ADXL345_TRIGGER
FIFO trigger mode.
Definition adxl345.h:90
@ ADXL345_BYPASS
FIFO bypass mode.
Definition adxl345.h:87
@ ADXL345_STREAM
FIFO stream mode.
Definition adxl345.h:89
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:144
Low-level I2C peripheral driver interface definition.
ADXL345 result vector struct.
Definition adxl345.h:115
int16_t y
Y-Axis measurement result.
Definition adxl345.h:117
int16_t x
X-Axis measurement result.
Definition adxl345.h:116
int16_t z
Z-Axis measurement result.
Definition adxl345.h:118
Interrupt configuration struct for the ADXL345 sensor.
Definition adxl345.h:124
uint8_t time_ff
Time threshold.
Definition adxl345.h:136
uint8_t tap_axes
Axis control for single tap/double tap.
Definition adxl345.h:138
uint8_t thres_inact
Inactivity threshold.
Definition adxl345.h:133
uint8_t thres_tap
Tap threshold.
Definition adxl345.h:128
uint8_t thres_latent
Tap latency.
Definition adxl345.h:130
uint8_t enable
Interrupt enable control.
Definition adxl345.h:127
uint8_t time_inact
Inactivity time.
Definition adxl345.h:134
uint8_t thres_dur
Tap duration.
Definition adxl345.h:129
uint8_t map
Interrupt mapping control.
Definition adxl345.h:126
uint8_t thres_window
Tap window.
Definition adxl345.h:131
uint8_t thres_ff
Free-fall threshold.
Definition adxl345.h:135
uint8_t source
Source of interrupts.
Definition adxl345.h:125
uint8_t act_inact
Enable ctrl for activity/inactivity detection.
Definition adxl345.h:137
uint8_t thres_act
Activity threshold.
Definition adxl345.h:132
Configuration struct for the ADXL345 sensor.
Definition adxl345.h:144
i2c_t i2c
I2C device which is used.
Definition adxl345.h:145
uint8_t range
Sensitivity configuration.
Definition adxl345.h:150
uint8_t rate
Configured sample rate for accel.
Definition adxl345.h:151
uint8_t full_res
Resolution bit.
Definition adxl345.h:152
gpio_t int2
accelerometer int2 pin
Definition adxl345.h:148
uint8_t addr
I2C address.
Definition adxl345.h:146
uint8_t offset[3]
offset axis
Definition adxl345.h:149
gpio_t int1
accelerometer int1 pin
Definition adxl345.h:147
Device descriptor for the ADXL345 sensor.
Definition adxl345.h:158
adxl345_interrupt_t interrupt
Interrupts configuration.
Definition adxl345.h:160
adxl345_params_t params
Device configuration.
Definition adxl345.h:159
int16_t scale_factor
Scale factor for converting value to mg.
Definition adxl345.h:161