no-OS
Classes | Macros | Enumerations | Functions
adxl345.h File Reference

Header file of ADXL345 Driver. More...

#include <stdint.h>
#include "no_os_i2c.h"
#include "no_os_spi.h"
Include dependency graph for adxl345.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  adxl345_dev
 ADXL345 Device structure. More...
 
struct  adxl345_init_param
 Structure holding the parameters for ADXL345 device initialization. More...
 

Macros

#define ADXL345_SPI_COMM   0
 
#define ADXL345_I2C_COMM   1
 
#define ADXL345_ADDRESS   0x1D
 
#define ADXL345_SPI_READ   (1 << 7)
 
#define ADXL345_SPI_WRITE   (0 << 7)
 
#define ADXL345_SPI_MB   (1 << 6)
 
#define ADXL345_DEVID   0x00
 
#define ADXL345_THRESH_TAP   0x1D
 
#define ADXL345_OFSX   0x1E
 
#define ADXL345_OFSY   0x1F
 
#define ADXL345_OFSZ   0x20
 
#define ADXL345_DUR   0x21
 
#define ADXL345_LATENT   0x22
 
#define ADXL345_WINDOW   0x23
 
#define ADXL345_THRESH_ACT   0x24
 
#define ADXL345_THRESH_INACT   0x25
 
#define ADXL345_TIME_INACT   0x26
 
#define ADXL345_ACT_INACT_CTL   0x27
 
#define ADXL345_THRESH_FF   0x28
 
#define ADXL345_TIME_FF   0x29
 
#define ADXL345_TAP_AXES   0x2A
 
#define ADXL345_ACT_TAP_STATUS   0x2B
 
#define ADXL345_BW_RATE   0x2C
 
#define ADXL345_POWER_CTL   0x2D
 
#define ADXL345_INT_ENABLE   0x2E
 
#define ADXL345_INT_MAP   0x2F
 
#define ADXL345_INT_SOURCE   0x30
 
#define ADXL345_DATA_FORMAT   0x31
 
#define ADXL345_DATAX0   0x32
 
#define ADXL345_DATAX1   0x33
 
#define ADXL345_DATAY0   0x34
 
#define ADXL345_DATAY1   0x35
 
#define ADXL345_DATAZ0   0x36
 
#define ADXL345_DATAZ1   0x37
 
#define ADXL345_FIFO_CTL   0x38
 
#define ADXL345_FIFO_STATUS   0x39
 
#define ADXL345_TAP_SIGN   0x3A
 
#define ADXL345_ORIENT_CONF   0x3B
 
#define ADXL345_ORIENT   0x3C
 
#define ADXL345_ACT_ACDC   (1 << 7)
 
#define ADXL345_ACT_X_EN   (1 << 6)
 
#define ADXL345_ACT_Y_EN   (1 << 5)
 
#define ADXL345_ACT_Z_EN   (1 << 4)
 
#define ADXL345_INACT_ACDC   (1 << 3)
 
#define ADXL345_INACT_X_EN   (1 << 2)
 
#define ADXL345_INACT_Y_EN   (1 << 1)
 
#define ADXL345_INACT_Z_EN   (1 << 0)
 
#define ADXL345_SUPPRESS   (1 << 3)
 
#define ADXL345_TAP_X_EN   (1 << 2)
 
#define ADXL345_TAP_Y_EN   (1 << 1)
 
#define ADXL345_TAP_Z_EN   (1 << 0)
 
#define ADXL345_ACT_X_SRC   (1 << 6)
 
#define ADXL345_ACT_Y_SRC   (1 << 5)
 
#define ADXL345_ACT_Z_SRC   (1 << 4)
 
#define ADXL345_ASLEEP   (1 << 3)
 
#define ADXL345_TAP_X_SRC   (1 << 2)
 
#define ADXL345_TAP_Y_SRC   (1 << 1)
 
#define ADXL345_TAP_Z_SRC   (1 << 0)
 
#define ADXL345_LOW_POWER   (1 << 4)
 
#define ADXL345_RATE(x)   ((x) & 0xF)
 
#define ADXL345_PCTL_LINK   (1 << 5)
 
#define ADXL345_PCTL_AUTO_SLEEP   (1 << 4)
 
#define ADXL345_PCTL_MEASURE   (1 << 3)
 
#define ADXL345_PCTL_SLEEP   (1 << 2)
 
#define ADXL345_PCTL_WAKEUP(x)   ((x) & 0x3)
 
#define ADXL345_DATA_READY   (1 << 7)
 
#define ADXL345_SINGLE_TAP   (1 << 6)
 
#define ADXL345_DOUBLE_TAP   (1 << 5)
 
#define ADXL345_ACTIVITY   (1 << 4)
 
#define ADXL345_INACTIVITY   (1 << 3)
 
#define ADXL345_FREE_FALL   (1 << 2)
 
#define ADXL345_WATERMARK   (1 << 1)
 
#define ADXL345_OVERRUN   (1 << 0)
 
#define ADXL345_ORIENTATION   (1 << 0)
 
#define ADXL345_SELF_TEST   (1 << 7)
 
#define ADXL345_SPI   (1 << 6)
 
#define ADXL345_INT_INVERT   (1 << 5)
 
#define ADXL345_FULL_RES   (1 << 3)
 
#define ADXL345_JUSTIFY   (1 << 2)
 
#define ADXL345_RANGE(x)   ((x) & 0x3)
 
#define ADXL345_RANGE_PM_2G   0
 
#define ADXL345_RANGE_PM_4G   1
 
#define ADXL345_RANGE_PM_8G   2
 
#define ADXL345_RANGE_PM_16G   3
 
#define ADXL345_FIFO_MODE(x)   (((x) & 0x3) << 6)
 
#define ADXL345_TRIGGER   (1 << 5)
 
#define ADXL345_SAMPLES(x)   ((x) & 0x1F)
 
#define ADXL345_FIFO_BYPASS   0
 
#define ADXL345_FIFO_FIFO   1
 
#define ADXL345_FIFO_STREAM   2
 
#define ADXL345_FIFO_TRIGGER   3
 
#define ADXL345_FIFO_TRIG   (1 << 7)
 
#define ADXL345_ENTRIES(x)   ((x) & 0x3F)
 
#define ADXL345_INT_ORIENT(x)   (((x) & 0x1) << 7)
 
#define ADXL345_DEAD_ZONE(x)   (((x) & 0x7) << 4)
 
#define ADXL345_INT_3D(x)   (((x) & 0x1) << 3)
 
#define ADXL345_DIVISOR(x)   ((x) & 7)
 
#define ADXL345_ID   0xE5
 
#define ADXL346_ID   0xE6
 
#define ADXL345_SCALE_FACTOR   0.0039
 

Enumerations

enum  adxl345_type {
  ID_ADXL345,
  ID_ADXL346
}
 ADXL345 Supported devices. More...
 
enum  adxl345_dead_zone_angle {
  DEGREES_5_1,
  DEGREES_10_2,
  DEGREES_15_2,
  DEGREES_20_4,
  DEGREES_25_5,
  DEGREES_30_8,
  DEGREES_36_1,
  DEGREES_41_4
}
 ADXL346 Dead zone angle encoding. More...
 
enum  adxl345_divisor_bandwidth {
  ODR_DIV_9,
  ODR_DIV_22,
  ODR_DIV_50,
  ODR_DIV_100,
  ODR_DIV_200,
  ODR_DIV_400,
  ODR_DIV_800,
  ODR_DIV_1600
}
 ADXL346 Divisor bandwidth encoding. More...
 

Functions

uint8_t adxl345_get_register_value (struct adxl345_dev *dev, uint8_t register_address)
 Reads the value of a register. More...
 
void adxl345_set_register_value (struct adxl345_dev *dev, uint8_t register_address, uint8_t register_value)
 Writes data into a register. More...
 
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. More...
 
int32_t adxl345_remove (struct adxl345_dev *dev)
 Free the resources allocated by adxl345_init(). More...
 
void adxl345_set_power_mode (struct adxl345_dev *dev, uint8_t pwr_mode)
 Places the device into standby/measure mode. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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). More...
 
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). More...
 
void adxl345_set_range_resolution (struct adxl345_dev *dev, uint8_t g_range, uint8_t full_res)
 Selects the measurement range. More...
 

Detailed Description

Header file of ADXL345 Driver.

Author
DBogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2012(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ ADXL345_ACT_ACDC

#define ADXL345_ACT_ACDC   (1 << 7)

◆ ADXL345_ACT_INACT_CTL

#define ADXL345_ACT_INACT_CTL   0x27

◆ ADXL345_ACT_TAP_STATUS

#define ADXL345_ACT_TAP_STATUS   0x2B

◆ ADXL345_ACT_X_EN

#define ADXL345_ACT_X_EN   (1 << 6)

◆ ADXL345_ACT_X_SRC

#define ADXL345_ACT_X_SRC   (1 << 6)

◆ ADXL345_ACT_Y_EN

#define ADXL345_ACT_Y_EN   (1 << 5)

◆ ADXL345_ACT_Y_SRC

#define ADXL345_ACT_Y_SRC   (1 << 5)

◆ ADXL345_ACT_Z_EN

#define ADXL345_ACT_Z_EN   (1 << 4)

◆ ADXL345_ACT_Z_SRC

#define ADXL345_ACT_Z_SRC   (1 << 4)

◆ ADXL345_ACTIVITY

#define ADXL345_ACTIVITY   (1 << 4)

◆ ADXL345_ADDRESS

#define ADXL345_ADDRESS   0x1D

◆ ADXL345_ASLEEP

#define ADXL345_ASLEEP   (1 << 3)

◆ ADXL345_BW_RATE

#define ADXL345_BW_RATE   0x2C

◆ ADXL345_DATA_FORMAT

#define ADXL345_DATA_FORMAT   0x31

◆ ADXL345_DATA_READY

#define ADXL345_DATA_READY   (1 << 7)

◆ ADXL345_DATAX0

#define ADXL345_DATAX0   0x32

◆ ADXL345_DATAX1

#define ADXL345_DATAX1   0x33

◆ ADXL345_DATAY0

#define ADXL345_DATAY0   0x34

◆ ADXL345_DATAY1

#define ADXL345_DATAY1   0x35

◆ ADXL345_DATAZ0

#define ADXL345_DATAZ0   0x36

◆ ADXL345_DATAZ1

#define ADXL345_DATAZ1   0x37

◆ ADXL345_DEAD_ZONE

#define ADXL345_DEAD_ZONE (   x)    (((x) & 0x7) << 4)

◆ ADXL345_DEVID

#define ADXL345_DEVID   0x00

◆ ADXL345_DIVISOR

#define ADXL345_DIVISOR (   x)    ((x) & 7)

◆ ADXL345_DOUBLE_TAP

#define ADXL345_DOUBLE_TAP   (1 << 5)

◆ ADXL345_DUR

#define ADXL345_DUR   0x21

◆ ADXL345_ENTRIES

#define ADXL345_ENTRIES (   x)    ((x) & 0x3F)

◆ ADXL345_FIFO_BYPASS

#define ADXL345_FIFO_BYPASS   0

◆ ADXL345_FIFO_CTL

#define ADXL345_FIFO_CTL   0x38

◆ ADXL345_FIFO_FIFO

#define ADXL345_FIFO_FIFO   1

◆ ADXL345_FIFO_MODE

#define ADXL345_FIFO_MODE (   x)    (((x) & 0x3) << 6)

◆ ADXL345_FIFO_STATUS

#define ADXL345_FIFO_STATUS   0x39

◆ ADXL345_FIFO_STREAM

#define ADXL345_FIFO_STREAM   2

◆ ADXL345_FIFO_TRIG

#define ADXL345_FIFO_TRIG   (1 << 7)

◆ ADXL345_FIFO_TRIGGER

#define ADXL345_FIFO_TRIGGER   3

◆ ADXL345_FREE_FALL

#define ADXL345_FREE_FALL   (1 << 2)

◆ ADXL345_FULL_RES

#define ADXL345_FULL_RES   (1 << 3)

◆ ADXL345_I2C_COMM

#define ADXL345_I2C_COMM   1

◆ ADXL345_ID

#define ADXL345_ID   0xE5

◆ ADXL345_INACT_ACDC

#define ADXL345_INACT_ACDC   (1 << 3)

◆ ADXL345_INACT_X_EN

#define ADXL345_INACT_X_EN   (1 << 2)

◆ ADXL345_INACT_Y_EN

#define ADXL345_INACT_Y_EN   (1 << 1)

◆ ADXL345_INACT_Z_EN

#define ADXL345_INACT_Z_EN   (1 << 0)

◆ ADXL345_INACTIVITY

#define ADXL345_INACTIVITY   (1 << 3)

◆ ADXL345_INT_3D

#define ADXL345_INT_3D (   x)    (((x) & 0x1) << 3)

◆ ADXL345_INT_ENABLE

#define ADXL345_INT_ENABLE   0x2E

◆ ADXL345_INT_INVERT

#define ADXL345_INT_INVERT   (1 << 5)

◆ ADXL345_INT_MAP

#define ADXL345_INT_MAP   0x2F

◆ ADXL345_INT_ORIENT

#define ADXL345_INT_ORIENT (   x)    (((x) & 0x1) << 7)

◆ ADXL345_INT_SOURCE

#define ADXL345_INT_SOURCE   0x30

◆ ADXL345_JUSTIFY

#define ADXL345_JUSTIFY   (1 << 2)

◆ ADXL345_LATENT

#define ADXL345_LATENT   0x22

◆ ADXL345_LOW_POWER

#define ADXL345_LOW_POWER   (1 << 4)

◆ ADXL345_OFSX

#define ADXL345_OFSX   0x1E

◆ ADXL345_OFSY

#define ADXL345_OFSY   0x1F

◆ ADXL345_OFSZ

#define ADXL345_OFSZ   0x20

◆ ADXL345_ORIENT

#define ADXL345_ORIENT   0x3C

◆ ADXL345_ORIENT_CONF

#define ADXL345_ORIENT_CONF   0x3B

◆ ADXL345_ORIENTATION

#define ADXL345_ORIENTATION   (1 << 0)

◆ ADXL345_OVERRUN

#define ADXL345_OVERRUN   (1 << 0)

◆ ADXL345_PCTL_AUTO_SLEEP

#define ADXL345_PCTL_AUTO_SLEEP   (1 << 4)

◆ ADXL345_PCTL_LINK

#define ADXL345_PCTL_LINK   (1 << 5)

◆ ADXL345_PCTL_MEASURE

#define ADXL345_PCTL_MEASURE   (1 << 3)

◆ ADXL345_PCTL_SLEEP

#define ADXL345_PCTL_SLEEP   (1 << 2)

◆ ADXL345_PCTL_WAKEUP

#define ADXL345_PCTL_WAKEUP (   x)    ((x) & 0x3)

◆ ADXL345_POWER_CTL

#define ADXL345_POWER_CTL   0x2D

◆ ADXL345_RANGE

#define ADXL345_RANGE (   x)    ((x) & 0x3)

◆ ADXL345_RANGE_PM_16G

#define ADXL345_RANGE_PM_16G   3

◆ ADXL345_RANGE_PM_2G

#define ADXL345_RANGE_PM_2G   0

◆ ADXL345_RANGE_PM_4G

#define ADXL345_RANGE_PM_4G   1

◆ ADXL345_RANGE_PM_8G

#define ADXL345_RANGE_PM_8G   2

◆ ADXL345_RATE

#define ADXL345_RATE (   x)    ((x) & 0xF)

◆ ADXL345_SAMPLES

#define ADXL345_SAMPLES (   x)    ((x) & 0x1F)

◆ ADXL345_SCALE_FACTOR

#define ADXL345_SCALE_FACTOR   0.0039

◆ ADXL345_SELF_TEST

#define ADXL345_SELF_TEST   (1 << 7)

◆ ADXL345_SINGLE_TAP

#define ADXL345_SINGLE_TAP   (1 << 6)

◆ ADXL345_SPI

#define ADXL345_SPI   (1 << 6)

◆ ADXL345_SPI_COMM

#define ADXL345_SPI_COMM   0

◆ ADXL345_SPI_MB

#define ADXL345_SPI_MB   (1 << 6)

◆ ADXL345_SPI_READ

#define ADXL345_SPI_READ   (1 << 7)

◆ ADXL345_SPI_WRITE

#define ADXL345_SPI_WRITE   (0 << 7)

◆ ADXL345_SUPPRESS

#define ADXL345_SUPPRESS   (1 << 3)

◆ ADXL345_TAP_AXES

#define ADXL345_TAP_AXES   0x2A

◆ ADXL345_TAP_SIGN

#define ADXL345_TAP_SIGN   0x3A

◆ ADXL345_TAP_X_EN

#define ADXL345_TAP_X_EN   (1 << 2)

◆ ADXL345_TAP_X_SRC

#define ADXL345_TAP_X_SRC   (1 << 2)

◆ ADXL345_TAP_Y_EN

#define ADXL345_TAP_Y_EN   (1 << 1)

◆ ADXL345_TAP_Y_SRC

#define ADXL345_TAP_Y_SRC   (1 << 1)

◆ ADXL345_TAP_Z_EN

#define ADXL345_TAP_Z_EN   (1 << 0)

◆ ADXL345_TAP_Z_SRC

#define ADXL345_TAP_Z_SRC   (1 << 0)

◆ ADXL345_THRESH_ACT

#define ADXL345_THRESH_ACT   0x24

◆ ADXL345_THRESH_FF

#define ADXL345_THRESH_FF   0x28

◆ ADXL345_THRESH_INACT

#define ADXL345_THRESH_INACT   0x25

◆ ADXL345_THRESH_TAP

#define ADXL345_THRESH_TAP   0x1D

◆ ADXL345_TIME_FF

#define ADXL345_TIME_FF   0x29

◆ ADXL345_TIME_INACT

#define ADXL345_TIME_INACT   0x26

◆ ADXL345_TRIGGER

#define ADXL345_TRIGGER   (1 << 5)

◆ ADXL345_WATERMARK

#define ADXL345_WATERMARK   (1 << 1)

◆ ADXL345_WINDOW

#define ADXL345_WINDOW   0x23

◆ ADXL346_ID

#define ADXL346_ID   0xE6

Enumeration Type Documentation

◆ adxl345_dead_zone_angle

ADXL346 Dead zone angle encoding.

Enumerator
DEGREES_5_1 
DEGREES_10_2 
DEGREES_15_2 
DEGREES_20_4 
DEGREES_25_5 
DEGREES_30_8 
DEGREES_36_1 
DEGREES_41_4 

◆ adxl345_divisor_bandwidth

ADXL346 Divisor bandwidth encoding.

Enumerator
ODR_DIV_9 
ODR_DIV_22 
ODR_DIV_50 
ODR_DIV_100 
ODR_DIV_200 
ODR_DIV_400 
ODR_DIV_800 
ODR_DIV_1600 

◆ adxl345_type

ADXL345 Supported devices.

Enumerator
ID_ADXL345 
ID_ADXL346 

Function Documentation

◆ adxl345_get_g_xyz()

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.

Reads the raw output data of each axis and converts it to g.

Parameters
dev- The device structure.
x- X-axis's output data.
y- Y-axis's output data.
z- Z-axis's output data.
Returns
None.

◆ adxl345_get_register_value()

uint8_t adxl345_get_register_value ( struct adxl345_dev dev,
uint8_t  register_address 
)

Reads the value of a register.

Reads the value of a register.

Parameters
dev- The device structure.
register_address- Address of the register.
Returns
register_value - Value of the register.
Here is the caller graph for this function:

◆ adxl345_get_xyz()

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.

Reads the raw output data of each axis.

Parameters
dev- The device structure.
x- X-axis's output data.
y- Y-axis's output data.
z- Z-axis's output data.
Returns
None.
Here is the caller graph for this function:

◆ adxl345_init()

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.

Init. the comm. peripheral and checks if the ADXL345 part is present.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
status - Result of the initialization procedure. Example: -1 - I2C/SPI peripheral was not initialized or ADXL345 part is not present. 0 - I2C/SPI peripheral is initialized and ADXL345 part is present.

◆ adxl345_remove()

int32_t adxl345_remove ( struct adxl345_dev dev)

Free the resources allocated by adxl345_init().

Free the resources allocated by adxl345_init().

Parameters
dev- The device structure.
Returns
ret - The result of the remove procedure.

◆ adxl345_set_activity_detection()

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.

Enables/disables the activity detection.

Parameters
dev- The device structure.
act_on_off- Enables/disables the activity detection. Example: 0x0 - disables the activity detection. 0x1 - enables the activity detection.
act_axes- Axes which participate in detecting activity. Example: 0x0 - disables axes participation. ADXL345_ACT_X_EN - enables x-axis participation. ADXL345_ACT_Y_EN - enables y-axis participation. ADXL345_ACT_Z_EN - enables z-axis participation.
act_ac_dc- Selects dc-coupled or ac-coupled operation. Example: 0x0 - dc-coupled operation. ADXL345_ACT_ACDC - ac-coupled operation.
act_thresh- Threshold value for detecting activity. The scale factor is 62.5 mg/LSB.
act_int- Interrupts pin. Example: 0x0 - activity interrupts on INT1 pin. ADXL345_ACTIVITY - activity interrupts on INT2 pin.
Returns
None.

◆ adxl345_set_free_fall_detection()

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.

Enables/disables the free-fall detection.

Parameters
dev- The device structure.
ff_on_off- Enables/disables the free-fall detection. Example: 0x0 - disables the free-fall detection. 0x1 - enables the free-fall detection.
ff_thresh- Threshold value for free-fall detection. The scale factor is 62.5 mg/LSB.
ff_time- Time value for free-fall detection. The scale factor is 5 ms/LSB.
ff_int- Interrupts pin. Example: 0x0 - free-fall interrupts on INT1 pin. ADXL345_FREE_FALL - free-fall interrupts on INT2 pin.
Returns
None.

◆ adxl345_set_inactivity_detection()

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.

Enables/disables the inactivity detection.

Parameters
dev- The device structure.
inact_on_off- Enables/disables the inactivity detection. Example: 0x0 - disables the inactivity detection. 0x1 - enables the inactivity detection.
inact_axes- Axes which participate in detecting inactivity. Example: 0x0 - disables axes participation. ADXL345_INACT_X_EN - enables x-axis. ADXL345_INACT_Y_EN - enables y-axis. ADXL345_INACT_Z_EN - enables z-axis.
inact_ac_dc- Selects dc-coupled or ac-coupled operation. Example: 0x0 - dc-coupled operation. ADXL345_INACT_ACDC - ac-coupled operation.
inact_thresh- Threshold value for detecting inactivity. The scale factor is 62.5 mg/LSB.
inact_time- Inactivity time. The scale factor is 1 sec/LSB.
inact_int- Interrupts pin. Example: 0x0 - inactivity interrupts on INT1 pin. ADXL345_INACTIVITY - inactivity interrupts on INT2 pin.
Returns
None.

◆ adxl345_set_offset()

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).

Sets an offset value for each axis (Offset Calibration).

Parameters
dev- The device structure.
x_offset- X-axis's offset.
y_offset- Y-axis's offset.
z_offset- Z-axis's offset.
Returns
None.

◆ adxl345_set_orientation_detection()

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).

Enables/disables the orientation detection.

Parameters
dev- The device structure.
orient_int- Interrupts pin. Example: 0x0 - orientation interrupts on INT1 pin. ADXL345_ORIENTATION - orientation interrupts on INT2 pin.
orient_on_off- Enables/disables the orientation detection. Example: 0x0 - disables the orientation detection. 0x1 - enables the orientation detection.
int_3d- Enables/disables the 3d orientation detection. Example: 0x0 - disables the 3d orientation detection (enables 2d orientation detection). 0x1 - enables the 3d orientation detection (disables 2d orientation detection).
dead_zone- Dead zone angle encoding.
divisor- Bandwidth divisor encoding.
Returns
None.

◆ adxl345_set_power_mode()

void adxl345_set_power_mode ( struct adxl345_dev dev,
uint8_t  pwr_mode 
)

Places the device into standby/measure mode.

Places the device into standby/measure mode.

Parameters
dev- The device structure.
pwr_mode- Power mode. Example: 0x0 - standby mode. 0x1 - measure mode.
Returns
None.

◆ adxl345_set_range_resolution()

void adxl345_set_range_resolution ( struct adxl345_dev dev,
uint8_t  g_range,
uint8_t  full_res 
)

Selects the measurement range.

Selects the measurement range.

Parameters
dev- The device structure.
g_range- Range option. Example: ADXL345_RANGE_PM_2G - +-2 g ADXL345_RANGE_PM_4G - +-4 g ADXL345_RANGE_PM_8G - +-8 g ADXL345_RANGE_PM_16G - +-16 g
full_res- Full resolution option. Example: 0x0 - Disables full resolution. ADXL345_FULL_RES - Enables full resolution.
Returns
None.

◆ adxl345_set_register_value()

void adxl345_set_register_value ( struct adxl345_dev dev,
uint8_t  register_address,
uint8_t  register_value 
)

Writes data into a register.

Writes data into a register.

Parameters
dev- The device structure.
register_address- Address of the register.
register_value- Data value to write.
Returns
None.
Here is the caller graph for this function:

◆ adxl345_set_tap_detection()

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.

Enables/disables the tap detection.

Parameters
dev- The device structure.
tap_type- Tap type (none, single, double). Example: 0x0 - disables tap detection. ADXL345_SINGLE_TAP - enables single tap detection. ADXL345_DOUBLE_TAP - enables double tap detection.
tap_axes- Axes which participate in tap detection. Example: 0x0 - disables axes participation. ADXL345_TAP_X_EN - enables x-axis participation. ADXL345_TAP_Y_EN - enables y-axis participation. ADXL345_TAP_Z_EN - enables z-axis participation.
tap_dur- Tap duration. The scale factor is 625us is/LSB.
tap_latent- Tap latency. The scale factor is 1.25 ms/LSB.
tap_window- Tap window. The scale factor is 1.25 ms/LSB.
tap_thresh- Tap threshold. The scale factor is 62.5 mg/LSB.
tap_int- Interrupts pin. Example: 0x0 - interrupts on INT1 pin. ADXL345_SINGLE_TAP - single tap interrupts on INT2 pin. ADXL345_DOUBLE_TAP - double tap interrupts on INT2 pin.
Returns
None.