![]() |
no-OS
|
Header file of ADXL38X Driver. More...
Classes | |
| struct | adxl38x_fractional_val |
| Data format in which the values are converted. More... | |
| union | adxl38x_comm_desc |
| union | adxl38x_comm_init_param |
| struct | adxl38x_dev |
| ADXL38X Device structure. More... | |
| struct | adxl38x_init_param |
| Structure holding the parameters for ADXL38X device initialization. More... | |
| struct | _adxl38x_sts_reg_flags |
| union | adxl38x_sts_reg_flags |
Functions | |
| int | adxl38x_read_device_data (struct adxl38x_dev *dev, uint8_t base_address, uint16_t size, uint8_t *read_data) |
| Reads from the device. | |
| int | adxl38x_write_device_data (struct adxl38x_dev *dev, uint8_t base_address, uint16_t size, uint8_t *write_data) |
| Writes to the device. | |
| int | adxl38x_register_update_bits (struct adxl38x_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t update_val) |
| Updates register with specified bits using given mask. | |
| int | adxl38x_init (struct adxl38x_dev **device, struct adxl38x_init_param init_param) |
| Initializes the device and checks for valid peripheral communication. | |
| int | adxl38x_remove (struct adxl38x_dev *dev) |
| Free the resources allocated by the init function. | |
| int | adxl38x_soft_reset (struct adxl38x_dev *dev) |
| Performs a soft reset of the device. | |
| int | adxl38x_get_sts_reg (struct adxl38x_dev *dev, union adxl38x_sts_reg_flags *status_flags) |
| Reads the status registers. | |
| int | adxl38x_set_op_mode (struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode) |
| Places the device into the given operation mode. | |
| int | adxl38x_get_op_mode (struct adxl38x_dev *dev, enum adxl38x_op_mode *op_mode) |
| Gets the current operation mode of the device. | |
| int | adxl38x_set_range (struct adxl38x_dev *dev, enum adxl38x_range range_val) |
| Sets the measurement range register value. | |
| int | adxl38x_get_range (struct adxl38x_dev *dev, enum adxl38x_range *range_val) |
| Gets the current range setting of the device. | |
| int | adxl38x_get_deviceID (struct adxl38x_dev *dev, enum adxl38x_id *devID) |
| Gets the current device type. | |
| int | adxl38x_set_self_test_registers (struct adxl38x_dev *dev, bool st_mode, bool st_force, bool st_dir) |
| Sets the part to execute self-test routine. | |
| int | adxl38x_clear_self_test_registers (struct adxl38x_dev *dev) |
| Resets the self test registers for the part. | |
| int | adxl38x_get_raw_xyz (struct adxl38x_dev *dev, uint16_t *raw_x, uint16_t *raw_y, uint16_t *raw_z) |
| Reads the raw output data using continuous read. | |
| int | adxl38x_get_temp (struct adxl38x_dev *dev, struct adxl38x_fractional_val *raw_temp) |
| Reads the raw temperature data using burst read. | |
| int | adxl38x_get_raw_data (struct adxl38x_dev *dev, enum adxl38x_ch_select channels, uint16_t *raw_x, uint16_t *raw_y, uint16_t *raw_z, uint16_t *raw_temp) |
| Reads the raw output data using burst read. | |
| int | adxl38x_get_xyz_gees (struct adxl38x_dev *dev, enum adxl38x_ch_select channels, struct adxl38x_fractional_val *x, struct adxl38x_fractional_val *y, struct adxl38x_fractional_val *z) |
| Reads the raw output data of each axis and converts it to g. | |
| int | adxl38x_selftest (struct adxl38x_dev *dev, enum adxl38x_op_mode op_mode, bool *st_x, bool *st_y, bool *st_z) |
| Executed Selftest on the sensing axes and returns the outcome of the test. | |
| int | adxl38x_accel_set_FIFO (struct adxl38x_dev *dev, uint16_t numSamples, bool externalTrigger, enum adxl38x_fifo_mode fifo_mode, bool chIDEnable, bool readReset) |
| Function to set the paramenters for FIFO mode. | |
| int | adxl38x_data_raw_to_gees (struct adxl38x_dev *dev, uint8_t *raw_accel_data, struct adxl38x_fractional_val *data_frac) |
| Function to convert accel data to gees. | |
Header file of ADXL38X Driver.
Copyright 2024(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| #define ADXL380_ACC_SCALE_FACTOR_GEE_MUL (int64_t) 1333 |
| #define ADXL380_ACC_SENSITIVITY (int32_t) 7500 |
| #define ADXL380_XY_ST_LIMIT_MAX 50 |
| #define ADXL380_XY_ST_LIMIT_MIN 29 |
| #define ADXL380_Z_ST_LIMIT_MAX 32 |
| #define ADXL380_Z_ST_LIMIT_MIN 27 |
| #define ADXL382_ACC_SCALE_FACTOR_GEE_MUL (int64_t) 5000 |
| #define ADXL382_ACC_SENSITIVITY (int32_t) 2000 |
| #define ADXL382_XY_ST_LIMIT_MAX 42 |
| #define ADXL382_XY_ST_LIMIT_MIN 31 |
| #define ADXL382_Z_ST_LIMIT_MAX 34 |
| #define ADXL382_Z_ST_LIMIT_MIN 26 |
| #define ADXL38X_ACC_SCALE_FACTOR_GEE_DIV (int32_t) 10000000 |
| #define ADXL38X_ACT_INACT_CTL 0x37 |
| #define ADXL38X_BCLK 0x5B |
| #define ADXL38X_CLK_CTRL 0x25 |
| #define ADXL38X_DEV_DELTA_F0_X 0x0E |
| #define ADXL38X_DEV_DELTA_F0_Y 0x0F |
| #define ADXL38X_DEV_DELTA_F0_Z 0x10 |
| #define ADXL38X_DEV_DELTA_Q_X 0x0B |
| #define ADXL38X_DEV_DELTA_Q_Y 0x0C |
| #define ADXL38X_DEV_DELTA_Q_Z 0x0D |
| #define ADXL38X_DEVID_AD 0x00 |
| #define ADXL38X_DEVID_MST 0x01 |
| #define ADXL38X_DIG_EN 0x27 |
| #define ADXL38X_FIFO_CFG0 0x30 |
| #define ADXL38X_FIFO_CFG1 0x31 |
| #define ADXL38X_FIFO_DATA 0x1D |
| #define ADXL38X_FIFO_STATUS0 0x1E |
| #define ADXL38X_FIFO_STATUS1 0x1F |
| #define ADXL38X_FIFOCFG_FIFOMODE_MSK 0x30 |
| #define ADXL38X_FILTER 0x50 |
| #define ADXL38X_FSYNC 0x5C |
| #define ADXL38X_INT0 0x5D |
| #define ADXL38X_INT0_MAP0 0x2B |
| #define ADXL38X_INT0_MAP1 0x2C |
| #define ADXL38X_INT1 0x5E |
| #define ADXL38X_INT1_MAP0 0x2D |
| #define ADXL38X_INT1_MAP1 0x2E |
| #define ADXL38X_MASK_CHEN_DIG_EN 0xF0 |
| #define ADXL38X_MASK_OP_MODE 0x0F |
| #define ADXL38X_MASK_RANGE 0xC0 |
| #define ADXL38X_MCLK 0x5A |
| #define ADXL38X_MISC0 0x20 |
| #define ADXL38X_MISC1 0x21 |
| #define ADXL38X_MISO 0x58 |
| #define ADXL38X_NEG_ACC_MSK NO_OS_GENMASK(31, 16) |
| #define ADXL38X_NVM_CTL 0x29 |
| #define ADXL38X_OP_MODE 0x26 |
| #define ADXL38X_OR_CFG 0x48 |
| #define ADXL38X_PART_ID 0x02 |
| #define ADXL38X_PART_ID_REV_ID 0x03 |
| #define ADXL38X_PDM_CFG 0x36 |
| #define ADXL38X_REG_RESET 0x2A |
| #define ADXL38X_RESET_CODE 0x52 |
| #define ADXL38X_RESET_DEVID_AD 0xAD |
| #define ADXL38X_RESET_DEVID_MST 0x1D |
| #define ADXL38X_RESET_INT0_MAP0 0x80 |
| #define ADXL38X_RESET_INT1_MAP1 0x80 |
| #define ADXL38X_RESET_PART_ID 0x17 |
| #define ADXL38X_RESET_PART_ID_REV_ID 0xC1 |
| #define ADXL38X_RESET_SPT_CFG1 0x08 |
| #define ADXL38X_RESET_SPT_CFG2 0x1A |
| #define ADXL38X_RESET_STATUS 0x80000400 |
| #define ADXL38X_RESET_STATUS0 0x80 |
| #define ADXL38X_RESET_STATUS2 0x04 |
| #define ADXL38X_RESET_ZERO 0x00 |
| #define ADXL38X_SAR_I2C 0x28 |
| #define ADXL38X_SENS_DSM 0x24 |
| #define ADXL38X_SERIAL_NUMBER_0 0x04 |
| #define ADXL38X_SERIAL_NUMBER_1 0x05 |
| #define ADXL38X_SERIAL_NUMBER_2 0x06 |
| #define ADXL38X_SERIAL_NUMBER_3 0x07 |
| #define ADXL38X_SERIAL_NUMBER_4 0x08 |
| #define ADXL38X_SERIAL_NUMBER_5 0x09 |
| #define ADXL38X_SERIAL_NUMBER_6 0x0A |
| #define ADXL38X_SLF_TST_CTRL_MSK 0xE0 |
| #define ADXL38X_SNSR_AXIS_EN 0x38 |
| #define ADXL38X_SOUT0 0x59 |
| #define ADXL38X_SPI_READ 0x01 |
| #define ADXL38X_SPI_WRITE 0x00 |
| #define ADXL38X_SPT_CFG0 0x32 |
| #define ADXL38X_SPT_CFG1 0x33 |
| #define ADXL38X_SPT_CFG2 0x34 |
| #define ADXL38X_ST_LIMIT_DENOMINATOR 10 |
| #define ADXL38X_STATUS0 0x11 |
| #define ADXL38X_STATUS1 0x12 |
| #define ADXL38X_STATUS2 0x13 |
| #define ADXL38X_STATUS3 0x14 |
| #define ADXL38X_SYNC_CFG 0x35 |
| #define ADXL38X_TAP_CFG 0x47 |
| #define ADXL38X_TAP_DUR 0x44 |
| #define ADXL38X_TAP_LATENT 0x45 |
| #define ADXL38X_TAP_THRESH 0x43 |
| #define ADXL38X_TAP_WINDOW 0x46 |
| #define ADXL38X_TDATA_H 0x1B |
| #define ADXL38X_TDATA_L 0x1C |
| #define ADXL38X_TEMP_OFFSET (int32_t) 295 |
| #define ADXL38X_TEMP_SCALE_DEN (int32_t) 10 |
| #define ADXL38X_TEMP_SCALE_NUM (int32_t) 102 |
| #define ADXL38X_TEST_EN 0x2F |
| #define ADXL38X_THRESH_ACT_H 0x39 |
| #define ADXL38X_THRESH_ACT_L 0x3A |
| #define ADXL38X_THRESH_INACT_H 0x3E |
| #define ADXL38X_THRESH_INACT_L 0x3F |
| #define ADXL38X_TIME_ACT_H 0x3B |
| #define ADXL38X_TIME_ACT_L 0x3D |
| #define ADXL38X_TIME_ACT_M 0x3C |
| #define ADXL38X_TIME_INACT_H 0x40 |
| #define ADXL38X_TIME_INACT_L 0x42 |
| #define ADXL38X_TIME_INACT_M 0x41 |
| #define ADXL38X_TRIG_CFG 0x49 |
| #define ADXL38X_USER_TEMP_SENS_0 0x55 |
| #define ADXL38X_USER_TEMP_SENS_1 0x56 |
| #define ADXL38X_X_DSM_OFFSET 0x4D |
| #define ADXL38X_X_SAR_OFFSET 0x4A |
| #define ADXL38X_XDATA_H 0x15 |
| #define ADXL38X_XDATA_L 0x16 |
| #define ADXL38X_Y_DSM_OFFSET 0x4E |
| #define ADXL38X_Y_SAR_OFFSET 0x4B |
| #define ADXL38X_YDATA_H 0x17 |
| #define ADXL38X_YDATA_L 0x18 |
| #define ADXL38X_Z_DSM_OFFSET 0x4F |
| #define ADXL38X_Z_SAR_OFFSET 0x4C |
| #define ADXL38X_ZDATA_H 0x19 |
| #define ADXL38X_ZDATA_L 0x1A |
| enum adxl38x_ch_select |
| enum adxl38x_comm_type |
| enum adxl38x_fifo_mode |
| enum adxl38x_id |
| enum adxl38x_op_mode |
| enum adxl38x_range |
| int adxl38x_accel_set_FIFO | ( | struct adxl38x_dev * | dev, |
| uint16_t | num_samples, | ||
| bool | external_trigger, | ||
| enum adxl38x_fifo_mode | fifo_mode, | ||
| bool | ch_ID_enable, | ||
| bool | read_reset ) |
Function to set the paramenters for FIFO mode.
| dev | - The device structure. |
| num_samples | - Number of FIFO entries that FIFI_WATERMARK should set. |
| external_trigger | - Enable/disable external trigger in FIFO stream mode. |
| fifo_mode | - FIFO mode setting. |
| ch_ID_enable | - Enable/disable channel ID. |
| read_reset | - reset read/write point and read state machine. |
| int adxl38x_clear_self_test_registers | ( | struct adxl38x_dev * | dev | ) |
Resets the self test registers for the part.
NOTE: It is recommended that the ADXL380 self-test should be performed in mid and high gee ranges and in high power mode.
| dev | - The device structure. |
| int adxl38x_data_raw_to_gees | ( | struct adxl38x_dev * | dev, |
| uint8_t * | raw_accel_data, | ||
| struct adxl38x_fractional_val * | data_frac ) |
Function to convert accel data to gees.
| dev | - The device structure. |
| raw_accel_data | - Raw data array of two bytes |
| data_frac | - Fractional data in gees |
| int adxl38x_get_deviceID | ( | struct adxl38x_dev * | dev, |
| enum adxl38x_id * | devID ) |
Gets the current device type.
| dev | - The device structure |
| devID | - Read Device ID |
| int adxl38x_get_op_mode | ( | struct adxl38x_dev * | dev, |
| enum adxl38x_op_mode * | op_mode ) |
Gets the current operation mode of the device.
| dev | - The device structure. |
| op_mode | - Read operation mode. |
| int adxl38x_get_range | ( | struct adxl38x_dev * | dev, |
| enum adxl38x_range * | range_val ) |
Gets the current range setting of the device.
| dev | - The device structure. |
| range_val | - Read range. |
| int adxl38x_get_raw_data | ( | struct adxl38x_dev * | dev, |
| enum adxl38x_ch_select | channels, | ||
| uint16_t * | raw_x, | ||
| uint16_t * | raw_y, | ||
| uint16_t * | raw_z, | ||
| uint16_t * | raw_temp ) |
Reads the raw output data using burst read.
| dev | - The device structure. |
| channels | - Channels to enable. |
| raw_x | - X-axis's raw output data. |
| raw_y | - Y-axis's raw output data. |
| raw_z | - Z-axis's raw output data. |
| raw_temp | - Raw temp output data. |
| int adxl38x_get_raw_xyz | ( | struct adxl38x_dev * | dev, |
| uint16_t * | raw_x, | ||
| uint16_t * | raw_y, | ||
| uint16_t * | raw_z ) |
Reads the raw output data using continuous read.
| 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 adxl38x_get_sts_reg | ( | struct adxl38x_dev * | dev, |
| union adxl38x_sts_reg_flags * | status_flags ) |
Reads the status registers.
TODO: Update according to datasheet (Currently based on RevH)
| dev | - The device structure. |
| status_flags | - Combined Status value. |
| int adxl38x_get_temp | ( | struct adxl38x_dev * | dev, |
| struct adxl38x_fractional_val * | temp_degC ) |
Reads the raw temperature data using burst read.
| dev | - The device structure. |
| temp_degC | - Temperature data in degree Celcius |
| int adxl38x_get_xyz_gees | ( | struct adxl38x_dev * | dev, |
| enum adxl38x_ch_select | channels, | ||
| struct adxl38x_fractional_val * | x, | ||
| struct adxl38x_fractional_val * | y, | ||
| struct adxl38x_fractional_val * | z ) |
Reads the raw output data of each axis and converts it to g.
| dev | - The device structure. |
| channels | - Channels to enable. |
| x | - X-axis's output data. |
| y | - Y-axis's output data. |
| z | - Z-axis's output data. |
| int adxl38x_init | ( | struct adxl38x_dev ** | device, |
| struct adxl38x_init_param | init_param ) |
Initializes the device and checks for valid peripheral communication.
| device | - The device structure. |
| init_param | - Structure containing initialization parameters |
| int adxl38x_read_device_data | ( | struct adxl38x_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 adxl38x_register_update_bits | ( | struct adxl38x_dev * | dev, |
| uint8_t | reg_addr, | ||
| uint8_t | mask, | ||
| uint8_t | update_val ) |
Updates register with specified bits using given mask.
| dev | - The device structure. |
| reg_addr | - Address of the register to update. |
| mask | - Mask for the update field. |
| update_val | - Value to be updated. |
| int adxl38x_remove | ( | struct adxl38x_dev * | dev | ) |
Free the resources allocated by the init function.
| dev | - The device structure. |
| int adxl38x_selftest | ( | struct adxl38x_dev * | dev, |
| enum adxl38x_op_mode | op_mode, | ||
| bool * | st_x, | ||
| bool * | st_y, | ||
| bool * | st_z ) |
Executed Selftest on the sensing axes and returns the outcome of the test.
| dev | - The device structure. |
| op_mode | - Operation mode in which self-test is executed |
| st_x | - Result of X-axis self test success/failure |
| st_y | - Result of X-axis self test success/failure |
| st_z | - Result of X-axis self test success/failure |
| int adxl38x_set_op_mode | ( | struct adxl38x_dev * | dev, |
| enum adxl38x_op_mode | op_mode ) |
Places the device into the given operation mode.
| dev | - The device structure. |
| op_mode | - Operation mode mode. |
| int adxl38x_set_range | ( | struct adxl38x_dev * | dev, |
| enum adxl38x_range | range_val ) |
Sets the measurement range register value.
| dev | - The device structure. |
| range_val | - Selected range. |
| int adxl38x_set_self_test_registers | ( | struct adxl38x_dev * | dev, |
| bool | st_mode, | ||
| bool | st_force, | ||
| bool | st_dir ) |
Sets the part to execute self-test routine.
NOTE: It is recommended that the ADXL380 self-test should be performed in mid and high gee ranges and in high power mode.
| dev | - The device structure. |
| st_mode | - Enable/disable bit for self test. |
| st_force | - Enable/disable bit for forced self test. |
| st_dir | - Direction bit for self test. 0 - Forward, 1 - Reverse. |
| int adxl38x_soft_reset | ( | struct adxl38x_dev * | dev | ) |
Performs a soft reset of the device.
| dev | - The device structure. |
| int adxl38x_write_device_data | ( | struct adxl38x_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. |