no-OS
Loading...
Searching...
No Matches
adxl355.c File Reference

Implementation of ADXL355 Driver. More...

#include <stdlib.h>
#include <errno.h>
#include "adxl355.h"
#include "no_os_delay.h"
#include "no_os_alloc.h"
Include dependency graph for adxl355.c:

Functions

int adxl355_read_device_data (struct adxl355_dev *dev, uint8_t base_address, uint16_t size, uint8_t *read_data)
 Reads from the device.
 
int adxl355_write_device_data (struct adxl355_dev *dev, uint8_t base_address, uint16_t size, uint8_t *write_data)
 Writes to the device.
 
int adxl355_init (struct adxl355_dev **device, struct adxl355_init_param init_param)
 Initializes the communication peripheral and checks if the ADXL355 part is present.
 
int adxl355_remove (struct adxl355_dev *dev)
 Free the resources allocated by adxl355_init().
 
int adxl355_set_op_mode (struct adxl355_dev *dev, enum adxl355_op_mode op_mode)
 Places the device into the given operation mode.
 
int adxl355_get_op_mode (struct adxl355_dev *dev, enum adxl355_op_mode *op_mode)
 Gets the current operation mode of the device.
 
int adxl355_soft_reset (struct adxl355_dev *dev)
 Performs a soft reset of the device.
 
int adxl355_set_self_test (struct adxl355_dev *dev)
 Triggers the self-test feature.
 
int adxl355_set_range (struct adxl355_dev *dev, enum adxl355_range range_val)
 Sets the measurement range register value.
 
int adxl355_set_odr_lpf (struct adxl355_dev *dev, enum adxl355_odr_lpf odr_lpf_val)
 Writes the low-pass filter settings.
 
int adxl355_set_hpf_corner (struct adxl355_dev *dev, enum adxl355_hpf_corner hpf_corner_val)
 Writes the high-pass filter settings.
 
int adxl355_set_offset (struct adxl355_dev *dev, uint16_t x_offset, uint16_t y_offset, uint16_t z_offset)
 Sets an offset value for each axis (Offset Calibration).
 
int adxl355_get_raw_xyz (struct adxl355_dev *dev, uint32_t *raw_x, uint32_t *raw_y, uint32_t *raw_z)
 Reads the raw output data.
 
int adxl355_get_xyz (struct adxl355_dev *dev, struct adxl355_frac_repr *x, struct adxl355_frac_repr *y, struct adxl355_frac_repr *z)
 Reads the raw output data of each axis and converts it to g.
 
int adxl355_get_raw_temp (struct adxl355_dev *dev, uint16_t *raw_temp)
 Reads the raw temperature.
 
int adxl355_get_temp (struct adxl355_dev *dev, struct adxl355_frac_repr *temp)
 Reads the raw temperature data and converts it to millidegrees Celsius.
 
int adxl355_get_sts_reg (struct adxl355_dev *dev, union adxl355_sts_reg_flags *status_flags)
 Reads the status register value.
 
int adxl355_get_nb_of_fifo_entries (struct adxl355_dev *dev, uint8_t *reg_value)
 Reads the number of FIFO entries register value.
 
int adxl355_set_fifo_samples (struct adxl355_dev *dev, uint8_t reg_value)
 Sets the number of FIFO samples register value.
 
int adxl355_get_raw_fifo_data (struct adxl355_dev *dev, uint8_t *fifo_entries, uint32_t *raw_x, uint32_t *raw_y, uint32_t *raw_z)
 Reads fifo data and returns the raw values.
 
int adxl355_get_fifo_data (struct adxl355_dev *dev, uint8_t *fifo_entries, struct adxl355_frac_repr *x, struct adxl355_frac_repr *y, struct adxl355_frac_repr *z)
 Reads fifo data and returns the values converted in m/s^2.
 
int adxl355_conf_act_en (struct adxl355_dev *dev, union adxl355_act_en_flags act_config)
 Configures the activity enable register.
 
int adxl355_conf_act_thr (struct adxl355_dev *dev, uint16_t act_thr)
 Configures the activity threshold registers.
 
int adxl355_set_act_cnt_reg (struct adxl355_dev *dev, uint8_t act_cnt)
 Writes the activity count register value.
 
int adxl355_config_int_pins (struct adxl355_dev *dev, union adxl355_int_mask int_conf)
 Configures the interrupt map for INT1 and INT2 pins.
 
int adxl355_set_int_pol (struct adxl355_dev *dev, enum adxl355_int_pol int_pol)
 Sets the interrupt polarity.
 

Detailed Description

Implementation of ADXL355 Driver.

Author
RBolboac (ramon.nosp@m.a.bo.nosp@m.lboac.nosp@m.a@an.nosp@m.alog..nosp@m.com)

Copyright 2022(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ adxl355_conf_act_en()

int adxl355_conf_act_en ( struct adxl355_dev * dev,
union adxl355_act_en_flags act_config )

Configures the activity enable register.

Parameters
dev- The device structure.
act_config- Activity enable mapping.
Returns
ret - Result of the configuration procedure.

◆ adxl355_conf_act_thr()

int adxl355_conf_act_thr ( struct adxl355_dev * dev,
uint16_t act_thr )

Configures the activity threshold registers.

Parameters
dev- The device structure.
act_thr- Activity threshold value.
Returns
ret - Result of the configuration procedure.

◆ adxl355_config_int_pins()

int adxl355_config_int_pins ( struct adxl355_dev * dev,
union adxl355_int_mask int_conf )

Configures the interrupt map for INT1 and INT2 pins.

Parameters
dev- The device structure.
int_conf- Interrupt mapping.
Returns
ret - Result of the configuration procedure.

◆ adxl355_get_fifo_data()

int adxl355_get_fifo_data ( struct adxl355_dev * dev,
uint8_t * fifo_entries,
struct adxl355_frac_repr * x,
struct adxl355_frac_repr * y,
struct adxl355_frac_repr * z )

Reads fifo data and returns the values converted in m/s^2.

Parameters
dev- The device structure.
fifo_entries- The number of fifo entries.
x- Converted x-axis data.
y- Converted y-axis data.
z- Converted z-axis data.
Returns
ret - Result of the configuration procedure.

◆ adxl355_get_nb_of_fifo_entries()

int adxl355_get_nb_of_fifo_entries ( struct adxl355_dev * dev,
uint8_t * reg_value )

Reads the number of FIFO entries register value.

Parameters
dev- The device structure.
reg_value- Register value.
Returns
ret - Result of the reading procedure.

◆ adxl355_get_op_mode()

int adxl355_get_op_mode ( struct adxl355_dev * dev,
enum adxl355_op_mode * op_mode )

Gets the current operation mode of the device.

Parameters
dev- The device structure.
op_mode- Read operation mode.
Returns
ret - Result of the reading operation procedure.

◆ adxl355_get_raw_fifo_data()

int adxl355_get_raw_fifo_data ( struct adxl355_dev * dev,
uint8_t * fifo_entries,
uint32_t * raw_x,
uint32_t * raw_y,
uint32_t * raw_z )

Reads fifo data and returns the raw values.

Parameters
dev- The device structure.
fifo_entries- The number of fifo entries.
raw_x- Raw x-axis data.
raw_y- Raw y-axis data.
raw_z- Raw z-axis data.
Returns
ret - Result of the configuration procedure.

◆ adxl355_get_raw_temp()

int adxl355_get_raw_temp ( struct adxl355_dev * dev,
uint16_t * raw_temp )

Reads the raw temperature.

Parameters
dev- The device structure.
raw_temp- Raw temperature output data.
Returns
ret - Result of the reading procedure.

◆ adxl355_get_raw_xyz()

int adxl355_get_raw_xyz ( struct adxl355_dev * dev,
uint32_t * raw_x,
uint32_t * raw_y,
uint32_t * raw_z )

Reads the raw output data.

Parameters
dev- The device structure.
raw_x- X-axis's raw output data.
raw_y- Y-axis's raw output data.
raw_z- Z-axis's raw output data.
Returns
ret - Result of the reading procedure.

◆ adxl355_get_sts_reg()

int adxl355_get_sts_reg ( struct adxl355_dev * dev,
union adxl355_sts_reg_flags * status_flags )

Reads the status register value.

Parameters
dev- The device structure.
status_flags- Register value.
Returns
ret - Result of the reading procedure.

◆ adxl355_get_temp()

int adxl355_get_temp ( struct adxl355_dev * dev,
struct adxl355_frac_repr * temp )

Reads the raw temperature data and converts it to millidegrees Celsius.

Parameters
dev- The device structure.
temp- Temperature output data.
Returns
ret - Result of the reading procedure.

◆ adxl355_get_xyz()

int adxl355_get_xyz ( struct adxl355_dev * dev,
struct adxl355_frac_repr * x,
struct adxl355_frac_repr * y,
struct adxl355_frac_repr * z )

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
ret - Result of the reading procedure.

◆ adxl355_init()

int adxl355_init ( struct adxl355_dev ** device,
struct adxl355_init_param init_param )

Initializes the communication peripheral and checks if the ADXL355 part is present.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
ret - Result of the initialization procedure.

◆ adxl355_read_device_data()

int adxl355_read_device_data ( struct adxl355_dev * dev,
uint8_t base_address,
uint16_t size,
uint8_t * read_data )

Reads from the device.

Parameters
dev- The device structure.
base_address- Address of the base register.
size- The number of bytes to be read and returned in read_data.
read_data- The read data buffer
Returns
ret - Result of the reading procedure.

◆ adxl355_remove()

int adxl355_remove ( struct adxl355_dev * dev)

Free the resources allocated by adxl355_init().

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

◆ adxl355_set_act_cnt_reg()

int adxl355_set_act_cnt_reg ( struct adxl355_dev * dev,
uint8_t act_cnt )

Writes the activity count register value.

Parameters
dev- The device structure.
act_cnt- Register value.
Returns
ret - Result of the writing procedure.

◆ adxl355_set_fifo_samples()

int adxl355_set_fifo_samples ( struct adxl355_dev * dev,
uint8_t reg_value )

Sets the number of FIFO samples register value.

Parameters
dev- The device structure.
reg_value- Register value.
Returns
ret - Result of the writing procedure.

◆ adxl355_set_hpf_corner()

int adxl355_set_hpf_corner ( struct adxl355_dev * dev,
enum adxl355_hpf_corner hpf_corner_val )

Writes the high-pass filter settings.

Parameters
dev- The device structure.
hpf_corner_val- High-pass filter settings.
Returns
ret - Result of the writing procedure.

◆ adxl355_set_int_pol()

int adxl355_set_int_pol ( struct adxl355_dev * dev,
enum adxl355_int_pol int_pol )

Sets the interrupt polarity.

Parameters
dev- The device structure.
int_pol- Interrupt polarity to be set.
Returns
ret - Result of the reading procedure.

◆ adxl355_set_odr_lpf()

int adxl355_set_odr_lpf ( struct adxl355_dev * dev,
enum adxl355_odr_lpf odr_lpf_val )

Writes the low-pass filter settings.

Parameters
dev- The device structure.
odr_lpf_val- Low-pass filter settings.
Returns
ret - Result of the writing procedure.

◆ adxl355_set_offset()

int adxl355_set_offset ( struct adxl355_dev * dev,
uint16_t x_offset,
uint16_t y_offset,
uint16_t z_offset )

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
ret - Result of the writing procedure.

◆ adxl355_set_op_mode()

int adxl355_set_op_mode ( struct adxl355_dev * dev,
enum adxl355_op_mode op_mode )

Places the device into the given operation mode.

Parameters
dev- The device structure.
op_mode- Operation mode mode.
Returns
ret - Result of the setting operation procedure.

◆ adxl355_set_range()

int adxl355_set_range ( struct adxl355_dev * dev,
enum adxl355_range range_val )

Sets the measurement range register value.

Parameters
dev- The device structure.
range_val- Selected range.
Returns
ret - Result of the writing procedure.

◆ adxl355_set_self_test()

int adxl355_set_self_test ( struct adxl355_dev * dev)

Triggers the self-test feature.

Parameters
dev- The device structure.
Returns
ret - Result of the writing procedure.

◆ adxl355_soft_reset()

int adxl355_soft_reset ( struct adxl355_dev * dev)

Performs a soft reset of the device.

Parameters
dev- The device structure.
Returns
ret - Result of the soft reset procedure.

◆ adxl355_write_device_data()

int adxl355_write_device_data ( struct adxl355_dev * dev,
uint8_t base_address,
uint16_t size,
uint8_t * write_data )

Writes to the device.

Parameters
dev- The device structure.
base_address- Address of the base register.
size- The number of bytes to be written. It is the size of the write_data buffer.
write_data- The data which is going to be written.
Returns
ret - Result of the writing procedure.