Device driver interface for the LIS3DH accelerometer. More...
Device driver interface for the LIS3DH accelerometer.
Definition in file lis3dh.h.
Go to the source code of this file.
Data Structures | |
struct | lis3dh_params_t |
Configuration parameters for LIS3DH devices. More... | |
struct | lis3dh_t |
Device descriptor for LIS3DH sensors. More... | |
struct | lis3dh_data_t |
Result vector for accelerometer measurement. More... | |
Macros | |
#define | LIS3DH_WHO_AM_I_RESPONSE (0x33) |
Identifier register value. More... | |
#define | LIS3DH_AXES_XYZ (LIS3DH_CTRL_REG1_XYZEN_MASK) |
Convenience macro for enabling all axes. | |
#define | LIS3DH_ADC_DATA_SIZE (2U) |
Length of scalar measurement data in bytes. | |
Functions | |
int | lis3dh_init (lis3dh_t *dev, const lis3dh_params_t *params) |
Initialize a LIS3DH sensor instance. More... | |
int | lis3dh_read_xyz (const lis3dh_t *dev, lis3dh_data_t *acc_data) |
Read 3D acceleration data from the accelerometer. More... | |
int | lis3dh_read_aux_adc1 (const lis3dh_t *dev, int16_t *out) |
Read auxiliary ADC channel 1 data from the accelerometer. More... | |
int | lis3dh_read_aux_adc2 (const lis3dh_t *dev, int16_t *out) |
Read auxiliary ADC channel 2 data from the accelerometer. More... | |
int | lis3dh_read_aux_adc3 (const lis3dh_t *dev, int16_t *out) |
Read auxiliary ADC channel 3 data from the accelerometer. More... | |
int | lis3dh_set_aux_adc (const lis3dh_t *dev, const uint8_t enable, const uint8_t temperature) |
Turn on/off power to the auxiliary ADC in LIS3DH. More... | |
int | lis3dh_set_axes (const lis3dh_t *dev, const uint8_t axes) |
Enable/disable accelerometer axes. More... | |
int | lis3dh_set_fifo (const lis3dh_t *dev, const uint8_t mode, const uint8_t watermark) |
Enable/disable the FIFO. More... | |
int | lis3dh_set_odr (const lis3dh_t *dev, const uint8_t odr) |
Set the output data rate of the sensor. More... | |
int | lis3dh_set_scale (lis3dh_t *dev, const uint8_t scale) |
Set the full scale range of the sensor. More... | |
int | lis3dh_set_int1 (const lis3dh_t *dev, const uint8_t mode) |
Set INT1 pin function. More... | |
int | lis3dh_get_fifo_level (const lis3dh_t *dev) |
Get the current number of elements in the FIFO. More... | |
TEMP_CFG_REG bitfield macros | |
#define | LIS3DH_TEMP_CFG_REG_ADC_PD_MASK (1 << 7) |
ADC enable. More... | |
#define | LIS3DH_TEMP_CFG_REG_TEMP_EN_MASK (1 << 6) |
Temperature sensor (T) enable. More... | |
CTRL_REG2 bitfield macros | |
#define | LIS3DH_CTRL_REG2_HPM1_MASK (1 << 7) |
High pass filter mode selection second bit. More... | |
#define | LIS3DH_CTRL_REG2_HPM0_MASK (1 << 6) |
High pass filter mode selection first bit. More... | |
#define | LIS3DH_CTRL_REG2_HPCF2_MASK (1 << 5) |
High pass filter cut off frequency selection second bit. | |
#define | LIS3DH_CTRL_REG2_HPCF1_MASK (1 << 4) |
High pass filter cut off frequency selection second bit. | |
#define | LIS3DH_CTRL_REG2_FDS_MASK (1 << 3) |
Filtered data selection. More... | |
#define | LIS3DH_CTRL_REG2_HPCLICK_MASK (1 << 2) |
High pass filter enabled for CLICK function. More... | |
#define | LIS3DH_CTRL_REG2_HPIS2_MASK (1 << 1) |
High pass filter enabled for AOI function on interrupt 2, second bit. More... | |
#define | LIS3DH_CTRL_REG2_HPIS1_MASK (1 << 0) |
High pass filter enabled for AOI function on interrupt 2, first bit. More... | |
CTRL_REG3 bitfield macros | |
#define | LIS3DH_CTRL_REG3_I1_CLICK_MASK (1 << 7) |
CLICK interrupt on INT1. More... | |
#define | LIS3DH_CTRL_REG3_I1_AOI1_MASK (1 << 6) |
AOI1 interrupt on INT1. More... | |
#define | LIS3DH_CTRL_REG3_I1_AOI2_MASK (1 << 5) |
AOI2 interrupt on INT1. More... | |
#define | LIS3DH_CTRL_REG3_I1_DRDY1_MASK (1 << 4) |
DRDY1 interrupt on INT1. More... | |
#define | LIS3DH_CTRL_REG3_I1_DRDY2_MASK (1 << 3) |
DRDY2 interrupt on INT1. More... | |
#define | LIS3DH_CTRL_REG3_I1_WTM_MASK (1 << 2) |
FIFO Watermark interrupt on INT1. More... | |
#define | LIS3DH_CTRL_REG3_I1_OVERRUN_MASK (1 << 1) |
FIFO Overrun interrupt on INT1. More... | |
CTRL_REG4 bitfield macros | |
#define | LIS3DH_CTRL_REG4_BDU_MASK (1 << 7) |
Block data update (BDU) bit mask. More... | |
#define | LIS3DH_CTRL_REG4_BDU_ENABLE (LIS3DH_CTRL_REG4_BDU_MASK) |
Block data update (BDU) enable. | |
#define | LIS3DH_CTRL_REG4_BDU_DISABLE (0) |
Block data update (BDU) disable. | |
#define | LIS3DH_CTRL_REG4_BLE_MASK (1 << 6) |
Big/little endian bit mask. More... | |
#define | LIS3DH_CTRL_REG4_BLE_LITTLE_ENDIAN (0) |
Big/little endian little endian mode. | |
#define | LIS3DH_CTRL_REG4_BLE_BIG_ENDIAN (LIS3DH_CTRL_REG4_BLE_MASK) |
Big/little endian big endian mode. | |
#define | LIS3DH_CTRL_REG4_FS1_MASK (1 << 5) |
Full scale selection mask second bit. | |
#define | LIS3DH_CTRL_REG4_FS0_MASK (1 << 4) |
Full scale selection mask first bit. | |
#define | LIS3DH_CTRL_REG4_FS_MASK |
Full scale selection mask. More... | |
#define | LIS3DH_CTRL_REG4_SCALE_2G (0) |
Scale register value: +/- 2G. | |
#define | LIS3DH_CTRL_REG4_SCALE_4G (LIS3DH_CTRL_REG4_FS0_MASK) |
Scale register value: +/- 4G. | |
#define | LIS3DH_CTRL_REG4_SCALE_8G (LIS3DH_CTRL_REG4_FS1_MASK) |
Scale register value: +/- 8G. | |
#define | LIS3DH_CTRL_REG4_SCALE_16G (LIS3DH_CTRL_REG4_FS1_MASK | LIS3DH_CTRL_REG4_FS0_MASK) |
Scale: +/- 16G. | |
#define | LIS3DH_CTRL_REG4_HR_MASK (1 << 3) |
High resolution output mode. More... | |
#define | LIS3DH_CTRL_REG4_ST1_MASK (1 << 2) |
Self test enable second bit mask. More... | |
#define | LIS3DH_CTRL_REG4_ST0_MASK (1 << 1) |
Self test enable first bit mask. | |
#define | LIS3DH_CTRL_REG4_SIM_MASK (1 << 0) |
SPI serial interface mode selection. More... | |
#define | LIS3DH_CTRL_REG5_REBOOT_MASK (1 << 7) |
Reboot memory content. More... | |
#define | LIS3DH_CTRL_REG5_FIFO_EN_MASK (1 << 6) |
FIFO enable. More... | |
#define | LIS3DH_CTRL_REG5_LIR_I1_MASK (1 << 3) |
Latch interrupt request on INT1. More... | |
#define | LIS3DH_CTRL_REG5_D4D_I1_MASK (1 << 2) |
4D enable More... | |
STATUS_REG bitfield macros | |
#define | LIS3DH_STATUS_REG_ZYXOR_MASK (1 << 7) |
X, Y or Z axis data overrun. More... | |
#define | LIS3DH_STATUS_REG_ZOR_MASK (1 << 6) |
Z axis data overrun. More... | |
#define | LIS3DH_STATUS_REG_YOR_MASK (1 << 5) |
Y axis data overrun. More... | |
#define | LIS3DH_STATUS_REG_XOR_MASK (1 << 4) |
X axis data overrun. More... | |
#define | LIS3DH_STATUS_REG_ZYXDA_MASK (1 << 3) |
X, Y or Z axis new data available. More... | |
#define | LIS3DH_STATUS_REG_ZDA_MASK (1 << 2) |
Z axis new data available. More... | |
#define | LIS3DH_STATUS_REG_YDA_MASK (1 << 1) |
Y axis new data available. More... | |
#define | LIS3DH_STATUS_REG_XDA_MASK (1 << 0) |
X axis new data available. More... | |
Register address bitfield macros | |
#define | LIS3DH_SPI_WRITE_MASK (0 << 7) |
Write to register. | |
#define | LIS3DH_SPI_READ_MASK (1 << 7) |
The READ bit must be set when reading. | |
#define | LIS3DH_SPI_MULTI_MASK (1 << 6) |
Multi byte transfers must assert this bit when writing the address. | |
#define | LIS3DH_SPI_SINGLE_MASK (0 << 6) |
Opposite of LIS3DH_SPI_MULTI_MASK. | |
#define | LIS3DH_SPI_ADDRESS_MASK (0x3F) |
Mask of the address bits in the address byte during transfers. | |
FIFO modes. | |
Used when calling lis3dh_set_fifo() | |
#define | LIS3DH_FIFO_MODE_BYPASS (0x00 << LIS3DH_FIFO_CTRL_REG_FM_SHIFT) |
FIFO mode: Bypass. | |
#define | LIS3DH_FIFO_MODE_FIFO (0x01 << LIS3DH_FIFO_CTRL_REG_FM_SHIFT) |
FIFO mode: FIFO. | |
#define | LIS3DH_FIFO_MODE_STREAM (0x02 << LIS3DH_FIFO_CTRL_REG_FM_SHIFT) |
FIFO mode: Stream. | |
#define | LIS3DH_FIFO_MODE_STREAM_TO_FIFO (0x03 << LIS3DH_FIFO_CTRL_REG_FM_SHIFT) |
FIFO mode: Stream to FIFO. | |
Output Data Rates (ODR) macros | |
#define | LIS3DH_ODR_POWERDOWN (0x00 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
Powerdown mode. | |
#define | LIS3DH_ODR_1Hz (0x01 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
1Hz mode | |
#define | LIS3DH_ODR_10Hz (0x02 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
10Hz mode | |
#define | LIS3DH_ODR_25Hz (0x03 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
25Hz mode | |
#define | LIS3DH_ODR_50Hz (0x04 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
50Hz mode | |
#define | LIS3DH_ODR_100Hz (0x05 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
100Hz mode | |
#define | LIS3DH_ODR_200Hz (0x06 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
200Hz mode | |
#define | LIS3DH_ODR_400Hz (0x07 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
400Hz mode | |
#define | LIS3DH_ODR_LP1600Hz (0x08 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
Low power 1600Hz mode. | |
#define | LIS3DH_ODR_NP1250Hz (0x09 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
Normal mode 1250 Hz. More... | |
#define | LIS3DH_ODR_LP5000HZ (0x09 << LIS3DH_CTRL_REG1_ODR_SHIFT) |
Low power mode 5000 Hz. More... | |