Skip to content

LSM6DSL

Frederic Pillon edited this page May 28, 2024 · 2 revisions

LSM6DSL

Arduino library to support the LSM6DSL 3D accelerometer and 3D gyroscope.

API

  • LSM6DSLSensor(TwoWire*, uint8_t): class constructor
    Params pointer to the I2C instance
    Params (optional) address of the component's instance

  • Enable_X: enable accelerometer
    Enable_G: enable gyroscope
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Disable_X: disable accelerometer
    Disable_G: disable gyroscope
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • ReadID(uint8_t*): read ID address
    Params pointer where store the ID of the device
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_X_Axes(int32_t*): read accelerometer data
    Get_G_Axes(int32_t*): read gyroscope data
    Params pointer where store the data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_X_Sensitivity(float*): read accelerometer sensitivity
    Get_G_Sensitivity(float*): read gyroscope sensitivity
    Params pointer where store the data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_X_AxesRaw(float*): read accelerometer raw data
    Get_G_AxesRaw(float*): read gyroscope raw data
    Params pointer where store the data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_X_ODR(float*): read the accelerometer output data rate
    Get_G_ODR(float*): read the gyroscope output data rate
    Params pointer where to store data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Set_X_ODR(float): set the accelerometer output data rate
    Set_G_ODR(float): set the gyroscope output data rate
    Params data rate to be set
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_X_FS(float*): read the accelerometer full scale
    Get_G_FS(float*): read the gyroscope full scale
    Params pointer where to store data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Set_X_FS(float): set the accelerometer full scale
    Set_G_FS(float): set the gyroscope full scale
    Params full scale to be set
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Enable_Free_Fall_Detection(LSM6DSL_Interrupt_Pin_t): enable free fall detection. Accelerometer ODR sets to 416Hz and full scale to 2g.
    Params (optional) interrupt pin to be used
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Disable_Free_Fall_Detection: disable free fall detection
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Set_Free_Fall_Threshold(uint8_t): set the accelerometer free fall detection threshold
    Params the threshold to be set
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Enable_Pedometer: enable the pedometer feature. Accelerometer ODR sets to 26Hz and full scale to 2g.
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Disable_Pedometer: disable the pedometer feature
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_Step_Counter(uint16_t*): read step counter
    Params pointer where to store data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Reset_Step_Counter: reset step counter
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Set_Pedometer_Threshold(uint8_t): set the pedometer threshold
    Params the threshold to be set
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Enable_Tilt_Detection(LSM6DSL_Interrupt_Pin_t): enable tilt detection. Accelerometer ODR sets to 26Hz and full scale to 2g.
    Params (optional) interrupt pin to be used
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Disable_Tilt_Detection: disable tilt detection
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Enable_Wake_Up_Detection(LSM6DSL_Interrupt_Pin_t): enable wake up detection. Accelerometer ODR sets to 416Hz and full scale to 2g.
    Params (optional) interrupt pin to be used
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Disable_Wake_Up_Detection: disable wake up detection
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Set_Wake_Up_Threshold(uint8_t): set the wake up threshold
    Params the threshold to be set
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Enable_Single_Tap_Detection(LSM6DSL_Interrupt_Pin_t): enable the single tap detection. Accelerometer ODR sets to 416Hz and full scale to 2g.
    Params (optional) interrupt pin to be used
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Disable_Single_Tap_Detection: disable single tap detection
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Enable_Double_Tap_Detection(LSM6DSL_Interrupt_Pin_t): enable the double tap detection. Accelerometer ODR sets to 416Hz and full scale to 2g.
    Params (optional) interrupt pin to be used
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Disable_Double_Tap_Detection: disable double tap detection
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Set_Tap_Threshold(uint8_t): set the tap threshold
    Params the threshold to be set
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Set_Tap_Shock_Time(uint8_t): set the tap shock time window
    Params the shock time window to be set
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Set_Tap_Quiet_Time(uint8_t): set the tap quiet time window
    Params the quiet time window to be set
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Set_Tap_Duration_Time(uint8_t): set the tap duration of the time window
    Params the duration of the time window to be set
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Enable_6D_Orientation(LSM6DSL_Interrupt_Pin_t): enable the 6D orientation detection. Accelerometer ODR sets to 416Hz and full scale to 2g.
    Params (optional) interrupt pin to be used
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Disable_6D_Orientation: disable the 6D orientation detection
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_6D_Orientation_XL(uint8_t*): read the XL axis data
    Params pointer where to store the data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_6D_Orientation_XH(uint8_t*): read the XH axis data
    Params pointer where to store the data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_6D_Orientation_YL(uint8_t*): read the YL axis data
    Params pointer where to store the data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_6D_Orientation_YH(uint8_t*): read the YH axis data
    Params pointer where to store the data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_6D_Orientation_ZL(uint8_t*): read the ZL axis data
    Params pointer where to store the data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_6D_Orientation_ZH(uint8_t*): read the ZH axis data
    Params pointer where to store the data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • Get_Event_Status(LSM6DSL_Event_Status_t*): read the status of all hardware events Params pointer where to store the event status Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • ReadReg(uint8_t, uint8_t*): read data from register
    Params register address
    Params pointer to register data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

  • WriteReg(uint8_t, uint8_t): write data to register
    Params register address
    Params register data
    Returns LSM6DSL_STATUS_OK in case of success, an error code otherwise

Note

This library uses the Wire library presents in the STM32 core by default.

Examples

  • DISCO_IOT_6DOrientation: detects and prints 6D orientation event
  • DISCO_IOT_DoubleTap: detects and prints double tap event
  • DISCO_IOT_FreeFall: detects and prints free fall event
  • DISCO_IOT_LS6DSL_DataLog_Terminal: reads accelerometer and gyroscope values and prints them
  • DISCO_IOT_MultiEvent: detects and prints free fall, tap, double tap, tilt, wake up, 6D orientation and step events
  • DISCO_IOT_Pedometer: detects and prints step event
  • DISCO_IOT_Tap: detects and prints single tap event
  • DISCO_IOT_Tilt: detects and prints tilt event
  • DISCO_IOT_WakeUp: detects and prints wakeup event

Source

You can find the source files at
https://github.com/stm32duino/LSM6DSL

Documentation

The LSM6DSL datasheet is available at
http://www.st.com/content/st_com/en/products/mems-and-sensors/inemo-inertial-modules/lsm6dsl.html

Clone this wiki locally