no-OS
|
Implementation of ADXL355 Driver. More...
#include <stdlib.h>
#include <errno.h>
#include "adxl355.h"
#include "no_os_delay.h"
#include "no_os_alloc.h"
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. More... | |
int | adxl355_write_device_data (struct adxl355_dev *dev, uint8_t base_address, uint16_t size, uint8_t *write_data) |
Writes to the device. More... | |
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. More... | |
int | adxl355_remove (struct adxl355_dev *dev) |
Free the resources allocated by adxl355_init(). More... | |
int | adxl355_set_op_mode (struct adxl355_dev *dev, enum adxl355_op_mode op_mode) |
Places the device into the given operation mode. More... | |
int | adxl355_get_op_mode (struct adxl355_dev *dev, enum adxl355_op_mode *op_mode) |
Gets the current operation mode of the device. More... | |
int | adxl355_soft_reset (struct adxl355_dev *dev) |
Performs a soft reset of the device. More... | |
int | adxl355_set_self_test (struct adxl355_dev *dev) |
Triggers the self-test feature. More... | |
int | adxl355_set_range (struct adxl355_dev *dev, enum adxl355_range range_val) |
Sets the measurement range register value. More... | |
int | adxl355_set_odr_lpf (struct adxl355_dev *dev, enum adxl355_odr_lpf odr_lpf_val) |
Writes the low-pass filter settings. More... | |
int | adxl355_set_hpf_corner (struct adxl355_dev *dev, enum adxl355_hpf_corner hpf_corner_val) |
Writes the high-pass filter settings. More... | |
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). More... | |
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. More... | |
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. More... | |
int | adxl355_get_raw_temp (struct adxl355_dev *dev, uint16_t *raw_temp) |
Reads the raw temperature. More... | |
int | adxl355_get_temp (struct adxl355_dev *dev, struct adxl355_frac_repr *temp) |
Reads the raw temperature data and converts it to millidegrees Celsius. More... | |
int | adxl355_get_sts_reg (struct adxl355_dev *dev, union adxl355_sts_reg_flags *status_flags) |
Reads the status register value. More... | |
int | adxl355_get_nb_of_fifo_entries (struct adxl355_dev *dev, uint8_t *reg_value) |
Reads the number of FIFO entries register value. More... | |
int | adxl355_set_fifo_samples (struct adxl355_dev *dev, uint8_t reg_value) |
Sets the number of FIFO samples register value. More... | |
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. More... | |
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. More... | |
int | adxl355_conf_act_en (struct adxl355_dev *dev, union adxl355_act_en_flags act_config) |
Configures the activity enable register. More... | |
int | adxl355_conf_act_thr (struct adxl355_dev *dev, uint16_t act_thr) |
Configures the activity threshold registers. More... | |
int | adxl355_set_act_cnt_reg (struct adxl355_dev *dev, uint8_t act_cnt) |
Writes the activity count register value. More... | |
int | adxl355_config_int_pins (struct adxl355_dev *dev, union adxl355_int_mask int_conf) |
Configures the interrupt map for INT1 and INT2 pins. More... | |
int | adxl355_set_int_pol (struct adxl355_dev *dev, enum adxl355_int_pol int_pol) |
Sets the interrupt polarity. More... | |
Implementation of ADXL355 Driver.
Copyright 2022(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:
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.
int adxl355_conf_act_en | ( | struct adxl355_dev * | dev, |
union adxl355_act_en_flags | act_config | ||
) |
Configures the activity enable register.
dev | - The device structure. |
act_config | - Activity enable mapping. |
int adxl355_conf_act_thr | ( | struct adxl355_dev * | dev, |
uint16_t | act_thr | ||
) |
Configures the activity threshold registers.
dev | - The device structure. |
act_thr | - Activity threshold 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.
dev | - The device structure. |
int_conf | - Interrupt mapping. |
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.
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. |
int adxl355_get_nb_of_fifo_entries | ( | struct adxl355_dev * | dev, |
uint8_t * | reg_value | ||
) |
Reads the number of FIFO entries register value.
dev | - The device structure. |
reg_value | - Register value. |
int adxl355_get_op_mode | ( | struct adxl355_dev * | dev, |
enum adxl355_op_mode * | op_mode | ||
) |
Gets the current operation mode of the device.
dev | - The device structure. |
op_mode | - Read operation mode. |
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.
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. |
int adxl355_get_raw_temp | ( | struct adxl355_dev * | dev, |
uint16_t * | raw_temp | ||
) |
Reads the raw temperature.
dev | - The device structure. |
raw_temp | - Raw temperature output data. |
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.
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. |
int adxl355_get_sts_reg | ( | struct adxl355_dev * | dev, |
union adxl355_sts_reg_flags * | status_flags | ||
) |
Reads the status register value.
dev | - The device structure. |
status_flags | - Register value. |
int adxl355_get_temp | ( | struct adxl355_dev * | dev, |
struct adxl355_frac_repr * | temp | ||
) |
Reads the raw temperature data and converts it to millidegrees Celsius.
dev | - The device structure. |
temp | - Temperature 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.
dev | - The device structure. |
x | - X-axis's output data. |
y | - Y-axis's output data. |
z | - Z-axis's output data. |
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.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
int adxl355_read_device_data | ( | struct adxl355_dev * | dev, |
uint8_t | base_address, | ||
uint16_t | size, | ||
uint8_t * | read_data | ||
) |
Reads from the device.
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 |
int adxl355_remove | ( | struct adxl355_dev * | dev | ) |
Free the resources allocated by adxl355_init().
dev | - The device structure. |
int adxl355_set_act_cnt_reg | ( | struct adxl355_dev * | dev, |
uint8_t | act_cnt | ||
) |
Writes the activity count register value.
dev | - The device structure. |
act_cnt | - Register value. |
int adxl355_set_fifo_samples | ( | struct adxl355_dev * | dev, |
uint8_t | reg_value | ||
) |
Sets the number of FIFO samples register value.
dev | - The device structure. |
reg_value | - Register value. |
int adxl355_set_hpf_corner | ( | struct adxl355_dev * | dev, |
enum adxl355_hpf_corner | hpf_corner_val | ||
) |
Writes the high-pass filter settings.
dev | - The device structure. |
hpf_corner_val | - High-pass filter settings. |
int adxl355_set_int_pol | ( | struct adxl355_dev * | dev, |
enum adxl355_int_pol | int_pol | ||
) |
Sets the interrupt polarity.
dev | - The device structure. |
int_pol | - Interrupt polarity to be set. |
int adxl355_set_odr_lpf | ( | struct adxl355_dev * | dev, |
enum adxl355_odr_lpf | odr_lpf_val | ||
) |
Writes the low-pass filter settings.
dev | - The device structure. |
odr_lpf_val | - Low-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).
dev | - The device structure. |
x_offset | - X-axis's offset. |
y_offset | - Y-axis's offset. |
z_offset | - Z-axis's offset. |
int adxl355_set_op_mode | ( | struct adxl355_dev * | dev, |
enum adxl355_op_mode | op_mode | ||
) |
Places the device into the given operation mode.
dev | - The device structure. |
op_mode | - Operation mode mode. |
int adxl355_set_range | ( | struct adxl355_dev * | dev, |
enum adxl355_range | range_val | ||
) |
Sets the measurement range register value.
dev | - The device structure. |
range_val | - Selected range. |
int adxl355_set_self_test | ( | struct adxl355_dev * | dev | ) |
Triggers the self-test feature.
dev | - The device structure. |
int adxl355_soft_reset | ( | struct adxl355_dev * | dev | ) |
Performs a soft reset of the device.
dev | - The device structure. |
int adxl355_write_device_data | ( | struct adxl355_dev * | dev, |
uint8_t | base_address, | ||
uint16_t | size, | ||
uint8_t * | write_data | ||
) |
Writes to the device.
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. |