Library for interfacing STMicroelectronics LIS3DSH three-axis accelerometer.
The LIS3DSH is an ultra-low-power high- performance three-axis linear accelerometer with an embedded state machine that can be programmed to implement autonomous applications.
typical SPI clock speed to be used
typical I2C clock speed to be used (400kHz, I2C Fast-Mode)
configuration of clock polarity and clock phase for the LIS3DSH
Available LIS3DSH I2C addresses
CTRL4 configuration bits
Output data rate and power mode selection (CTRL4, bit 4-7)
Initializes communication with the LIS3DSH and prepares the LIS3DSH for use
In SPI mode (cs >= 0, addr =-1) first of all the used CS pin is configured as output and set to high so no data transfer takes place at the beginning. After that, regardless of the mode (SPI or I2C), the device ID is read out. If the ID register check succeeds, the two read-only information registers are read out. If they are also correct (no error is returned), the ADD_INC bit in control register 6 is set so that the address used to read/write data is increased at every block. Moreover, the two state machines are disabled.
Activates the LIS3DSH by setting the "CTRL4" register
Reads acceleration data in mg from the LIS3DSH
Sets the LIS3DSH into power-down mode (i.e. no data sampling is performed) and thus grants minimum power consumption
When accessing the CTRL4 register, only the ODR bits are set to "Power-down". All other bits of the CTRL4 register remain unchanged.
absolute maximum SPI clock speed (10MHz)
absolute maximum I2C clock speed
Available register (Address | R/W | Default | Description)
The vector filter is a 7th-order anti-symmetric FIR filter. The 8 taps have a 4x2 structure:
VFC_1, VFC_2, VFC_3, VFC_4 and -VFC_1, -VFC_2, -VFC_3, -VFC_4.
State machine 1 system register is made up of 16, 8-bit registers to implement 16-step op-code (Use LIS3DSH_LoadStateMachine()).
State machine 2 system register is made up of 16, 8-bit registers to implement 16-step op-code (Use LIS3DSH_LoadStateMachine()).
Interrupt status - interrupt synchronization register bits
CTRL1 configuration bits
CTRL2 configuration bits
CTRL3 configuration bits
CTRL5 configuration bits
Anti-aliasing filter bandwidth (CTRL5, bit 6-7)
Full-scale selection (CTRL5, bit 3-5)
elf-test enable (CTRL5, bit 1-2)
CTRL6 configuration bits
Status data register bits
FIFO control register configuration bits
FIFO mode selection (FIFO_CTRL, bit 5-7)
FIFO SRC control register bits
MASK1_B, MASK1_A, MASK2_B and MASK2_A register configuration bits
SETT1/SETT2 register configuration bits
PR1/PR2 register bits
OUTS1/OUTS2 register bits
Available state machines
State machine register offsets
Contains state machine register information
Reads register of LIS3DSH
Reads raw data from a number of LIS3DSH registers
Writes register of LIS3DSH
Writes a number of LIS3DSH registers
Reads raw acceleration data from the LIS3DSH
Enables state machine
The function detects at first which state machine should be used (1 or 2) and initialises the associated register addresses. After disabling the state machine, the 16-byte code is handed over to the LIS3DSH_WriteBuf() function. Additional state machine registers are then also initialised. See the LIS3DSH datasheet for further information. When the process is finished, the state machine is enabled.
Disables state machine
The function detects which state machine should be disabled and then clears the SMx_EN bit in the corresponding register (CTRL1 or CTRL2). All other bits of the register remain unchanged.