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

Header file of ADXL313 Driver. More...

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

Go to the source code of this file.

Classes

struct  adxl313_comm_init_param
 Structure holding the parameters for ADXL313 communication initialization. More...
 
struct  adxl313_frac_repr
 Data format in which the acceleration values are converted. More...
 
struct  adxl313_init_param
 Structure holding the parameters for ADXL313 device initialization. More...
 
struct  _adxl313_int_reg_flags
 Structure holding the flags for ADXL313 interrupt sources. More...
 
union  adxl313_int_en_reg_flags
 Union holding the flags for ADXL313 interrupt enable. More...
 
union  adxl313_int_map_reg_flags
 Union holding the flags for ADXL313 interrupt mapping. More...
 
union  adxl313_int_src_reg_flags
 Union holding the flags for ADXL313 interrupt source. More...
 
struct  _adxl313_act_inact_ctl_flags
 Structure holding the flags corresponding to ACT AC/DC and INACT AC/DC Bits. More...
 
union  adxl313_act_inact_ctl_flags
 Union holding the flags corresponding to ACT AC/DC and INACT AC/DC Bits. More...
 
union  adxl313_comm_desc
 Union holding the communication parameters. More...
 
struct  adxl313_dev
 ADXL313 Device structure. More...
 

Macros

#define ADXL313_SPI_READ   (0x80)
 
#define ADXL313_SPI_WRITE   (0x00)
 
#define ADXL313_MULTIBIT   NO_OS_BIT(6)
 
#define ADXL313_REG_DEVID_AD   0x00
 
#define ADXL313_REG_DEVID1_AD   0x01
 
#define ADXL313_REG_PARTID   0x02
 
#define ADXL313_REG_REVID   0x03
 
#define ADXL313_REG_XID   0x04
 
#define ADXL313_REG_SOFT_RESET   0x18
 
#define ADXL313_REG_OFS_AXIS(index)   (0x1E + (index))
 
#define ADXL313_REG_THRESH_ACT   0x24
 
#define ADXL313_REG_THRESH_INACT   0x25
 
#define ADXL313_REG_TIME_INACT   0x26
 
#define ADXL313_REG_ACT_INACT_CTL   0x27
 
#define ADXL313_REG_BW_RATE   0x2C
 
#define ADXL313_REG_POWER_CTL   0x2D
 
#define ADXL313_REG_INT_EN   0x2E
 
#define ADXL313_REG_INT_MAP   0x2F
 
#define ADXL313_REG_INT_SRC   0x30
 
#define ADXL313_REG_DATA_FORMAT   0x31
 
#define ADXL313_REG_DATA_AXIS(index)   (0x32 + ((index) * 2))
 
#define ADXL313_REG_FIFO_CTL   0x38
 
#define ADXL313_REG_FIFO_STATUS   0x39
 
#define ADXL313_DEVID   0xAD
 
#define ADXL313_DEVID1   0x1D
 
#define ADXL313_PARTID   0xCB
 
#define ADXL314_DEVID   0xE5
 
#define ADXL313_RESET_KEY   0x52
 
#define ADXL313_MAX_FIFO_SAMPLES_VAL   0x60
 
#define ADXL313_RATE_MSK   NO_OS_GENMASK(3, 0)
 
#define ADXL313_LOW_POWER_OP   NO_OS_BIT(4)
 
#define ADXL313_POWER_CTL_I2C_DISABLE   NO_OS_BIT(6)
 
#define ADXL313_POWER_CTL_LINK   NO_OS_BIT(5)
 
#define ADXL313_POWER_CTL_AUTO_SLEEP   NO_OS_BIT(4)
 
#define ADXL313_POWER_CTL_MEASURE   NO_OS_BIT(3)
 
#define ADXL313_POWER_CTL_SLEEP   NO_OS_BIT(2)
 
#define ADXL313_POWER_CTL_WAKEUP(x)   ((x) & 0x3)
 
#define ADXL313_REG_INT_EN_DATA_READY   NO_OS_BIT(7)
 
#define ADXL313_REG_INT_EN_ACTIVITY   NO_OS_BIT(4)
 
#define ADXL313_REG_INT_EN_INACTIVITY   NO_OS_BIT(3)
 
#define ADXL313_REG_INT_EN_WATERMARK   NO_OS_BIT(1)
 
#define ADXL313_REG_INT_EN_OVERRUN   NO_OS_BIT(0)
 
#define ADXL313_REG_INT_MAP_DR_INT2   NO_OS_BIT(7)
 
#define ADXL313_REG_INT_MAP_ACT_INT2   NO_OS_BIT(4)
 
#define ADXL313_REG_INT_MAP_INACT_INT2   NO_OS_BIT(3)
 
#define ADXL313_REG_INT_MAP_WM_INT2   NO_OS_BIT(1)
 
#define ADXL313_REG_INT_MAP_OVER_INT2   NO_OS_BIT(0)
 
#define ADXL313_REG_INT_SRC_DATA_READY   NO_OS_BIT(7)
 
#define ADXL313_REG_INT_SRC_ACTIVITY   NO_OS_BIT(4)
 
#define ADXL313_REG_INT_SRC_INACTIVITY   NO_OS_BIT(3)
 
#define ADXL313_REG_INT_SRC_WATERMARK   NO_OS_BIT(1)
 
#define ADXL313_REG_INT_SRC_OVERRUN   NO_OS_BIT(0)
 
#define ADXL313_REG_DATA_FORMAT_SELF_TEST   NO_OS_BIT(7)
 
#define ADXL313_REG_DATA_FORMAT_SPI_3WIRE   NO_OS_BIT(6)
 
#define ADXL313_REG_DATA_FORMAT_INT_INV   NO_OS_BIT(5)
 
#define ADXL313_REG_DATA_FORMAT_FULL_RES   NO_OS_BIT(3)
 
#define ADXL313_REG_DATA_FORMAT_JUSTIFY_BIT   NO_OS_BIT(2)
 
#define ADXL313_REG_DATA_FORMAT_RANGE   NO_OS_GENMASK(1, 0)
 
#define ADXL313_REG_FIFO_CTL_MODE_MSK   NO_OS_GENMASK(7, 6)
 
#define ADXL313_REG_FIFO_CTL_TRIGGER_BIT   NO_OS_BIT(5)
 
#define ADXL313_REG_FIFO_CTL_SAMPLES_MSK   NO_OS_GENMASK(4, 0)
 
#define ADXL313_REG_FIFO_FIFO_TRIGGER_BIT   NO_OS_BIT(7)
 
#define ADXL313_REG_FIFO_STS_ENTRIES_MSK   NO_OS_GENMASK(5, 0)
 
#define ADXL312_ACC_SCALE_FACTOR_MUL_FULL_RES   ((int64_t)28439285ULL)
 
#define ADXL313_ACC_SCALE_FACTOR_MUL_FULL_RES   ((int64_t)957680664ULL)
 
#define ADXL313_ACC_SCALE_FACTOR_MUL_DIVIDER   ((int32_t)100)
 
#define ADXL314_ACC_SCALE_FACTOR_MUL   ((int64_t)478858719ULL)
 
#define ADXL313_ACC_SCALE_FACTOR_DIV   ((int32_t)1000000000)
 
#define ADXL312_OFFSET_SCALE_FACTOR   11600
 
#define ADXL313_OFFSET_SCALE_FACTOR   3900
 
#define ADXL314_OFFSET_SCALE_FACTOR   195000
 
#define ADXL312_THRESH_SCALE_FACTOR   46400
 
#define ADXL313_THRESH_SCALE_FACTOR   15625
 
#define ADXL314_THRESH_SCALE_FACTOR   784000
 
#define ADXL313_ODR_OFFSET_VAL   6
 
#define ADXL313_REGS_PER_ENTRY   6
 
#define ADXL313_MAX_FIFO_ENTRIES   32
 
#define ADXL313_SELF_TEST_SAMPLES   10
 
#define ADXL312_SELF_TEST_MULT   2900
 
#define ADXL313_SELF_TEST_MULT   976
 
#define ADXL314_SELF_TEST_MULT   4883
 
#define ADXL313_SELF_TEST_DIV   1000
 
#define ADXL312_SELF_TEST_MIN_DEVIATION   300
 
#define ADXL312_SELF_TEST_MAX_DEVIATION   3400
 
#define ADXL313_SELF_TEST_MIN_DEVIATION   300
 
#define ADXL313_SELF_TEST_MAX_DEVIATION   3700
 
#define ADXL314_SELF_TEST_MIN_DEVIATION   100
 
#define ADXL314_SELF_TEST_MAX_DEVIATION   8000
 
#define ADXL313_RANGE_FACTOR   4
 
#define ADXL313_X_EN   NO_OS_BIT(1)
 
#define ADXL313_Y_EN   NO_OS_BIT(2)
 
#define ADXL313_Z_EN   NO_OS_BIT(3)
 

Enumerations

enum  adxl313_type {
  ID_ADXL312 = 0,
  ID_ADXL313 = 1,
  ID_ADXL314 = 2
}
 Enum for device type. More...
 
enum  adxl313_comm_type {
  ADXL313_SPI_COMM = 0,
  ADXL313_I2C_COMM = 1
}
 Enum for communication type. More...
 
enum  adxl313_op_mode {
  ADXL313_STDBY = 0,
  ADXL313_MEAS = 1
}
 Enum for operating mode. More...
 
enum  adxl313_lp_mode {
  ADXL313_LP_MODE_NONE = 0,
  ADXL313_LP_MODE_ON = 1,
  ADXL313_LP_MODE_AUTOSLEEP = 2
}
 Enum for low power operating mode. More...
 
enum  adxl313_wake_up_f {
  ADXL313_WU_8_HZ = 0,
  ADXL313_WU_4_HZ = 1,
  ADXL313_WU_2_HZ = 2,
  ADXL313_WU_1_HZ = 3
}
 Enum for frequency of wake-up events during sleep. More...
 
enum  adxl313_range {
  ADXL313_0_5G_RANGE = 0,
  ADXL313_1G_RANGE = 1,
  ADXL313_2G_RANGE = 2,
  ADXL313_4G_RANGE = 3,
  ADXL313_1_5G_RANGE = 4,
  ADXL313_3G_RANGE = 5,
  ADXL313_6G_RANGE = 6,
  ADXL313_12G_RANGE = 7,
  ADXL313_200G_RANGE = 8
}
 Enum for selecting range. More...
 
enum  adxl313_resolution {
  ADXL313_10_BIT_RES = 0,
  ADXL313_11_BIT_RES = 1,
  ADXL313_12_BIT_RES = 2,
  ADXL313_13_BIT_RES = 3
}
 Enum for specifying resolution. More...
 
enum  adxl313_odr {
  ADXL313_ODR_6_25HZ = 0,
  ADXL313_ODR_12_5HZ = 1,
  ADXL313_ODR_25HZ = 2,
  ADXL313_ODR_50HZ = 3,
  ADXL313_ODR_100HZ = 4,
  ADXL313_ODR_200HZ = 5,
  ADXL313_ODR_400HZ = 6,
  ADXL313_ODR_800HZ = 7,
  ADXL313_ODR_1600HZ = 8,
  ADXL313_ODR_3200HZ = 9
}
 Enum for selecting output data rate. More...
 
enum  adxl313_axis {
  ADXL313_X_AXIS = 0,
  ADXL313_Y_AXIS = 1,
  ADXL313_Z_AXIS = 2
}
 Enum for accelerometer axis. More...
 
enum  adxl313_fifo_mode {
  ADXL313_BYPAS_MODE = 0,
  ADXL313_FIFO_MODE = 1,
  ADXL313_STREAM_MODE = 2,
  ADXL313_TRIGGERED_MODE = 3
}
 Enum for selecting FIFO operating mode. More...
 
enum  adxl313_int_pol {
  ADXL313_INT_ACTIVE_HIGH = 0,
  ADXL313_INT_ACTIVE_LOW = 1
}
 Enum for selecting interrupt polarity. More...
 
enum  bit_action {
  DISABLE_E = 0,
  ENABLE_E = 1
}
 Enum for selecting Set/Reset bit action. More...
 

Functions

int adxl313_init (struct adxl313_dev **device, struct adxl313_init_param init_param)
 
int adxl313_remove (struct adxl313_dev *dev)
 
int adxl313_software_reset (struct adxl313_dev *dev)
 
int adxl313_set_op_mode (struct adxl313_dev *dev, enum adxl313_op_mode op_mode)
 
int adxl313_get_op_mode (struct adxl313_dev *dev, enum adxl313_op_mode *op_mode)
 
int adxl313_set_offset (struct adxl313_dev *dev, int32_t offset_ug, enum adxl313_axis axis)
 
int adxl313_get_offset (struct adxl313_dev *dev, int32_t *offset_ug, enum adxl313_axis axis)
 
int adxl313_get_raw_xyz (struct adxl313_dev *dev, int16_t *x_raw, int16_t *y_raw, int16_t *z_raw)
 
int adxl313_get_xyz (struct adxl313_dev *dev, struct adxl313_frac_repr *x_m_s2, struct adxl313_frac_repr *y_m_s2, struct adxl313_frac_repr *z_m_s2)
 
int adxl313_get_no_of_fifo_entries (struct adxl313_dev *dev, uint8_t *entries_no)
 
int adxl313_set_fifo_samples (struct adxl313_dev *dev, uint8_t samples_no)
 
int adxl313_set_fifo_mode (struct adxl313_dev *dev, enum adxl313_fifo_mode mode)
 
int adxl313_get_raw_fifo_data (struct adxl313_dev *dev, uint8_t *entries, int16_t *x_raw, int16_t *y_raw, int16_t *z_raw)
 
int adxl313_get_fifo_data (struct adxl313_dev *dev, uint8_t *entries, struct adxl313_frac_repr *x, struct adxl313_frac_repr *y, struct adxl313_frac_repr *z)
 
int adxl313_conf_act_thr (struct adxl313_dev *dev, uint32_t act_thr_ug)
 
int adxl313_get_act_thr (struct adxl313_dev *dev, uint32_t *act_thr_ug)
 
int adxl313_conf_inact_thr (struct adxl313_dev *dev, uint32_t inact_thr_ug)
 
int adxl313_get_inact_thr (struct adxl313_dev *dev, uint32_t *inact_thr_ug)
 
int adxl313_conf_time_inact (struct adxl313_dev *dev, uint8_t time_inact_s)
 
int adxl313_get_time_inact (struct adxl313_dev *dev, uint8_t *time_inact_s)
 
int adxl313_conf_act_inact_ctl (struct adxl313_dev *dev, union adxl313_act_inact_ctl_flags config)
 
int adxl313_get_conf_act_inact_ctl (struct adxl313_dev *dev, union adxl313_act_inact_ctl_flags *config)
 
int adxl313_set_activity_detection (struct adxl313_dev *dev, uint8_t act_axes, uint8_t act_ac_dc, uint32_t act_thresh_ug, uint8_t int_pin)
 Enable the activity detection. More...
 
int adxl313_set_inactivity_detection (struct adxl313_dev *dev, uint8_t inact_axes, uint8_t inact_ac_dc, uint32_t inact_thresh_ug, uint8_t inact_time, uint8_t int_pin)
 Enables the inactivity detection. More...
 
int adxl313_set_odr (struct adxl313_dev *dev, enum adxl313_odr odr)
 
int adxl313_get_odr (struct adxl313_dev *dev, enum adxl313_odr *odr)
 
int adxl313_disable_i2c (struct adxl313_dev *dev)
 
int adxl313_enable_i2c (struct adxl313_dev *dev)
 
int adxl313_set_low_power_mode (struct adxl313_dev *dev, enum bit_action enable)
 
int adxl313_set_autosleep_mode (struct adxl313_dev *dev, enum bit_action enable, uint8_t inact_thr, uint8_t time_inact_s)
 
int adxl313_link_mode_enable (struct adxl313_dev *dev)
 
int adxl313_link_mode_disable (struct adxl313_dev *dev)
 
int adxl313_sleep (struct adxl313_dev *dev, enum adxl313_wake_up_f wake_up_f_hz)
 
int adxl313_exit_sleep (struct adxl313_dev *dev)
 
int adxl313_conf_int_enable (struct adxl313_dev *dev, union adxl313_int_en_reg_flags en_ctl)
 
int adxl313_activity_int_enable (struct adxl313_dev *dev)
 
int adxl313_activity_int_disable (struct adxl313_dev *dev)
 
int adxl313_inactivity_int_enable (struct adxl313_dev *dev)
 
int adxl313_inactivity_int_disable (struct adxl313_dev *dev)
 
int adxl313_conf_int_map (struct adxl313_dev *dev, union adxl313_int_map_reg_flags int_map)
 
int adxl313_data_ready_int_map (struct adxl313_dev *dev, uint8_t int_pin)
 
int adxl313_activity_int_map (struct adxl313_dev *dev, uint8_t int_pin)
 
int adxl313_inactivity_int_map (struct adxl313_dev *dev, uint8_t int_pin)
 
int adxl313_watermark_int_map (struct adxl313_dev *dev, uint8_t int_pin)
 
int adxl313_overrun_int_map (struct adxl313_dev *dev, uint8_t int_pin)
 
int adxl313_get_int_source_reg (struct adxl313_dev *dev, union adxl313_int_src_reg_flags *int_status_flags)
 
int adxl313_set_int_pol (struct adxl313_dev *dev, enum adxl313_int_pol int_pol)
 
int adxl313_enable_full_res (struct adxl313_dev *dev)
 
int adxl313_disable_full_res (struct adxl313_dev *dev)
 
int adxl313_get_full_res_setting (struct adxl313_dev *dev, uint8_t *full_res)
 
int adxl313_set_range (struct adxl313_dev *dev, enum adxl313_range range)
 
int adxl313_get_range (struct adxl313_dev *dev, enum adxl313_range *range)
 
int adxl313_self_test (struct adxl313_dev *dev)
 

Detailed Description

Header file of ADXL313 Driver.

Author
GMois (georg.nosp@m.e.mo.nosp@m.is@an.nosp@m.alog.nosp@m..com)

Copyright 2022(c) Analog Devices, Inc.

All rights reserved.

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

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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

◆ ADXL312_ACC_SCALE_FACTOR_MUL_FULL_RES

#define ADXL312_ACC_SCALE_FACTOR_MUL_FULL_RES   ((int64_t)28439285ULL)

◆ ADXL312_OFFSET_SCALE_FACTOR

#define ADXL312_OFFSET_SCALE_FACTOR   11600

◆ ADXL312_SELF_TEST_MAX_DEVIATION

#define ADXL312_SELF_TEST_MAX_DEVIATION   3400

◆ ADXL312_SELF_TEST_MIN_DEVIATION

#define ADXL312_SELF_TEST_MIN_DEVIATION   300

◆ ADXL312_SELF_TEST_MULT

#define ADXL312_SELF_TEST_MULT   2900

◆ ADXL312_THRESH_SCALE_FACTOR

#define ADXL312_THRESH_SCALE_FACTOR   46400

◆ ADXL313_ACC_SCALE_FACTOR_DIV

#define ADXL313_ACC_SCALE_FACTOR_DIV   ((int32_t)1000000000)

◆ ADXL313_ACC_SCALE_FACTOR_MUL_DIVIDER

#define ADXL313_ACC_SCALE_FACTOR_MUL_DIVIDER   ((int32_t)100)

◆ ADXL313_ACC_SCALE_FACTOR_MUL_FULL_RES

#define ADXL313_ACC_SCALE_FACTOR_MUL_FULL_RES   ((int64_t)957680664ULL)

◆ ADXL313_DEVID

#define ADXL313_DEVID   0xAD

◆ ADXL313_DEVID1

#define ADXL313_DEVID1   0x1D

◆ ADXL313_LOW_POWER_OP

#define ADXL313_LOW_POWER_OP   NO_OS_BIT(4)

◆ ADXL313_MAX_FIFO_ENTRIES

#define ADXL313_MAX_FIFO_ENTRIES   32

◆ ADXL313_MAX_FIFO_SAMPLES_VAL

#define ADXL313_MAX_FIFO_SAMPLES_VAL   0x60

◆ ADXL313_MULTIBIT

#define ADXL313_MULTIBIT   NO_OS_BIT(6)

◆ ADXL313_ODR_OFFSET_VAL

#define ADXL313_ODR_OFFSET_VAL   6

◆ ADXL313_OFFSET_SCALE_FACTOR

#define ADXL313_OFFSET_SCALE_FACTOR   3900

◆ ADXL313_PARTID

#define ADXL313_PARTID   0xCB

◆ ADXL313_POWER_CTL_AUTO_SLEEP

#define ADXL313_POWER_CTL_AUTO_SLEEP   NO_OS_BIT(4)

◆ ADXL313_POWER_CTL_I2C_DISABLE

#define ADXL313_POWER_CTL_I2C_DISABLE   NO_OS_BIT(6)

◆ ADXL313_POWER_CTL_LINK

#define ADXL313_POWER_CTL_LINK   NO_OS_BIT(5)

◆ ADXL313_POWER_CTL_MEASURE

#define ADXL313_POWER_CTL_MEASURE   NO_OS_BIT(3)

◆ ADXL313_POWER_CTL_SLEEP

#define ADXL313_POWER_CTL_SLEEP   NO_OS_BIT(2)

◆ ADXL313_POWER_CTL_WAKEUP

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

◆ ADXL313_RANGE_FACTOR

#define ADXL313_RANGE_FACTOR   4

◆ ADXL313_RATE_MSK

#define ADXL313_RATE_MSK   NO_OS_GENMASK(3, 0)

◆ ADXL313_REG_ACT_INACT_CTL

#define ADXL313_REG_ACT_INACT_CTL   0x27

◆ ADXL313_REG_BW_RATE

#define ADXL313_REG_BW_RATE   0x2C

◆ ADXL313_REG_DATA_AXIS

#define ADXL313_REG_DATA_AXIS (   index)    (0x32 + ((index) * 2))

◆ ADXL313_REG_DATA_FORMAT

#define ADXL313_REG_DATA_FORMAT   0x31

◆ ADXL313_REG_DATA_FORMAT_FULL_RES

#define ADXL313_REG_DATA_FORMAT_FULL_RES   NO_OS_BIT(3)

◆ ADXL313_REG_DATA_FORMAT_INT_INV

#define ADXL313_REG_DATA_FORMAT_INT_INV   NO_OS_BIT(5)

◆ ADXL313_REG_DATA_FORMAT_JUSTIFY_BIT

#define ADXL313_REG_DATA_FORMAT_JUSTIFY_BIT   NO_OS_BIT(2)

◆ ADXL313_REG_DATA_FORMAT_RANGE

#define ADXL313_REG_DATA_FORMAT_RANGE   NO_OS_GENMASK(1, 0)

◆ ADXL313_REG_DATA_FORMAT_SELF_TEST

#define ADXL313_REG_DATA_FORMAT_SELF_TEST   NO_OS_BIT(7)

◆ ADXL313_REG_DATA_FORMAT_SPI_3WIRE

#define ADXL313_REG_DATA_FORMAT_SPI_3WIRE   NO_OS_BIT(6)

◆ ADXL313_REG_DEVID1_AD

#define ADXL313_REG_DEVID1_AD   0x01

◆ ADXL313_REG_DEVID_AD

#define ADXL313_REG_DEVID_AD   0x00

◆ ADXL313_REG_FIFO_CTL

#define ADXL313_REG_FIFO_CTL   0x38

◆ ADXL313_REG_FIFO_CTL_MODE_MSK

#define ADXL313_REG_FIFO_CTL_MODE_MSK   NO_OS_GENMASK(7, 6)

◆ ADXL313_REG_FIFO_CTL_SAMPLES_MSK

#define ADXL313_REG_FIFO_CTL_SAMPLES_MSK   NO_OS_GENMASK(4, 0)

◆ ADXL313_REG_FIFO_CTL_TRIGGER_BIT

#define ADXL313_REG_FIFO_CTL_TRIGGER_BIT   NO_OS_BIT(5)

◆ ADXL313_REG_FIFO_FIFO_TRIGGER_BIT

#define ADXL313_REG_FIFO_FIFO_TRIGGER_BIT   NO_OS_BIT(7)

◆ ADXL313_REG_FIFO_STATUS

#define ADXL313_REG_FIFO_STATUS   0x39

◆ ADXL313_REG_FIFO_STS_ENTRIES_MSK

#define ADXL313_REG_FIFO_STS_ENTRIES_MSK   NO_OS_GENMASK(5, 0)

◆ ADXL313_REG_INT_EN

#define ADXL313_REG_INT_EN   0x2E

◆ ADXL313_REG_INT_EN_ACTIVITY

#define ADXL313_REG_INT_EN_ACTIVITY   NO_OS_BIT(4)

◆ ADXL313_REG_INT_EN_DATA_READY

#define ADXL313_REG_INT_EN_DATA_READY   NO_OS_BIT(7)

◆ ADXL313_REG_INT_EN_INACTIVITY

#define ADXL313_REG_INT_EN_INACTIVITY   NO_OS_BIT(3)

◆ ADXL313_REG_INT_EN_OVERRUN

#define ADXL313_REG_INT_EN_OVERRUN   NO_OS_BIT(0)

◆ ADXL313_REG_INT_EN_WATERMARK

#define ADXL313_REG_INT_EN_WATERMARK   NO_OS_BIT(1)

◆ ADXL313_REG_INT_MAP

#define ADXL313_REG_INT_MAP   0x2F

◆ ADXL313_REG_INT_MAP_ACT_INT2

#define ADXL313_REG_INT_MAP_ACT_INT2   NO_OS_BIT(4)

◆ ADXL313_REG_INT_MAP_DR_INT2

#define ADXL313_REG_INT_MAP_DR_INT2   NO_OS_BIT(7)

◆ ADXL313_REG_INT_MAP_INACT_INT2

#define ADXL313_REG_INT_MAP_INACT_INT2   NO_OS_BIT(3)

◆ ADXL313_REG_INT_MAP_OVER_INT2

#define ADXL313_REG_INT_MAP_OVER_INT2   NO_OS_BIT(0)

◆ ADXL313_REG_INT_MAP_WM_INT2

#define ADXL313_REG_INT_MAP_WM_INT2   NO_OS_BIT(1)

◆ ADXL313_REG_INT_SRC

#define ADXL313_REG_INT_SRC   0x30

◆ ADXL313_REG_INT_SRC_ACTIVITY

#define ADXL313_REG_INT_SRC_ACTIVITY   NO_OS_BIT(4)

◆ ADXL313_REG_INT_SRC_DATA_READY

#define ADXL313_REG_INT_SRC_DATA_READY   NO_OS_BIT(7)

◆ ADXL313_REG_INT_SRC_INACTIVITY

#define ADXL313_REG_INT_SRC_INACTIVITY   NO_OS_BIT(3)

◆ ADXL313_REG_INT_SRC_OVERRUN

#define ADXL313_REG_INT_SRC_OVERRUN   NO_OS_BIT(0)

◆ ADXL313_REG_INT_SRC_WATERMARK

#define ADXL313_REG_INT_SRC_WATERMARK   NO_OS_BIT(1)

◆ ADXL313_REG_OFS_AXIS

#define ADXL313_REG_OFS_AXIS (   index)    (0x1E + (index))

◆ ADXL313_REG_PARTID

#define ADXL313_REG_PARTID   0x02

◆ ADXL313_REG_POWER_CTL

#define ADXL313_REG_POWER_CTL   0x2D

◆ ADXL313_REG_REVID

#define ADXL313_REG_REVID   0x03

◆ ADXL313_REG_SOFT_RESET

#define ADXL313_REG_SOFT_RESET   0x18

◆ ADXL313_REG_THRESH_ACT

#define ADXL313_REG_THRESH_ACT   0x24

◆ ADXL313_REG_THRESH_INACT

#define ADXL313_REG_THRESH_INACT   0x25

◆ ADXL313_REG_TIME_INACT

#define ADXL313_REG_TIME_INACT   0x26

◆ ADXL313_REG_XID

#define ADXL313_REG_XID   0x04

◆ ADXL313_REGS_PER_ENTRY

#define ADXL313_REGS_PER_ENTRY   6

◆ ADXL313_RESET_KEY

#define ADXL313_RESET_KEY   0x52

◆ ADXL313_SELF_TEST_DIV

#define ADXL313_SELF_TEST_DIV   1000

◆ ADXL313_SELF_TEST_MAX_DEVIATION

#define ADXL313_SELF_TEST_MAX_DEVIATION   3700

◆ ADXL313_SELF_TEST_MIN_DEVIATION

#define ADXL313_SELF_TEST_MIN_DEVIATION   300

◆ ADXL313_SELF_TEST_MULT

#define ADXL313_SELF_TEST_MULT   976

◆ ADXL313_SELF_TEST_SAMPLES

#define ADXL313_SELF_TEST_SAMPLES   10

◆ ADXL313_SPI_READ

#define ADXL313_SPI_READ   (0x80)

◆ ADXL313_SPI_WRITE

#define ADXL313_SPI_WRITE   (0x00)

◆ ADXL313_THRESH_SCALE_FACTOR

#define ADXL313_THRESH_SCALE_FACTOR   15625

◆ ADXL313_X_EN

#define ADXL313_X_EN   NO_OS_BIT(1)

◆ ADXL313_Y_EN

#define ADXL313_Y_EN   NO_OS_BIT(2)

◆ ADXL313_Z_EN

#define ADXL313_Z_EN   NO_OS_BIT(3)

◆ ADXL314_ACC_SCALE_FACTOR_MUL

#define ADXL314_ACC_SCALE_FACTOR_MUL   ((int64_t)478858719ULL)

◆ ADXL314_DEVID

#define ADXL314_DEVID   0xE5

◆ ADXL314_OFFSET_SCALE_FACTOR

#define ADXL314_OFFSET_SCALE_FACTOR   195000

◆ ADXL314_SELF_TEST_MAX_DEVIATION

#define ADXL314_SELF_TEST_MAX_DEVIATION   8000

◆ ADXL314_SELF_TEST_MIN_DEVIATION

#define ADXL314_SELF_TEST_MIN_DEVIATION   100

◆ ADXL314_SELF_TEST_MULT

#define ADXL314_SELF_TEST_MULT   4883

◆ ADXL314_THRESH_SCALE_FACTOR

#define ADXL314_THRESH_SCALE_FACTOR   784000

Enumeration Type Documentation

◆ adxl313_axis

Enum for accelerometer axis.

Enumerator
ADXL313_X_AXIS 
ADXL313_Y_AXIS 
ADXL313_Z_AXIS 

◆ adxl313_comm_type

Enum for communication type.

Enumerator
ADXL313_SPI_COMM 
ADXL313_I2C_COMM 

◆ adxl313_fifo_mode

Enum for selecting FIFO operating mode.

Enumerator
ADXL313_BYPAS_MODE 
ADXL313_FIFO_MODE 
ADXL313_STREAM_MODE 
ADXL313_TRIGGERED_MODE 

◆ adxl313_int_pol

Enum for selecting interrupt polarity.

Enumerator
ADXL313_INT_ACTIVE_HIGH 
ADXL313_INT_ACTIVE_LOW 

◆ adxl313_lp_mode

Enum for low power operating mode.

Enumerator
ADXL313_LP_MODE_NONE 
ADXL313_LP_MODE_ON 
ADXL313_LP_MODE_AUTOSLEEP 

◆ adxl313_odr

Enum for selecting output data rate.

Enumerator
ADXL313_ODR_6_25HZ 
ADXL313_ODR_12_5HZ 
ADXL313_ODR_25HZ 
ADXL313_ODR_50HZ 
ADXL313_ODR_100HZ 
ADXL313_ODR_200HZ 
ADXL313_ODR_400HZ 
ADXL313_ODR_800HZ 
ADXL313_ODR_1600HZ 
ADXL313_ODR_3200HZ 

◆ adxl313_op_mode

Enum for operating mode.

Enumerator
ADXL313_STDBY 
ADXL313_MEAS 

◆ adxl313_range

Enum for selecting range.

Enumerator
ADXL313_0_5G_RANGE 
ADXL313_1G_RANGE 
ADXL313_2G_RANGE 
ADXL313_4G_RANGE 
ADXL313_1_5G_RANGE 
ADXL313_3G_RANGE 
ADXL313_6G_RANGE 
ADXL313_12G_RANGE 
ADXL313_200G_RANGE 

◆ adxl313_resolution

Enum for specifying resolution.

Enumerator
ADXL313_10_BIT_RES 
ADXL313_11_BIT_RES 
ADXL313_12_BIT_RES 
ADXL313_13_BIT_RES 

◆ adxl313_type

Enum for device type.

Enumerator
ID_ADXL312 
ID_ADXL313 
ID_ADXL314 

◆ adxl313_wake_up_f

Enum for frequency of wake-up events during sleep.

Enumerator
ADXL313_WU_8_HZ 
ADXL313_WU_4_HZ 
ADXL313_WU_2_HZ 
ADXL313_WU_1_HZ 

◆ bit_action

enum bit_action

Enum for selecting Set/Reset bit action.

Enumerator
DISABLE_E 
ENABLE_E 

Function Documentation

◆ adxl313_activity_int_disable()

int adxl313_activity_int_disable ( struct adxl313_dev dev)

Configure interrupt disable control for activity.

◆ adxl313_activity_int_enable()

int adxl313_activity_int_enable ( struct adxl313_dev dev)

Configure interrupt enable control for activity.

Here is the caller graph for this function:

◆ adxl313_activity_int_map()

int adxl313_activity_int_map ( struct adxl313_dev dev,
uint8_t  int_pin 
)

Set pin for activity interrupt.

Here is the caller graph for this function:

◆ adxl313_conf_act_inact_ctl()

int adxl313_conf_act_inact_ctl ( struct adxl313_dev dev,
union adxl313_act_inact_ctl_flags  config 
)

Configure the ACT AC/DC and INACT AC/DC bits.

Here is the caller graph for this function:

◆ adxl313_conf_act_thr()

int adxl313_conf_act_thr ( struct adxl313_dev dev,
uint32_t  act_thr_ug 
)

Configure the activity threshold register.

Here is the caller graph for this function:

◆ adxl313_conf_inact_thr()

int adxl313_conf_inact_thr ( struct adxl313_dev dev,
uint32_t  inact_thr_ug 
)

Configure the inactivity threshold register.

Here is the caller graph for this function:

◆ adxl313_conf_int_enable()

int adxl313_conf_int_enable ( struct adxl313_dev dev,
union adxl313_int_en_reg_flags  en_ctl 
)

Configure interrupt enable control.

Here is the caller graph for this function:

◆ adxl313_conf_int_map()

int adxl313_conf_int_map ( struct adxl313_dev dev,
union adxl313_int_map_reg_flags  int_map 
)

Configure interrupt mapping control.

Here is the caller graph for this function:

◆ adxl313_conf_time_inact()

int adxl313_conf_time_inact ( struct adxl313_dev dev,
uint8_t  time_inact_s 
)

Configure the time inactivity threshold register.

Here is the caller graph for this function:

◆ adxl313_data_ready_int_map()

int adxl313_data_ready_int_map ( struct adxl313_dev dev,
uint8_t  int_pin 
)

Set pin for DATA_READY interrupt.

◆ adxl313_disable_full_res()

int adxl313_disable_full_res ( struct adxl313_dev dev)

Disable full resolution for the ADXL312/ADXL313 device.

Here is the caller graph for this function:

◆ adxl313_disable_i2c()

int adxl313_disable_i2c ( struct adxl313_dev dev)

Disable I2C.

◆ adxl313_enable_full_res()

int adxl313_enable_full_res ( struct adxl313_dev dev)

Enable full resolution for the ADXL312/ADXL313 device.

Here is the caller graph for this function:

◆ adxl313_enable_i2c()

int adxl313_enable_i2c ( struct adxl313_dev dev)

Enable I2C.

◆ adxl313_exit_sleep()

int adxl313_exit_sleep ( struct adxl313_dev dev)

Exit Sleep mode.

◆ adxl313_get_act_thr()

int adxl313_get_act_thr ( struct adxl313_dev dev,
uint32_t *  act_thr_ug 
)

Get the value saved in the activity threshold register.

◆ adxl313_get_conf_act_inact_ctl()

int adxl313_get_conf_act_inact_ctl ( struct adxl313_dev dev,
union adxl313_act_inact_ctl_flags config 
)

Get the ACT AC/DC and INACT AC/DC bits.

Here is the caller graph for this function:

◆ adxl313_get_fifo_data()

int adxl313_get_fifo_data ( struct adxl313_dev dev,
uint8_t *  entries,
struct adxl313_frac_repr x,
struct adxl313_frac_repr y,
struct adxl313_frac_repr z 
)

Read converted values from FIFO.

Here is the caller graph for this function:

◆ adxl313_get_full_res_setting()

int adxl313_get_full_res_setting ( struct adxl313_dev dev,
uint8_t *  full_res 
)

Get the ADXL312/ADXL313 FULL_RES setting.

Here is the caller graph for this function:

◆ adxl313_get_inact_thr()

int adxl313_get_inact_thr ( struct adxl313_dev dev,
uint32_t *  inact_thr_ug 
)

Get the value in the inactivity threshold register.

◆ adxl313_get_int_source_reg()

int adxl313_get_int_source_reg ( struct adxl313_dev dev,
union adxl313_int_src_reg_flags int_status_flags 
)

Read the INT_SOURCE register value.

Here is the caller graph for this function:

◆ adxl313_get_no_of_fifo_entries()

int adxl313_get_no_of_fifo_entries ( struct adxl313_dev dev,
uint8_t *  entries_no 
)

Read the number of FIFO entries register value.

Here is the caller graph for this function:

◆ adxl313_get_odr()

int adxl313_get_odr ( struct adxl313_dev dev,
enum adxl313_odr odr 
)

Get output data rate (ODR).

◆ adxl313_get_offset()

int adxl313_get_offset ( struct adxl313_dev dev,
int32_t *  offset_ug,
enum adxl313_axis  axis 
)

Get offset for each axis.

◆ adxl313_get_op_mode()

int adxl313_get_op_mode ( struct adxl313_dev dev,
enum adxl313_op_mode op_mode 
)

Get the current operation mode of the device.

◆ adxl313_get_range()

int adxl313_get_range ( struct adxl313_dev dev,
enum adxl313_range range 
)

Get the ADXL312/ADXL313 device range.

◆ adxl313_get_raw_fifo_data()

int adxl313_get_raw_fifo_data ( struct adxl313_dev dev,
uint8_t *  entries,
int16_t *  x_raw,
int16_t *  y_raw,
int16_t *  z_raw 
)

Read FIFO data and return the raw values.

Here is the caller graph for this function:

◆ adxl313_get_raw_xyz()

int adxl313_get_raw_xyz ( struct adxl313_dev dev,
int16_t *  x_raw,
int16_t *  y_raw,
int16_t *  z_raw 
)

Read the 3-axis raw data from the accelerometer.

Here is the caller graph for this function:

◆ adxl313_get_time_inact()

int adxl313_get_time_inact ( struct adxl313_dev dev,
uint8_t *  time_inact_s 
)

Get the value of the time inactivity threshold register.

◆ adxl313_get_xyz()

int adxl313_get_xyz ( struct adxl313_dev dev,
struct adxl313_frac_repr x_m_s2,
struct adxl313_frac_repr y_m_s2,
struct adxl313_frac_repr z_m_s2 
)

Read the raw output data of each axis and convert it to m/s^2.

Here is the caller graph for this function:

◆ adxl313_inactivity_int_disable()

int adxl313_inactivity_int_disable ( struct adxl313_dev dev)

Configure interrupt disable control for inactivity.

◆ adxl313_inactivity_int_enable()

int adxl313_inactivity_int_enable ( struct adxl313_dev dev)

Configure interrupt enable control for inactivity.

Here is the caller graph for this function:

◆ adxl313_inactivity_int_map()

int adxl313_inactivity_int_map ( struct adxl313_dev dev,
uint8_t  int_pin 
)

Set pin for inactivity interrupt.

Here is the caller graph for this function:

◆ adxl313_init()

int adxl313_init ( struct adxl313_dev **  device,
struct adxl313_init_param  init_param 
)

Init. the comm. peripheral and check if the ADXL313 is present.

Here is the caller graph for this function:

◆ adxl313_link_mode_disable()

int adxl313_link_mode_disable ( struct adxl313_dev dev)

Disable Link Mode for activity inactivity functions.

◆ adxl313_link_mode_enable()

int adxl313_link_mode_enable ( struct adxl313_dev dev)

Enable Link Mode for activity inactivity functions.

◆ adxl313_overrun_int_map()

int adxl313_overrun_int_map ( struct adxl313_dev dev,
uint8_t  int_pin 
)

Set pin for overrun interrupt.

◆ adxl313_remove()

int adxl313_remove ( struct adxl313_dev dev)

Free the resources allocated by adxl313_init().

Here is the caller graph for this function:

◆ adxl313_self_test()

int adxl313_self_test ( struct adxl313_dev dev)
Here is the caller graph for this function:

◆ adxl313_set_activity_detection()

int adxl313_set_activity_detection ( struct adxl313_dev dev,
uint8_t  act_axes,
uint8_t  act_ac_dc,
uint32_t  act_thresh_ug,
uint8_t  int_pin 
)

Enable the activity detection.

Enable activity detection.

Parameters
dev- The device structure.
act_axes- Axes which participate in detecting activity (ORed together). Example: 0x0 - disables axes participation. ADXL313_X_EN - enables x-axis participation. ADXL313_Y_EN - enables y-axis participation. ADXL313_Z_EN - enables z-axis participation.
act_ac_dc- Selects dc-coupled or ac-coupled operation. Example: 0x00 - dc-coupled operation. 0x01 - ac-coupled operation.
act_thresh_ug- Threshold value for detecting activity. The scale factor is 15625 ug/LSB for ADXL313 and 780000 ug/LSB for ADXL314.
int_pin- Interrupts pin. Example: 0x00 - activity interrupts on INT1 pin. 0x01 - activity interrupts on INT2 pin.
Returns
None.

◆ adxl313_set_autosleep_mode()

int adxl313_set_autosleep_mode ( struct adxl313_dev dev,
enum bit_action  enable,
uint8_t  inact_thr,
uint8_t  time_inact_s 
)

Activate/Deactivate AUTOSLEEP.

◆ adxl313_set_fifo_mode()

int adxl313_set_fifo_mode ( struct adxl313_dev dev,
enum adxl313_fifo_mode  mode 
)

Set FIFO mode.

Here is the caller graph for this function:

◆ adxl313_set_fifo_samples()

int adxl313_set_fifo_samples ( struct adxl313_dev dev,
uint8_t  samples_no 
)

Set the number of FIFO samples register value.

◆ adxl313_set_inactivity_detection()

int adxl313_set_inactivity_detection ( struct adxl313_dev dev,
uint8_t  inact_axes,
uint8_t  inact_ac_dc,
uint32_t  inact_thresh_ug,
uint8_t  inact_time_s,
uint8_t  int_pin 
)

Enables the inactivity detection.

Enable inactivity detection.

Parameters
dev- The device structure.
inact_axes- Axes which participate in detecting inactivity. Example: 0x0 - disables axes participation. ADXL313_X_EN - enables x-axis participation. ADXL313_Y_EN - enables y-axis participation. ADXL313_Z_EN - enables z-axis participation.
inact_ac_dc- Selects dc-coupled or ac-coupled operation. Example: 0x00 - dc-coupled operation. 0x01 - ac-coupled operation.
inact_thresh_ug- Threshold value for detecting inactivity. The scale factor is 62.5 mg/LSB.
inact_time_s- Inactivity time. The scale factor is 1 sec/LSB.
int_pin- Interrupts pin. Example: 0x00 - activity interrupts on INT1 pin. 0x01 - activity interrupts on INT2 pin.
Returns
None.
Here is the caller graph for this function:

◆ adxl313_set_int_pol()

int adxl313_set_int_pol ( struct adxl313_dev dev,
enum adxl313_int_pol  int_pol 
)

Configure the interrupt polarity.

◆ adxl313_set_low_power_mode()

int adxl313_set_low_power_mode ( struct adxl313_dev dev,
enum bit_action  enable 
)

Activate/Deactivate LOW_POWER.

Here is the caller graph for this function:

◆ adxl313_set_odr()

int adxl313_set_odr ( struct adxl313_dev dev,
enum adxl313_odr  odr 
)

Set output data rate (ODR).

Here is the caller graph for this function:

◆ adxl313_set_offset()

int adxl313_set_offset ( struct adxl313_dev dev,
int32_t  offset_ug,
enum adxl313_axis  axis 
)

Set offset for each axis.

Here is the caller graph for this function:

◆ adxl313_set_op_mode()

int adxl313_set_op_mode ( struct adxl313_dev dev,
enum adxl313_op_mode  op_mode 
)

Place the device into the given operation mode.

Here is the caller graph for this function:

◆ adxl313_set_range()

int adxl313_set_range ( struct adxl313_dev dev,
enum adxl313_range  range 
)

Set the ADXL312/ADXL313 device range.

Here is the caller graph for this function:

◆ adxl313_sleep()

int adxl313_sleep ( struct adxl313_dev dev,
enum adxl313_wake_up_f  wake_up_f_hz 
)

Put device in Sleep mode.

◆ adxl313_software_reset()

int adxl313_software_reset ( struct adxl313_dev dev)

Reset the device via communication.

Here is the caller graph for this function:

◆ adxl313_watermark_int_map()

int adxl313_watermark_int_map ( struct adxl313_dev dev,
uint8_t  int_pin 
)

Set pin for watermark interrupt.