LIS3DH accelerometer

Device driver for the LIS3DH accelerometer. More...

Detailed Description

Files

file  lis3dh.h
 Device driver interface for the LIS3DH accelerometer.
 

Macros

#define LIS3DH_WHO_AM_I_RESPONSE   (0b00110011)
 The WHO_AM_I register should contain this value in order to correctly identify the chip.
 
#define LIS3DH_CTRL_REG1_LPEN_MASK   (1 << 3)
 Low power mode enable. More...
 
#define LIS3DH_CTRL_REG1_ZEN_SHIFT   (2)
 Z enable bit offset.
 
#define LIS3DH_CTRL_REG1_ZEN_MASK   (1 << LIS3DH_CTRL_REG1_ZEN_SHIFT)
 Z axis enable. More...
 
#define LIS3DH_CTRL_REG1_YEN_SHIFT   (1)
 Y enable bit offset.
 
#define LIS3DH_CTRL_REG1_YEN_MASK   (1 << LIS3DH_CTRL_REG1_YEN_SHIFT)
 Y axis enable. More...
 
#define LIS3DH_CTRL_REG1_XEN_SHIFT   (0)
 X enable bit offset.
 
#define LIS3DH_CTRL_REG1_XEN_MASK   (1 << LIS3DH_CTRL_REG1_XEN_SHIFT)
 X axis enable. More...
 
#define LIS3DH_CTRL_REG1_XYZEN_SHIFT   (0)
 XYZ enable bitfield offset.
 
#define LIS3DH_CTRL_REG1_XYZEN_MASK
 X, Y, Z enable bitfield mask. More...
 

Enumerations

enum  lis3dh_reg_t {
  LIS3DH_REG_STATUS_AUX = 0x07, LIS3DH_REG_OUT_AUX_ADC1_L = 0x08, LIS3DH_REG_OUT_AUX_ADC1_H = 0x09, LIS3DH_REG_OUT_AUX_ADC2_L = 0x0A,
  LIS3DH_REG_OUT_AUX_ADC2_H = 0x0B, LIS3DH_REG_OUT_AUX_ADC3_L = 0x0C, LIS3DH_REG_OUT_AUX_ADC3_H = 0x0D, LIS3DH_REG_INT_COUNTER_REG = 0x0E,
  LIS3DH_REG_WHO_AM_I = 0x0F, LIS3DH_REG_TEMP_CFG_REG = 0x1F, LIS3DH_REG_CTRL_REG1 = 0x20, LIS3DH_REG_CTRL_REG2 = 0x21,
  LIS3DH_REG_CTRL_REG3 = 0x22, LIS3DH_REG_CTRL_REG4 = 0x23, LIS3DH_REG_CTRL_REG5 = 0x24, LIS3DH_REG_CTRL_REG6 = 0x25,
  LIS3DH_REG_REFERENCE = 0x26, LIS3DH_REG_STATUS_REG = 0x27, LIS3DH_REG_OUT_X_L = 0x28, LIS3DH_REG_OUT_X_H = 0x29,
  LIS3DH_REG_OUT_Y_L = 0x2A, LIS3DH_REG_OUT_Y_H = 0x2B, LIS3DH_REG_OUT_Z_L = 0x2C, LIS3DH_REG_OUT_Z_H = 0x2D,
  LIS3DH_REG_FIFO_CTRL_REG = 0x2E, LIS3DH_REG_FIFO_SRC_REG = 0x2F, LIS3DH_REG_INT1_CFG = 0x30, LIS3DH_REG_INT1_SOURCE = 0x31,
  LIS3DH_REG_INT1_THS = 0x32, LIS3DH_REG_INT1_DURATION = 0x33, LIS3DH_REG_CLICK_CFG = 0x38, LIS3DH_REG_CLICK_SRC = 0x39,
  LIS3DH_REG_CLICK_THS = 0x3A, LIS3DH_REG_TIME_LIMIT = 0x3B, LIS3DH_REG_TIME_LATENCY = 0x3C, LIS3DH_REG_TIME_WINDOW = 0x3D
}
 LIS3DH hardware register addresses.
 

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

Output data rate selection bitfield macros

Default value: 0000

0000: Power down; Others: Refer to data sheet

See also
LIS3DH data sheet Table 25, “Data rate configuration”
#define LIS3DH_CTRL_REG1_ODR_SHIFT   (4)
 
#define LIS3DH_CTRL_REG1_ODR3_MASK   (1 << (LIS3DH_CTRL_REG1_ODR_SHIFT + 3))
 
#define LIS3DH_CTRL_REG1_ODR2_MASK   (1 << (LIS3DH_CTRL_REG1_ODR_SHIFT + 2))
 
#define LIS3DH_CTRL_REG1_ODR1_MASK   (1 << (LIS3DH_CTRL_REG1_ODR_SHIFT + 1))
 
#define LIS3DH_CTRL_REG1_ODR0_MASK   (1 << LIS3DH_CTRL_REG1_ODR_SHIFT)
 
#define LIS3DH_CTRL_REG1_ODR_MASK
 

Macro Definition Documentation

◆ LIS3DH_CTRL_REG1_LPEN_MASK

#define LIS3DH_CTRL_REG1_LPEN_MASK   (1 << 3)

Default value: 0

0. normal mode

  1. low power mode

Definition at line 149 of file lis3dh.h.

◆ LIS3DH_CTRL_REG1_ODR_MASK

#define LIS3DH_CTRL_REG1_ODR_MASK
Value:
(LIS3DH_CTRL_REG1_ODR3_MASK | \
LIS3DH_CTRL_REG1_ODR2_MASK | \
LIS3DH_CTRL_REG1_ODR1_MASK | \
LIS3DH_CTRL_REG1_ODR0_MASK)

Definition at line 134 of file lis3dh.h.

◆ LIS3DH_CTRL_REG1_XEN_MASK

#define LIS3DH_CTRL_REG1_XEN_MASK   (1 << LIS3DH_CTRL_REG1_XEN_SHIFT)

Default value: 1

0. X axis disabled

  1. X axis enabled

Definition at line 185 of file lis3dh.h.

◆ LIS3DH_CTRL_REG1_XYZEN_MASK

#define LIS3DH_CTRL_REG1_XYZEN_MASK
Value:
LIS3DH_CTRL_REG1_YEN_MASK | LIS3DH_CTRL_REG1_ZEN_MASK)
#define LIS3DH_CTRL_REG1_ZEN_MASK
Z axis enable.
Definition: lis3dh.h:161
#define LIS3DH_CTRL_REG1_XEN_MASK
X axis enable.
Definition: lis3dh.h:185

Definition at line 190 of file lis3dh.h.

◆ LIS3DH_CTRL_REG1_YEN_MASK

#define LIS3DH_CTRL_REG1_YEN_MASK   (1 << LIS3DH_CTRL_REG1_YEN_SHIFT)

Default value: 1

0. Y axis disabled

  1. Y axis enabled

Definition at line 173 of file lis3dh.h.

◆ LIS3DH_CTRL_REG1_ZEN_MASK

#define LIS3DH_CTRL_REG1_ZEN_MASK   (1 << LIS3DH_CTRL_REG1_ZEN_SHIFT)

Default value: 1

0. Z axis disabled

  1. Z axis enabled

Definition at line 161 of file lis3dh.h.

◆ LIS3DH_TEMP_CFG_REG_ADC_PD_MASK

#define LIS3DH_TEMP_CFG_REG_ADC_PD_MASK   (1 << 7)

Default value: 0

0: ADC disabled; 1: ADC enabled

Definition at line 100 of file lis3dh.h.

◆ LIS3DH_TEMP_CFG_REG_TEMP_EN_MASK

#define LIS3DH_TEMP_CFG_REG_TEMP_EN_MASK   (1 << 6)

Default value: 0

0: T disabled; 1: T enabled

Definition at line 109 of file lis3dh.h.