Loading...
Searching...
No Matches

Device driver interface for the ADXL345. More...

Detailed Description

Device driver interface for the ADXL345.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.

Files

file  adxl345_params.h
 Default configuration for ADXL345 devices.
 
file  adxl345_regs.h
 Register and bit definitions for the ADXL345.
 
file  adxl345.h
 Interface definition for the ADXL345.
 

Data Structures

struct  adxl345_data_t
 ADXL345 result vector struct. More...
 
struct  adxl345_interrupt_t
 Interrupt configuration struct for the ADXL345 sensor. More...
 
struct  adxl345_params_t
 Configuration struct for the ADXL345 sensor. More...
 
struct  adxl345_t
 Device descriptor for the ADXL345 sensor. More...
 

Enumerations

enum  { ADXL345_ADDR_1D = 0x1D , ADXL345_ADDR_53 = 0x53 }
 Possible ADXL345 hardware addresses (wiring specific) More...
 
enum  { ADXL345_MEASURE_MODE , ADXL345_STANDBY_MODE , ADXL345_SLEEP_MODE , ADXL345_AUTOSLEEP_MODE }
 List ADXL345 power mode. More...
 
enum  { ADXL345_RANGE_2G = 0 , ADXL345_RANGE_4G = 1 , ADXL345_RANGE_8G = 2 , ADXL345_RANGE_16G = 3 }
 Define ADXL345 sensitivity. More...
 
enum  {
  ADXL345_RATE_0HZ1 = 0 , ADXL345_RATE_0HZ2 = 1 , ADXL345_RATE_0HZ39 = 2 , ADXL345_RATE_0HZ78 = 3 ,
  ADXL345_RATE_1HZ56 = 4 , ADXL345_RATE_3HZ13 = 5 , ADXL345_RATE_6HZ25 = 6 , ADXL345_RATE_12HZ50 = 7 ,
  ADXL345_RATE_25HZ = 8 , ADXL345_RATE_50HZ = 9 , ADXL345_RATE_100HZ = 10 , ADXL345_RATE_200HZ = 11 ,
  ADXL345_RATE_400HZ = 12 , ADXL345_RATE_800HZ = 13 , ADXL345_RATE_1600HZ = 14 , ADXL345_RATE_3200HZ = 15
}
 List bandwidth rate. More...
 
enum  { ADXL345_BYPASS = 0 , ADXL345_FIFO = 1 , ADXL345_STREAM = 2 , ADXL345_TRIGGER = 3 }
 List fifo mode. More...
 
enum  { ADXL345_INT1 , ADXL345_INT2 }
 Output Interrupt selection. More...
 
enum  {
  ADXL345_OK = 0 , ADXL345_DATA_READY = 1 , ADXL345_NOI2C = -1 , ADXL345_NODEV = -2 ,
  ADXL345_NODATA = -3
}
 Named return values. More...
 

Functions

int adxl345_init (adxl345_t *dev, const adxl345_params_t *params)
 Initialize the ADXL345 accelerometer driver.
 
void adxl345_read (const adxl345_t *dev, adxl345_data_t *data)
 Read accelerometer's data.
 
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_set_standby (const adxl345_t *dev)
 Set standby mode.
 
void adxl345_set_sleep (const adxl345_t *dev)
 Set sleep mode.
 
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_fifo_mode (const adxl345_t *dev, uint8_t mode, uint8_t output, uint8_t value)
 Set fifo mode with its configuration.
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Possible ADXL345 hardware addresses (wiring specific)

Enumerator
ADXL345_ADDR_1D 

I2C device address if Alt addr pin is high.

ADXL345_ADDR_53 

I2C device address if Alt addr pin is low.

Definition at line 37 of file adxl345.h.

◆ anonymous enum

anonymous enum

List ADXL345 power mode.

Enumerator
ADXL345_MEASURE_MODE 

Measure mode.

ADXL345_STANDBY_MODE 

Standby mode.

ADXL345_SLEEP_MODE 

Sleep mode.

ADXL345_AUTOSLEEP_MODE 

Autosleep mode.

Definition at line 45 of file adxl345.h.

◆ anonymous enum

anonymous enum

Define ADXL345 sensitivity.

Enumerator
ADXL345_RANGE_2G 

+/- 2 g Full Scale Range

ADXL345_RANGE_4G 

+/- 4 g Full Scale Range

ADXL345_RANGE_8G 

+/- 8 g Full Scale Range

ADXL345_RANGE_16G 

+/- 16 g Full Scale Range

Definition at line 55 of file adxl345.h.

◆ anonymous enum

anonymous enum

List bandwidth rate.

Enumerator
ADXL345_RATE_0HZ1 

0.1 Hz Output Data Rate

ADXL345_RATE_0HZ2 

0.2 Hz Output Data Rate

ADXL345_RATE_0HZ39 

0.39 Hz Output Data Rate

ADXL345_RATE_0HZ78 

0.78 Hz Output Data Rate

ADXL345_RATE_1HZ56 

1.56 Hz Output Data Rate

ADXL345_RATE_3HZ13 

3.13 Hz Output Data Rate

ADXL345_RATE_6HZ25 

6.25 Hz Output Data Rate

ADXL345_RATE_12HZ50 

12.5 Hz Output Data Rate

ADXL345_RATE_25HZ 

25 Hz Output Data Rate

ADXL345_RATE_50HZ 

50 Hz Output Data Rate

ADXL345_RATE_100HZ 

100 Hz Output Data Rate

ADXL345_RATE_200HZ 

200 Hz Output Data Rate

ADXL345_RATE_400HZ 

400 Hz Output Data Rate

ADXL345_RATE_800HZ 

800 Hz Output Data Rate

ADXL345_RATE_1600HZ 

1600 Hz Output Data Rate

ADXL345_RATE_3200HZ 

3200 Hz Output Data Rate

Definition at line 65 of file adxl345.h.

◆ anonymous enum

anonymous enum

List fifo mode.

Enumerator
ADXL345_BYPASS 

FIFO bypass mode.

ADXL345_FIFO 

FIFO mode.

ADXL345_STREAM 

FIFO stream mode.

ADXL345_TRIGGER 

FIFO trigger mode.

Definition at line 87 of file adxl345.h.

◆ anonymous enum

anonymous enum

Output Interrupt selection.

Enumerator
ADXL345_INT1 

Output interrupt on INT1 pin.

ADXL345_INT2 

Output interrupt on INT2 pin.

Definition at line 97 of file adxl345.h.

◆ anonymous enum

anonymous enum

Named return values.

Enumerator
ADXL345_OK 

everything was fine

ADXL345_DATA_READY 

new data ready to be read

ADXL345_NOI2C 

I2C communication failed.

ADXL345_NODEV 

no ADXL345 device found on the bus

ADXL345_NODATA 

no data available

Definition at line 105 of file adxl345.h.

Function Documentation

◆ adxl345_init()

int adxl345_init ( adxl345_t dev,
const adxl345_params_t params 
)

Initialize the ADXL345 accelerometer driver.

Parameters
[out]devdevice descriptor of accelerometer to initialize
[in]paramsconfiguration parameters
Returns
ADXL345_OK on success
ADXL345_NOI2C if initialization of I2C bus failed
ADXL345_NODEV if accelerometer test failed

◆ adxl345_read()

void adxl345_read ( const adxl345_t dev,
adxl345_data_t data 
)

Read accelerometer's data.

Acceleration will be calculated as:
$ accel = {value \times 3.9} $ if full scale is set to 2g
$ accel = {value \times 7.8} $ if full scale is set to 4g
$ accel = {value \times 15.6} $ if full scale is set to 8g
$ accel = {value \times 31.2} $ if full scale is set to 16g

Parameters
[in]devdevice descriptor of accelerometer
[out]datathe current acceleration data [in mg]

◆ adxl345_set_autosleep()

void adxl345_set_autosleep ( const adxl345_t dev)

Set autosleep mode.

Parameters
[in]devdevice descriptor of accelerometer

◆ adxl345_set_bandwidth_rate()

void adxl345_set_bandwidth_rate ( const adxl345_t dev,
uint8_t  bw_rate 
)

Set bandwidth rate.

Parameters
[in]devdevice descriptor of accelerometer
[in]bw_ratenew datarate

◆ adxl345_set_fifo_mode()

void adxl345_set_fifo_mode ( const adxl345_t dev,
uint8_t  mode,
uint8_t  output,
uint8_t  value 
)

Set fifo mode with its configuration.

Parameters
[in]devdevice descriptor of accelerometer
[in]modefifo mode configuration
[in]outputset trigger output
[in]valueset trigger's value

◆ adxl345_set_interrupt()

void adxl345_set_interrupt ( const adxl345_t dev)

set ADXL345's interrupts configuration

Parameters
[in]devdevice descriptor of accelerometer

◆ adxl345_set_measure()

void adxl345_set_measure ( const adxl345_t dev)

set ADXL345's measure mode

Parameters
[in]devdevice descriptor of accelerometer

◆ adxl345_set_sleep()

void adxl345_set_sleep ( const adxl345_t dev)

Set sleep mode.

Parameters
[in]devdevice descriptor of accelerometer

◆ adxl345_set_standby()

void adxl345_set_standby ( const adxl345_t dev)

Set standby mode.

Parameters
[in]devdevice descriptor of accelerometer