![]() |
no-OS
|
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"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... | |
Header file of ADXL313 Driver.
Copyright 2022(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| #define ADXL312_ACC_SCALE_FACTOR_MUL_FULL_RES ((int64_t)28439285ULL) |
| #define ADXL312_OFFSET_SCALE_FACTOR 11600 |
| #define ADXL312_SELF_TEST_MAX_DEVIATION 3400 |
| #define ADXL312_SELF_TEST_MIN_DEVIATION 300 |
| #define ADXL312_SELF_TEST_MULT 2900 |
| #define ADXL312_THRESH_SCALE_FACTOR 46400 |
| #define ADXL313_ACC_SCALE_FACTOR_DIV ((int32_t)1000000000) |
| #define ADXL313_ACC_SCALE_FACTOR_MUL_DIVIDER ((int32_t)100) |
| #define ADXL313_ACC_SCALE_FACTOR_MUL_FULL_RES ((int64_t)957680664ULL) |
| #define ADXL313_DEVID 0xAD |
| #define ADXL313_DEVID1 0x1D |
| #define ADXL313_LOW_POWER_OP NO_OS_BIT(4) |
| #define ADXL313_MAX_FIFO_ENTRIES 32 |
| #define ADXL313_MAX_FIFO_SAMPLES_VAL 0x60 |
| #define ADXL313_MULTIBIT NO_OS_BIT(6) |
| #define ADXL313_ODR_OFFSET_VAL 6 |
| #define ADXL313_OFFSET_SCALE_FACTOR 3900 |
| #define ADXL313_PARTID 0xCB |
| #define ADXL313_POWER_CTL_AUTO_SLEEP 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_MEASURE NO_OS_BIT(3) |
| #define ADXL313_POWER_CTL_SLEEP NO_OS_BIT(2) |
| #define ADXL313_POWER_CTL_WAKEUP | ( | x | ) |
| #define ADXL313_RANGE_FACTOR 4 |
| #define ADXL313_RATE_MSK NO_OS_GENMASK(3, 0) |
| #define ADXL313_REG_ACT_INACT_CTL 0x27 |
| #define ADXL313_REG_BW_RATE 0x2C |
| #define ADXL313_REG_DATA_AXIS | ( | index | ) |
| #define ADXL313_REG_DATA_FORMAT 0x31 |
| #define ADXL313_REG_DATA_FORMAT_FULL_RES NO_OS_BIT(3) |
| #define ADXL313_REG_DATA_FORMAT_INT_INV NO_OS_BIT(5) |
| #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_DATA_FORMAT_SELF_TEST NO_OS_BIT(7) |
| #define ADXL313_REG_DATA_FORMAT_SPI_3WIRE NO_OS_BIT(6) |
| #define ADXL313_REG_DEVID1_AD 0x01 |
| #define ADXL313_REG_DEVID_AD 0x00 |
| #define ADXL313_REG_FIFO_CTL 0x38 |
| #define ADXL313_REG_FIFO_CTL_MODE_MSK NO_OS_GENMASK(7, 6) |
| #define ADXL313_REG_FIFO_CTL_SAMPLES_MSK NO_OS_GENMASK(4, 0) |
| #define ADXL313_REG_FIFO_CTL_TRIGGER_BIT NO_OS_BIT(5) |
| #define ADXL313_REG_FIFO_FIFO_TRIGGER_BIT NO_OS_BIT(7) |
| #define ADXL313_REG_FIFO_STATUS 0x39 |
| #define ADXL313_REG_FIFO_STS_ENTRIES_MSK NO_OS_GENMASK(5, 0) |
| #define ADXL313_REG_INT_EN 0x2E |
| #define ADXL313_REG_INT_EN_ACTIVITY NO_OS_BIT(4) |
| #define ADXL313_REG_INT_EN_DATA_READY NO_OS_BIT(7) |
| #define ADXL313_REG_INT_EN_INACTIVITY NO_OS_BIT(3) |
| #define ADXL313_REG_INT_EN_OVERRUN NO_OS_BIT(0) |
| #define ADXL313_REG_INT_EN_WATERMARK NO_OS_BIT(1) |
| #define ADXL313_REG_INT_MAP 0x2F |
| #define ADXL313_REG_INT_MAP_ACT_INT2 NO_OS_BIT(4) |
| #define ADXL313_REG_INT_MAP_DR_INT2 NO_OS_BIT(7) |
| #define ADXL313_REG_INT_MAP_INACT_INT2 NO_OS_BIT(3) |
| #define ADXL313_REG_INT_MAP_OVER_INT2 NO_OS_BIT(0) |
| #define ADXL313_REG_INT_MAP_WM_INT2 NO_OS_BIT(1) |
| #define ADXL313_REG_INT_SRC 0x30 |
| #define ADXL313_REG_INT_SRC_ACTIVITY NO_OS_BIT(4) |
| #define ADXL313_REG_INT_SRC_DATA_READY NO_OS_BIT(7) |
| #define ADXL313_REG_INT_SRC_INACTIVITY NO_OS_BIT(3) |
| #define ADXL313_REG_INT_SRC_OVERRUN NO_OS_BIT(0) |
| #define ADXL313_REG_INT_SRC_WATERMARK NO_OS_BIT(1) |
| #define ADXL313_REG_OFS_AXIS | ( | index | ) |
| #define ADXL313_REG_PARTID 0x02 |
| #define ADXL313_REG_POWER_CTL 0x2D |
| #define ADXL313_REG_REVID 0x03 |
| #define ADXL313_REG_SOFT_RESET 0x18 |
| #define ADXL313_REG_THRESH_ACT 0x24 |
| #define ADXL313_REG_THRESH_INACT 0x25 |
| #define ADXL313_REG_TIME_INACT 0x26 |
| #define ADXL313_REG_XID 0x04 |
| #define ADXL313_REGS_PER_ENTRY 6 |
| #define ADXL313_RESET_KEY 0x52 |
| #define ADXL313_SELF_TEST_DIV 1000 |
| #define ADXL313_SELF_TEST_MAX_DEVIATION 3700 |
| #define ADXL313_SELF_TEST_MIN_DEVIATION 300 |
| #define ADXL313_SELF_TEST_MULT 976 |
| #define ADXL313_SELF_TEST_SAMPLES 10 |
| #define ADXL313_SPI_READ (0x80) |
| #define ADXL313_SPI_WRITE (0x00) |
| #define ADXL313_THRESH_SCALE_FACTOR 15625 |
| #define ADXL313_X_EN NO_OS_BIT(1) |
| #define ADXL313_Y_EN NO_OS_BIT(2) |
| #define ADXL313_Z_EN NO_OS_BIT(3) |
| #define ADXL314_ACC_SCALE_FACTOR_MUL ((int64_t)478858719ULL) |
| #define ADXL314_DEVID 0xE5 |
| #define ADXL314_OFFSET_SCALE_FACTOR 195000 |
| #define ADXL314_SELF_TEST_MAX_DEVIATION 8000 |
| #define ADXL314_SELF_TEST_MIN_DEVIATION 100 |
| #define ADXL314_SELF_TEST_MULT 48830 |
| #define ADXL314_THRESH_SCALE_FACTOR 784000 |
| enum adxl313_axis |
| enum adxl313_comm_type |
| enum adxl313_fifo_mode |
| enum adxl313_int_pol |
| enum adxl313_lp_mode |
| enum adxl313_odr |
| enum adxl313_op_mode |
| enum adxl313_range |
| enum adxl313_resolution |
| enum adxl313_type |
| enum adxl313_wake_up_f |
| enum bit_action |
| int adxl313_activity_int_disable | ( | struct adxl313_dev * | dev | ) |
Configure interrupt disable control for activity.
| int adxl313_activity_int_enable | ( | struct adxl313_dev * | dev | ) |
Configure interrupt enable control for activity.
| int adxl313_activity_int_map | ( | struct adxl313_dev * | dev, |
| uint8_t | int_pin ) |
Set pin for activity interrupt.
| 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.
| int adxl313_conf_act_thr | ( | struct adxl313_dev * | dev, |
| uint32_t | act_thr_ug ) |
Configure the activity threshold register.
| int adxl313_conf_inact_thr | ( | struct adxl313_dev * | dev, |
| uint32_t | inact_thr_ug ) |
Configure the inactivity threshold register.
| int adxl313_conf_int_enable | ( | struct adxl313_dev * | dev, |
| union adxl313_int_en_reg_flags | en_ctl ) |
Configure interrupt enable control.
| int adxl313_conf_int_map | ( | struct adxl313_dev * | dev, |
| union adxl313_int_map_reg_flags | int_map ) |
Configure interrupt mapping control.
| int adxl313_conf_time_inact | ( | struct adxl313_dev * | dev, |
| uint8_t | time_inact_s ) |
Configure the time inactivity threshold register.
| int adxl313_data_ready_int_map | ( | struct adxl313_dev * | dev, |
| uint8_t | int_pin ) |
Set pin for DATA_READY interrupt.
| int adxl313_disable_full_res | ( | struct adxl313_dev * | dev | ) |
Disable full resolution for the ADXL312/ADXL313 device.
| int adxl313_disable_i2c | ( | struct adxl313_dev * | dev | ) |
Disable I2C.
| int adxl313_enable_full_res | ( | struct adxl313_dev * | dev | ) |
Enable full resolution for the ADXL312/ADXL313 device.
| int adxl313_enable_i2c | ( | struct adxl313_dev * | dev | ) |
Enable I2C.
| int adxl313_exit_sleep | ( | struct adxl313_dev * | dev | ) |
Exit Sleep mode.
| int adxl313_get_act_thr | ( | struct adxl313_dev * | dev, |
| uint32_t * | act_thr_ug ) |
Get the value saved in the activity threshold register.
| 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.
| 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.
| int adxl313_get_full_res_setting | ( | struct adxl313_dev * | dev, |
| uint8_t * | full_res ) |
Get the ADXL312/ADXL313 FULL_RES setting.
| int adxl313_get_inact_thr | ( | struct adxl313_dev * | dev, |
| uint32_t * | inact_thr_ug ) |
Get the value in the inactivity threshold register.
| 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.
| int adxl313_get_no_of_fifo_entries | ( | struct adxl313_dev * | dev, |
| uint8_t * | entries_no ) |
Read the number of FIFO entries register value.
| int adxl313_get_odr | ( | struct adxl313_dev * | dev, |
| enum adxl313_odr * | odr ) |
Get output data rate (ODR).
| int adxl313_get_offset | ( | struct adxl313_dev * | dev, |
| int32_t * | offset_ug, | ||
| enum adxl313_axis | axis ) |
Get offset for each axis.
| int adxl313_get_op_mode | ( | struct adxl313_dev * | dev, |
| enum adxl313_op_mode * | op_mode ) |
Get the current operation mode of the device.
| int adxl313_get_range | ( | struct adxl313_dev * | dev, |
| enum adxl313_range * | range ) |
Get the ADXL312/ADXL313 device range.
| 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.
| int adxl313_get_raw_offset | ( | struct adxl313_dev * | dev, |
| int32_t * | offset_raw, | ||
| enum adxl313_axis | axis ) |
Get raw offset for each axis.
| 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.
| int adxl313_get_time_inact | ( | struct adxl313_dev * | dev, |
| uint8_t * | time_inact_s ) |
Get the value of the time inactivity threshold register.
| 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.
| int adxl313_inactivity_int_disable | ( | struct adxl313_dev * | dev | ) |
Configure interrupt disable control for inactivity.
| int adxl313_inactivity_int_enable | ( | struct adxl313_dev * | dev | ) |
Configure interrupt enable control for inactivity.
| int adxl313_inactivity_int_map | ( | struct adxl313_dev * | dev, |
| uint8_t | int_pin ) |
Set pin for inactivity interrupt.
| int adxl313_init | ( | struct adxl313_dev ** | device, |
| struct adxl313_init_param | init_param ) |
Init. the comm. peripheral and check if the ADXL313 is present.
| int adxl313_link_mode_disable | ( | struct adxl313_dev * | dev | ) |
Disable Link Mode for activity inactivity functions.
| int adxl313_link_mode_enable | ( | struct adxl313_dev * | dev | ) |
Enable Link Mode for activity inactivity functions.
| int adxl313_overrun_int_map | ( | struct adxl313_dev * | dev, |
| uint8_t | int_pin ) |
Set pin for overrun interrupt.
| int adxl313_remove | ( | struct adxl313_dev * | dev | ) |
Free the resources allocated by adxl313_init().
| int adxl313_self_test | ( | struct adxl313_dev * | dev | ) |
| 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.
| 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. |
| 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.
| int adxl313_set_fifo_mode | ( | struct adxl313_dev * | dev, |
| enum adxl313_fifo_mode | mode ) |
Set FIFO mode.
| int adxl313_set_fifo_samples | ( | struct adxl313_dev * | dev, |
| uint8_t | samples_no ) |
Set the number of FIFO samples register value.
| 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.
| 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. |
| int adxl313_set_int_pol | ( | struct adxl313_dev * | dev, |
| enum adxl313_int_pol | int_pol ) |
Configure the interrupt polarity.
| int adxl313_set_low_power_mode | ( | struct adxl313_dev * | dev, |
| enum bit_action | enable ) |
Activate/Deactivate LOW_POWER.
| int adxl313_set_odr | ( | struct adxl313_dev * | dev, |
| enum adxl313_odr | odr ) |
Set output data rate (ODR).
| int adxl313_set_offset | ( | struct adxl313_dev * | dev, |
| int32_t | offset_ug, | ||
| enum adxl313_axis | axis ) |
Set offset for each axis.
| int adxl313_set_op_mode | ( | struct adxl313_dev * | dev, |
| enum adxl313_op_mode | op_mode ) |
Place the device into the given operation mode.
| int adxl313_set_range | ( | struct adxl313_dev * | dev, |
| enum adxl313_range | range ) |
Set the ADXL312/ADXL313 device range.
| int adxl313_set_raw_offset | ( | struct adxl313_dev * | dev, |
| int32_t | offset_raw, | ||
| enum adxl313_axis | axis ) |
Set raw offset for each axis.
| int adxl313_sleep | ( | struct adxl313_dev * | dev, |
| enum adxl313_wake_up_f | wake_up_f_hz ) |
Put device in Sleep mode.
| int adxl313_software_reset | ( | struct adxl313_dev * | dev | ) |
Reset the device via communication.
| int adxl313_watermark_int_map | ( | struct adxl313_dev * | dev, |
| uint8_t | int_pin ) |
Set pin for watermark interrupt.