Workshop example

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Embed: (wiki syntax)

« Back to documentation index

LSM6DSLSensor Class Reference

LSM6DSLSensor Class Reference

Abstract class of an LSM6DSL Inertial Measurement Unit (IMU) 6 axes sensor. More...

#include <LSM6DSLSensor.h>

Public Member Functions

 LSM6DSLSensor (DevI2C *i2c, uint8_t address=LSM6DSL_ACC_GYRO_I2C_ADDRESS_HIGH, PinName INT1_pin=NC, PinName INT2_pin=NC)
 Constructor.
virtual int init (void *init)
 Initializing the component.
virtual int read_id (uint8_t *id)
 Read ID of LSM6DSL Accelerometer and Gyroscope.
virtual int get_x_axes (int32_t *pData)
 Read data from LSM6DSL Accelerometer.
virtual int get_g_axes (int32_t *pData)
 Read data from LSM6DSL Gyroscope.
virtual int get_x_sensitivity (float *pfData)
 Read Accelerometer Sensitivity.
virtual int get_g_sensitivity (float *pfData)
 Read Gyroscope Sensitivity.
virtual int get_x_axes_raw (int16_t *pData)
 Read raw data from LSM6DSL Accelerometer.
virtual int get_g_axes_raw (int16_t *pData)
 Read raw data from LSM6DSL Gyroscope.
virtual int get_x_odr (float *odr)
 Read LSM6DSL Accelerometer output data rate.
virtual int get_g_odr (float *odr)
 Read LSM6DSL Gyroscope output data rate.
virtual int set_x_odr (float odr)
 Set LSM6DSL Accelerometer output data rate.
virtual int set_g_odr (float odr)
 Set LSM6DSL Gyroscope output data rate.
virtual int get_x_fs (float *fullScale)
 Read LSM6DSL Accelerometer full scale.
virtual int get_g_fs (float *fullScale)
 Read LSM6DSL Gyroscope full scale.
virtual int set_x_fs (float fullScale)
 Set LSM6DSL Accelerometer full scale.
virtual int set_g_fs (float fullScale)
 Set LSM6DSL Gyroscope full scale.
int enable_x (void)
 Enable LSM6DSL Accelerator.
int enable_g (void)
 Enable LSM6DSL Gyroscope.
int disable_x (void)
 Disable LSM6DSL Accelerator.
int disable_g (void)
 Disable LSM6DSL Gyroscope.
int enable_free_fall_detection (LSM6DSL_Interrupt_Pin_t pin=LSM6DSL_INT1_PIN)
 Enable free fall detection.
int disable_free_fall_detection (void)
 Disable free fall detection.
int set_free_fall_threshold (uint8_t thr)
 Set the free fall detection threshold for LSM6DSL accelerometer sensor.
int enable_pedometer (void)
 Enable the pedometer feature for LSM6DSL accelerometer sensor.
int disable_pedometer (void)
 Disable the pedometer feature for LSM6DSL accelerometer sensor.
int get_step_counter (uint16_t *step_count)
 Get the step counter for LSM6DSL accelerometer sensor.
int reset_step_counter (void)
 Reset of the step counter for LSM6DSL accelerometer sensor.
int set_pedometer_threshold (uint8_t thr)
 Set the pedometer threshold for LSM6DSL accelerometer sensor.
int enable_tilt_detection (LSM6DSL_Interrupt_Pin_t pin=LSM6DSL_INT1_PIN)
 Enable the tilt detection for LSM6DSL accelerometer sensor.
int disable_tilt_detection (void)
 Disable the tilt detection for LSM6DSL accelerometer sensor.
int enable_wake_up_detection (LSM6DSL_Interrupt_Pin_t pin=LSM6DSL_INT2_PIN)
 Enable the wake up detection for LSM6DSL accelerometer sensor.
int disable_wake_up_detection (void)
 Disable the wake up detection for LSM6DSL accelerometer sensor.
int set_wake_up_threshold (uint8_t thr)
 Set the wake up threshold for LSM6DSL accelerometer sensor.
int enable_single_tap_detection (LSM6DSL_Interrupt_Pin_t pin=LSM6DSL_INT1_PIN)
 Enable the single tap detection for LSM6DSL accelerometer sensor.
int disable_single_tap_detection (void)
 Disable the single tap detection for LSM6DSL accelerometer sensor.
int enable_double_tap_detection (LSM6DSL_Interrupt_Pin_t pin=LSM6DSL_INT1_PIN)
 Enable the double tap detection for LSM6DSL accelerometer sensor.
int disable_double_tap_detection (void)
 Disable the double tap detection for LSM6DSL accelerometer sensor.
int set_tap_threshold (uint8_t thr)
 Set the tap threshold for LSM6DSL accelerometer sensor.
int set_tap_shock_time (uint8_t time)
 Set the tap shock time window for LSM6DSL accelerometer sensor.
int set_tap_quiet_time (uint8_t time)
 Set the tap quiet time window for LSM6DSL accelerometer sensor.
int set_tap_duration_time (uint8_t time)
 Set the tap duration of the time window for LSM6DSL accelerometer sensor.
int enable_6d_orientation (LSM6DSL_Interrupt_Pin_t pin=LSM6DSL_INT1_PIN)
 Enable the 6D orientation detection for LSM6DSL accelerometer sensor.
int disable_6d_orientation (void)
 Disable the 6D orientation detection for LSM6DSL accelerometer sensor.
int get_6d_orientation_xl (uint8_t *xl)
 Get the 6D orientation XL axis for LSM6DSL accelerometer sensor.
int get_6d_orientation_xh (uint8_t *xh)
 Get the 6D orientation XH axis for LSM6DSL accelerometer sensor.
int get_6d_orientation_yl (uint8_t *yl)
 Get the 6D orientation YL axis for LSM6DSL accelerometer sensor.
int get_6d_orientation_yh (uint8_t *yh)
 Get the 6D orientation YH axis for LSM6DSL accelerometer sensor.
int get_6d_orientation_zl (uint8_t *zl)
 Get the 6D orientation ZL axis for LSM6DSL accelerometer sensor.
int get_6d_orientation_zh (uint8_t *zh)
 Get the 6D orientation ZH axis for LSM6DSL accelerometer sensor.
int get_event_status (LSM6DSL_Event_Status_t *status)
 Get the status of all hardware events for LSM6DSL accelerometer sensor.
int read_reg (uint8_t reg, uint8_t *data)
 Read the data from register.
int write_reg (uint8_t reg, uint8_t data)
 Write the data to register.
void attach_int1_irq (void(*fptr)(void))
 Attaching an interrupt handler to the INT1 interrupt.
void enable_int1_irq (void)
 Enabling the INT1 interrupt handling.
void disable_int1_irq (void)
 Disabling the INT1 interrupt handling.
void attach_int2_irq (void(*fptr)(void))
 Attaching an interrupt handler to the INT2 interrupt.
void enable_int2_irq (void)
 Enabling the INT2 interrupt handling.
void disable_int2_irq (void)
 Disabling the INT2 interrupt handling.
uint8_t io_read (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead)
 Utility function to read data.
uint8_t io_write (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite)
 Utility function to write data.

Detailed Description

Abstract class of an LSM6DSL Inertial Measurement Unit (IMU) 6 axes sensor.

Definition at line 126 of file LSM6DSLSensor.h.


Constructor & Destructor Documentation

LSM6DSLSensor ( DevI2C *  i2c,
uint8_t  address = LSM6DSL_ACC_GYRO_I2C_ADDRESS_HIGH,
PinName  int1_pin = NC,
PinName  int2_pin = NC 
)

Constructor.

Parameters:
i2cobject of an helper class which handles the I2C peripheral
addressthe address of the component's instance

Definition at line 71 of file LSM6DSLSensor.cpp.


Member Function Documentation

void attach_int1_irq ( void(*)(void)  fptr )

Attaching an interrupt handler to the INT1 interrupt.

Parameters:
fptrAn interrupt handler.
Return values:
None.

Definition at line 190 of file LSM6DSLSensor.h.

void attach_int2_irq ( void(*)(void)  fptr )

Attaching an interrupt handler to the INT2 interrupt.

Parameters:
fptrAn interrupt handler.
Return values:
None.

Definition at line 220 of file LSM6DSLSensor.h.

int disable_6d_orientation ( void   )

Disable the 6D orientation detection for LSM6DSL accelerometer sensor.

Return values:
0in case of success, an error code otherwise

Definition at line 1788 of file LSM6DSLSensor.cpp.

int disable_double_tap_detection ( void   )

Disable the double tap detection for LSM6DSL accelerometer sensor.

Return values:
0in case of success, an error code otherwise

Definition at line 1597 of file LSM6DSLSensor.cpp.

int disable_free_fall_detection ( void   )

Disable free fall detection.

Parameters:
None
Return values:
0in case of success, an error code otherwise

Definition at line 952 of file LSM6DSLSensor.cpp.

int disable_g ( void   )

Disable LSM6DSL Gyroscope.

Return values:
0in case of success, an error code otherwise

Definition at line 218 of file LSM6DSLSensor.cpp.

void disable_int1_irq ( void   )

Disabling the INT1 interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 210 of file LSM6DSLSensor.h.

void disable_int2_irq ( void   )

Disabling the INT2 interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 240 of file LSM6DSLSensor.h.

int disable_pedometer ( void   )

Disable the pedometer feature for LSM6DSL accelerometer sensor.

Return values:
0in case of success, an error code otherwise

Definition at line 1053 of file LSM6DSLSensor.cpp.

int disable_single_tap_detection ( void   )

Disable the single tap detection for LSM6DSL accelerometer sensor.

Return values:
0in case of success, an error code otherwise

Definition at line 1432 of file LSM6DSLSensor.cpp.

int disable_tilt_detection ( void   )

Disable the tilt detection for LSM6DSL accelerometer sensor.

Return values:
0in case of success, an error code otherwise

Definition at line 1193 of file LSM6DSLSensor.cpp.

int disable_wake_up_detection ( void   )

Disable the wake up detection for LSM6DSL accelerometer sensor.

Return values:
0in case of success, an error code otherwise

Definition at line 1288 of file LSM6DSLSensor.cpp.

int disable_x ( void   )

Disable LSM6DSL Accelerator.

Return values:
0in case of success, an error code otherwise

Definition at line 189 of file LSM6DSLSensor.cpp.

int enable_6d_orientation ( LSM6DSL_Interrupt_Pin_t  pin = LSM6DSL_INT1_PIN )

Enable the 6D orientation detection for LSM6DSL accelerometer sensor.

Parameters:
pinthe interrupt pin to be used
Note:
This function sets the LSM6DSL accelerometer ODR to 416Hz and the LSM6DSL accelerometer full scale to 2g
Return values:
0in case of success, an error code otherwise

Definition at line 1734 of file LSM6DSLSensor.cpp.

int enable_double_tap_detection ( LSM6DSL_Interrupt_Pin_t  pin = LSM6DSL_INT1_PIN )

Enable the double tap detection for LSM6DSL accelerometer sensor.

Parameters:
pinthe interrupt pin to be used
Note:
This function sets the LSM6DSL accelerometer ODR to 416Hz and the LSM6DSL accelerometer full scale to 2g
Return values:
0in case of success, an error code otherwise

Definition at line 1501 of file LSM6DSLSensor.cpp.

int enable_free_fall_detection ( LSM6DSL_Interrupt_Pin_t  pin = LSM6DSL_INT1_PIN )

Enable free fall detection.

Parameters:
pinthe interrupt pin to be used
Note:
This function sets the LSM6DSL accelerometer ODR to 416Hz and the LSM6DSL accelerometer full scale to 2g
Return values:
0in case of success, an error code otherwise

Definition at line 873 of file LSM6DSLSensor.cpp.

int enable_g ( void   )

Enable LSM6DSL Gyroscope.

Return values:
0in case of success, an error code otherwise

Definition at line 166 of file LSM6DSLSensor.cpp.

void enable_int1_irq ( void   )

Enabling the INT1 interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 200 of file LSM6DSLSensor.h.

void enable_int2_irq ( void   )

Enabling the INT2 interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 230 of file LSM6DSLSensor.h.

int enable_pedometer ( void   )

Enable the pedometer feature for LSM6DSL accelerometer sensor.

Note:
This function sets the LSM6DSL accelerometer ODR to 26Hz and the LSM6DSL accelerometer full scale to 2g
Return values:
0in case of success, an error code otherwise

Definition at line 1008 of file LSM6DSLSensor.cpp.

int enable_single_tap_detection ( LSM6DSL_Interrupt_Pin_t  pin = LSM6DSL_INT1_PIN )

Enable the single tap detection for LSM6DSL accelerometer sensor.

Parameters:
pinthe interrupt pin to be used
Note:
This function sets the LSM6DSL accelerometer ODR to 416Hz and the LSM6DSL accelerometer full scale to 2g
Return values:
0in case of success, an error code otherwise

Definition at line 1344 of file LSM6DSLSensor.cpp.

int enable_tilt_detection ( LSM6DSL_Interrupt_Pin_t  pin = LSM6DSL_INT1_PIN )

Enable the tilt detection for LSM6DSL accelerometer sensor.

Parameters:
pinthe interrupt pin to be used
Note:
This function sets the LSM6DSL accelerometer ODR to 26Hz and the LSM6DSL accelerometer full scale to 2g
Return values:
0in case of success, an error code otherwise

Definition at line 1139 of file LSM6DSLSensor.cpp.

int enable_wake_up_detection ( LSM6DSL_Interrupt_Pin_t  pin = LSM6DSL_INT2_PIN )

Enable the wake up detection for LSM6DSL accelerometer sensor.

Parameters:
pinthe interrupt pin to be used
Note:
This function sets the LSM6DSL accelerometer ODR to 416Hz and the LSM6DSL accelerometer full scale to 2g
Return values:
0in case of success, an error code otherwise

Definition at line 1228 of file LSM6DSLSensor.cpp.

int enable_x ( void   )

Enable LSM6DSL Accelerator.

Return values:
0in case of success, an error code otherwise

Definition at line 143 of file LSM6DSLSensor.cpp.

int get_6d_orientation_xh ( uint8_t *  xh )

Get the 6D orientation XH axis for LSM6DSL accelerometer sensor.

Parameters:
xhthe pointer to the 6D orientation XH axis
Return values:
0in case of success, an error code otherwise

Definition at line 1851 of file LSM6DSLSensor.cpp.

int get_6d_orientation_xl ( uint8_t *  xl )

Get the 6D orientation XL axis for LSM6DSL accelerometer sensor.

Parameters:
xlthe pointer to the 6D orientation XL axis
Return values:
0in case of success, an error code otherwise

Definition at line 1822 of file LSM6DSLSensor.cpp.

int get_6d_orientation_yh ( uint8_t *  yh )

Get the 6D orientation YH axis for LSM6DSL accelerometer sensor.

Parameters:
yhthe pointer to the 6D orientation YH axis
Return values:
0in case of success, an error code otherwise

Definition at line 1909 of file LSM6DSLSensor.cpp.

int get_6d_orientation_yl ( uint8_t *  yl )

Get the 6D orientation YL axis for LSM6DSL accelerometer sensor.

Parameters:
ylthe pointer to the 6D orientation YL axis
Return values:
0in case of success, an error code otherwise

Definition at line 1880 of file LSM6DSLSensor.cpp.

int get_6d_orientation_zh ( uint8_t *  zh )

Get the 6D orientation ZH axis for LSM6DSL accelerometer sensor.

Parameters:
zhthe pointer to the 6D orientation ZH axis
Return values:
0in case of success, an error code otherwise

Definition at line 1967 of file LSM6DSLSensor.cpp.

int get_6d_orientation_zl ( uint8_t *  zl )

Get the 6D orientation ZL axis for LSM6DSL accelerometer sensor.

Parameters:
zlthe pointer to the 6D orientation ZL axis
Return values:
0in case of success, an error code otherwise

Definition at line 1938 of file LSM6DSLSensor.cpp.

int get_event_status ( LSM6DSL_Event_Status_t *  status )

Get the status of all hardware events for LSM6DSL accelerometer sensor.

Parameters:
statusthe pointer to the status of all hardware events
Return values:
0in case of success, an error code otherwise

Definition at line 1996 of file LSM6DSLSensor.cpp.

int get_g_axes ( int32_t *  pData ) [virtual]

Read data from LSM6DSL Gyroscope.

Parameters:
pDatathe pointer where the gyroscope data are stored
Return values:
0in case of success, an error code otherwise

Definition at line 299 of file LSM6DSLSensor.cpp.

int get_g_axes_raw ( int16_t *  pData ) [virtual]

Read raw data from LSM6DSL Gyroscope.

Parameters:
pDatathe pointer where the gyroscope raw data are stored
Return values:
0in case of success, an error code otherwise

Definition at line 444 of file LSM6DSLSensor.cpp.

int get_g_fs ( float *  fullScale ) [virtual]

Read LSM6DSL Gyroscope full scale.

Parameters:
fullScalethe pointer to the full scale
Return values:
0in case of success, an error code otherwise

Definition at line 765 of file LSM6DSLSensor.cpp.

int get_g_odr ( float *  odr ) [virtual]

Read LSM6DSL Gyroscope output data rate.

Parameters:
odrthe pointer to the output data rate
Return values:
0in case of success, an error code otherwise

Definition at line 524 of file LSM6DSLSensor.cpp.

int get_g_sensitivity ( float *  pfData ) [virtual]

Read Gyroscope Sensitivity.

Parameters:
pfDatathe pointer where the gyroscope sensitivity is stored
Return values:
0in case of success, an error code otherwise

Definition at line 367 of file LSM6DSLSensor.cpp.

int get_step_counter ( uint16_t *  step_count )

Get the step counter for LSM6DSL accelerometer sensor.

Parameters:
step_countthe pointer to the step counter
Return values:
0in case of success, an error code otherwise

Definition at line 1087 of file LSM6DSLSensor.cpp.

int get_x_axes ( int32_t *  pData ) [virtual]

Read data from LSM6DSL Accelerometer.

Parameters:
pDatathe pointer where the accelerometer data are stored
Return values:
0in case of success, an error code otherwise

Definition at line 269 of file LSM6DSLSensor.cpp.

int get_x_axes_raw ( int16_t *  pData ) [virtual]

Read raw data from LSM6DSL Accelerometer.

Parameters:
pDatathe pointer where the accelerometer raw data are stored
Return values:
0in case of success, an error code otherwise

Definition at line 421 of file LSM6DSLSensor.cpp.

int get_x_fs ( float *  fullScale ) [virtual]

Read LSM6DSL Accelerometer full scale.

Parameters:
fullScalethe pointer to the full scale
Return values:
0in case of success, an error code otherwise

Definition at line 729 of file LSM6DSLSensor.cpp.

int get_x_odr ( float *  odr ) [virtual]

Read LSM6DSL Accelerometer output data rate.

Parameters:
odrthe pointer to the output data rate
Return values:
0in case of success, an error code otherwise

Definition at line 467 of file LSM6DSLSensor.cpp.

int get_x_sensitivity ( float *  pfData ) [virtual]

Read Accelerometer Sensitivity.

Parameters:
pfDatathe pointer where the accelerometer sensitivity is stored
Return values:
0in case of success, an error code otherwise

Definition at line 329 of file LSM6DSLSensor.cpp.

int init ( void *  init ) [virtual]

Initializing the component.

Parameters:
[in]initpointer to device specific initalization structure.
Return values:
0in case of success, an error code otherwise.

Definition at line 83 of file LSM6DSLSensor.cpp.

uint8_t io_read ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToRead 
)

Utility function to read data.

Parameters:
pBuffer,:pointer to data to be read.
RegisterAddr,:specifies internal address register to be read.
NumByteToRead,:number of bytes to be read.
Return values:
0if ok, an error code otherwise.

Definition at line 252 of file LSM6DSLSensor.h.

uint8_t io_write ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToWrite 
)

Utility function to write data.

Parameters:
pBuffer,:pointer to data to be written.
RegisterAddr,:specifies internal address register to be written.
NumByteToWrite,:number of bytes to write.
Return values:
0if ok, an error code otherwise.

Definition at line 283 of file LSM6DSLSensor.h.

int read_id ( uint8_t *  id ) [virtual]

Read ID of LSM6DSL Accelerometer and Gyroscope.

Parameters:
p_idthe pointer where the ID of the device is stored
Return values:
0in case of success, an error code otherwise

Definition at line 248 of file LSM6DSLSensor.cpp.

int read_reg ( uint8_t  reg,
uint8_t *  data 
)

Read the data from register.

Parameters:
regregister address
dataregister data
Return values:
0in case of success, an error code otherwise

Definition at line 2102 of file LSM6DSLSensor.cpp.

int reset_step_counter ( void   )

Reset of the step counter for LSM6DSL accelerometer sensor.

Return values:
0in case of success, an error code otherwise

Definition at line 1101 of file LSM6DSLSensor.cpp.

int set_free_fall_threshold ( uint8_t  thr )

Set the free fall detection threshold for LSM6DSL accelerometer sensor.

Parameters:
thrthe threshold to be set
Return values:
0in case of success, an error code otherwise

Definition at line 992 of file LSM6DSLSensor.cpp.

int set_g_fs ( float  fullScale ) [virtual]

Set LSM6DSL Gyroscope full scale.

Parameters:
fullScalethe full scale to be set
Return values:
0in case of success, an error code otherwise

Definition at line 836 of file LSM6DSLSensor.cpp.

int set_g_odr ( float  odr ) [virtual]

Set LSM6DSL Gyroscope output data rate.

Parameters:
odrthe output data rate to be set
Return values:
0in case of success, an error code otherwise

Definition at line 655 of file LSM6DSLSensor.cpp.

int set_pedometer_threshold ( uint8_t  thr )

Set the pedometer threshold for LSM6DSL accelerometer sensor.

Parameters:
thrthe threshold to be set
Return values:
0in case of success, an error code otherwise

Definition at line 1123 of file LSM6DSLSensor.cpp.

int set_tap_duration_time ( uint8_t  time )

Set the tap duration of the time window for LSM6DSL accelerometer sensor.

Parameters:
timethe duration of the time window to be set
Return values:
0in case of success, an error code otherwise

Definition at line 1718 of file LSM6DSLSensor.cpp.

int set_tap_quiet_time ( uint8_t  time )

Set the tap quiet time window for LSM6DSL accelerometer sensor.

Parameters:
timethe quiet time window to be set
Return values:
0in case of success, an error code otherwise

Definition at line 1703 of file LSM6DSLSensor.cpp.

int set_tap_shock_time ( uint8_t  time )

Set the tap shock time window for LSM6DSL accelerometer sensor.

Parameters:
timethe shock time window to be set
Return values:
0in case of success, an error code otherwise

Definition at line 1688 of file LSM6DSLSensor.cpp.

int set_tap_threshold ( uint8_t  thr )

Set the tap threshold for LSM6DSL accelerometer sensor.

Parameters:
thrthe threshold to be set
Return values:
0in case of success, an error code otherwise

Definition at line 1673 of file LSM6DSLSensor.cpp.

int set_wake_up_threshold ( uint8_t  thr )

Set the wake up threshold for LSM6DSL accelerometer sensor.

Parameters:
thrthe threshold to be set
Return values:
0in case of success, an error code otherwise

Definition at line 1328 of file LSM6DSLSensor.cpp.

int set_x_fs ( float  fullScale ) [virtual]

Set LSM6DSL Accelerometer full scale.

Parameters:
fullScalethe full scale to be set
Return values:
0in case of success, an error code otherwise

Definition at line 814 of file LSM6DSLSensor.cpp.

int set_x_odr ( float  odr ) [virtual]

Set LSM6DSL Accelerometer output data rate.

Parameters:
odrthe output data rate to be set
Return values:
0in case of success, an error code otherwise

Definition at line 581 of file LSM6DSLSensor.cpp.

int write_reg ( uint8_t  reg,
uint8_t  data 
)

Write the data to register.

Parameters:
regregister address
dataregister data
Return values:
0in case of success, an error code otherwise

Definition at line 2119 of file LSM6DSLSensor.cpp.