no-OS
Functions
adxl313.c File Reference
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include "adxl313.h"
#include "no_os_print_log.h"
#include "no_os_util.h"
#include "no_os_delay.h"
#include "no_os_alloc.h"
Include dependency graph for adxl313.c:

Functions

int adxl313_read (struct adxl313_dev *dev, uint8_t base_address, uint16_t size, uint8_t *read_data)
 
int adxl313_write (struct adxl313_dev *dev, uint8_t base_address, uint16_t size, uint8_t *write_data)
 
int adxl313_reg_write_msk (struct adxl313_dev *dev, uint8_t reg_addr, uint8_t data, uint8_t mask)
 
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_set_raw_offset (struct adxl313_dev *dev, int32_t offset_raw, enum adxl313_axis axis)
 
int adxl313_get_raw_offset (struct adxl313_dev *dev, int32_t *offset_raw, 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_s, 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)
 

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_offset()

int adxl313_get_raw_offset ( struct adxl313_dev dev,
int32_t *  offset_raw,
enum adxl313_axis  axis 
)

Get raw offset for each axis.

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_read()

int adxl313_read ( struct adxl313_dev dev,
uint8_t  base_address,
uint16_t  size,
uint8_t *  read_data 
)
Here is the caller graph for this function:

◆ adxl313_reg_write_msk()

int adxl313_reg_write_msk ( struct adxl313_dev dev,
uint8_t  reg_addr,
uint8_t  data,
uint8_t  mask 
)
Here is the caller graph for this function:

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

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.

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_set_raw_offset()

int adxl313_set_raw_offset ( struct adxl313_dev dev,
int32_t  offset_raw,
enum adxl313_axis  axis 
)

Set raw offset for each axis.

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.

◆ adxl313_write()

int adxl313_write ( struct adxl313_dev dev,
uint8_t  base_address,
uint16_t  size,
uint8_t *  write_data 
)
Here is the caller graph for this function: