Firmware Library for X-NUCLEO-IKS01A1 (MEMS Inertial & Environmental Sensors) Expansion Board

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   MultiTech_Dragonfly_2015_ATT_Gov_Solutions_Hackathon_Example HelloWorld_IKS01A1 LoRaWAN-test-10secs ServoMotorDemo ... more

Fork of X_NUCLEO_IKS01A1 by ST Expansion SW Team

Embed: (wiki syntax)

« Back to documentation index

LSM6DS3 Class Reference

Class representing a LSM6DS3 sensor component. More...

#include <lsm6ds3_class.h>

Public Member Functions

 LSM6DS3 (DevI2C &i2c, PinName irq_pin)
 Constructor.
virtual ~LSM6DS3 ()
 Destructor.
IMU_6AXES_StatusTypeDef Enable_Free_Fall_Detection (void)
 Enable free fall detection.
IMU_6AXES_StatusTypeDef Disable_Free_Fall_Detection (void)
 Disable free fall detection.
IMU_6AXES_StatusTypeDef Get_Status_Free_Fall_Detection (uint8_t *status)
 Get status of free fall detection.
void Attach_Free_Fall_Detection_IRQ (void(*fptr)(void))
 Attach a function to call when a free fall is detected.
void Enable_Free_Fall_Detection_IRQ (void)
 Enable Free Fall IRQ.
void Disable_Free_Fall_Detection_IRQ (void)
 Disable free Fall IRQ.

Protected Member Functions

IMU_6AXES_StatusTypeDef LSM6DS3_Init (IMU_6AXES_InitTypeDef *LSM6DS3_Init)
 Set LSM6DS3 Initialization.
IMU_6AXES_StatusTypeDef LSM6DS3_Read_XG_ID (uint8_t *xg_id)
 Read ID of LSM6DS3 Accelerometer and Gyroscope.
IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxes (int32_t *pData)
 Read data from LSM6DS3 Accelerometer and calculate linear acceleration in mg.
IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxesRaw (int16_t *pData)
 Read raw data from LSM6DS3 Accelerometer output register.
IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxes (int32_t *pData)
 Read data from LSM6DS3 Gyroscope and calculate angular rate in mdps.
IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxesRaw (int16_t *pData)
 Read raw data from LSM6DS3 Gyroscope output register.
IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_ODR (float *odr)
 Read Accelero Output Data Rate.
IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_ODR (float odr)
 Write Accelero Output Data Rate.
IMU_6AXES_StatusTypeDef LSM6DS3_X_GetSensitivity (float *pfData)
 Read Accelero Sensitivity.
IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_FS (float *fullScale)
 Read Accelero Full Scale.
IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_FS (float fullScale)
 Write Accelero Full Scale.
IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_ODR (float *odr)
 Read Gyro Output Data Rate.
IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_ODR (float odr)
 Write Gyro Output Data Rate.
IMU_6AXES_StatusTypeDef LSM6DS3_G_GetSensitivity (float *pfData)
 Read Gyro Sensitivity.
IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_FS (float *fullScale)
 Read Gyro Full Scale.
IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_FS (float fullScale)
 Write Gyro Full Scale.
IMU_6AXES_StatusTypeDef LSM6DS3_Enable_Free_Fall_Detection (void)
 Enable free fall detection.
IMU_6AXES_StatusTypeDef LSM6DS3_Disable_Free_Fall_Detection (void)
 Disable free fall detection.
IMU_6AXES_StatusTypeDef LSM6DS3_Get_Status_Free_Fall_Detection (uint8_t *status)
 Get status of free fall detection.
IMU_6AXES_StatusTypeDef LSM6DS3_Common_Sensor_Enable (void)
 Set LSM6DS3 common initialization.
IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_Axes_Status (uint8_t enableX, uint8_t enableY, uint8_t enableZ)
 Set the status of the axes for accelerometer.
IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_Axes_Status (uint8_t enableX, uint8_t enableY, uint8_t enableZ)
 Set the status of the axes for gyroscope.
void LSM6DS3_IO_ITConfig (void)
 Configures LSM6DS3 interrupt lines for NUCLEO boards.
IMU_6AXES_StatusTypeDef LSM6DS3_IO_Init (void)
 Configures LSM6DS3 I2C interface.
IMU_6AXES_StatusTypeDef LSM6DS3_IO_Read (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToRead)
 Utility function to read data from LSM6DS3.
IMU_6AXES_StatusTypeDef LSM6DS3_IO_Write (uint8_t *pBuffer, uint8_t RegisterAddr, uint16_t NumByteToWrite)
 Utility function to write data to LSM6DS3.

Detailed Description

Class representing a LSM6DS3 sensor component.

Definition at line 51 of file lsm6ds3_class.h.


Constructor & Destructor Documentation

LSM6DS3 ( DevI2C &  i2c,
PinName  irq_pin 
)

Constructor.

Parameters:
[in]i2cdevice I2C to be used for communication
[in]irq_pinpin name for free fall detection interrupt

Definition at line 57 of file lsm6ds3_class.h.

virtual ~LSM6DS3 (  ) [virtual]

Destructor.

Definition at line 63 of file lsm6ds3_class.h.


Member Function Documentation

void Attach_Free_Fall_Detection_IRQ ( void(*)(void)  fptr )

Attach a function to call when a free fall is detected.

Parameters:
[in]fptrA pointer to a void function, or 0 to set as none

Definition at line 161 of file lsm6ds3_class.h.

IMU_6AXES_StatusTypeDef Disable_Free_Fall_Detection ( void   )

Disable free fall detection.

Returns:
IMU_6AXES_OK in case of success, an error code otherwise

Definition at line 143 of file lsm6ds3_class.h.

void Disable_Free_Fall_Detection_IRQ ( void   )

Disable free Fall IRQ.

Definition at line 173 of file lsm6ds3_class.h.

IMU_6AXES_StatusTypeDef Enable_Free_Fall_Detection ( void   )

Enable free fall detection.

Returns:
IMU_6AXES_OK in case of success, an error code otherwise

Definition at line 135 of file lsm6ds3_class.h.

void Enable_Free_Fall_Detection_IRQ ( void   )

Enable Free Fall IRQ.

Definition at line 167 of file lsm6ds3_class.h.

IMU_6AXES_StatusTypeDef Get_Status_Free_Fall_Detection ( uint8_t *  status )

Get status of free fall detection.

Parameters:
[out]statusthe pointer where the status of free fall detection is stored; 0 means no detection, 1 means detection happened
Returns:
IMU_6AXES_OK in case of success, an error code otherwise

Definition at line 153 of file lsm6ds3_class.h.

IMU_6AXES_StatusTypeDef LSM6DS3_Common_Sensor_Enable ( void   ) [protected]

Set LSM6DS3 common initialization.

Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 132 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_Disable_Free_Fall_Detection ( void   ) [protected]

Disable free fall detection.

Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 950 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_Enable_Free_Fall_Detection ( void   ) [protected]

Enable free fall detection.

Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 863 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_FS ( float *  fullScale ) [protected]

Read Gyro Full Scale.

Parameters:
fullScalethe pointer where the gyroscope full scale is stored
Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 746 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_G_Get_ODR ( float *  odr ) [protected]

Read Gyro Output Data Rate.

Parameters:
odrthe pointer where the gyroscope output data rate is stored
Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 604 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxes ( int32_t *  pData ) [protected]

Read data from LSM6DS3 Gyroscope and calculate angular rate in mdps.

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

Definition at line 368 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_G_GetAxesRaw ( int16_t *  pData ) [protected]

Read raw data from LSM6DS3 Gyroscope output register.

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

Definition at line 246 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_G_GetSensitivity ( float *  pfData ) [protected]

Read Gyro Sensitivity.

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

Definition at line 693 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_Axes_Status ( uint8_t  enableX,
uint8_t  enableY,
uint8_t  enableZ 
) [protected]

Set the status of the axes for gyroscope.

Parameters:
enableXthe status of the x axis to be set
enableYthe status of the y axis to be set
enableZthe status of the z axis to be set
Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 327 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_FS ( float  fullScale ) [protected]

Write Gyro Full Scale.

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

Definition at line 799 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_G_Set_ODR ( float  odr ) [protected]

Write Gyro Output Data Rate.

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

Definition at line 657 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_Get_Status_Free_Fall_Detection ( uint8_t *  status ) [protected]

Get status of free fall detection.

Parameters:
statusthe pointer where the status of free fall detection is stored; 0 means no detection, 1 means detection happened
Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 994 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_Init ( IMU_6AXES_InitTypeDef LSM6DS3_Init ) [protected]

Set LSM6DS3 Initialization.

Parameters:
LSM6DS3_Initthe configuration setting for the LSM6DS3
Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 53 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_IO_Init ( void   ) [protected]

Configures LSM6DS3 I2C interface.

Returns:
IMU_6AXES_OK in case of success, an error code otherwise

Definition at line 215 of file lsm6ds3_class.h.

void LSM6DS3_IO_ITConfig ( void   ) [protected]

Configures LSM6DS3 interrupt lines for NUCLEO boards.

Definition at line 206 of file lsm6ds3_class.h.

IMU_6AXES_StatusTypeDef LSM6DS3_IO_Read ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToRead 
) [protected]

Utility function to read data from LSM6DS3.

Parameters:
[out]pBufferpointer to the byte-array to read data in to
[in]RegisterAddrspecifies internal address register to read from.
[in]NumByteToReadnumber of bytes to be read.
Return values:
IMU_6AXES_OKif ok,
IMU_6AXES_ERRORif an I2C error has occured

Definition at line 228 of file lsm6ds3_class.h.

IMU_6AXES_StatusTypeDef LSM6DS3_IO_Write ( uint8_t *  pBuffer,
uint8_t  RegisterAddr,
uint16_t  NumByteToWrite 
) [protected]

Utility function to write data to LSM6DS3.

Parameters:
[in]pBufferpointer to the byte-array data to send
[in]RegisterAddrspecifies internal address register to read from.
[in]NumByteToWritenumber of bytes to write.
Return values:
IMU_6AXES_OKif ok,
IMU_6AXES_ERRORif an I2C error has occured

Definition at line 249 of file lsm6ds3_class.h.

IMU_6AXES_StatusTypeDef LSM6DS3_Read_XG_ID ( uint8_t *  xg_id ) [protected]

Read ID of LSM6DS3 Accelerometer and Gyroscope.

Parameters:
xg_idthe pointer where the ID of the device is stored
Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 118 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_FS ( float *  fullScale ) [protected]

Read Accelero Full Scale.

Parameters:
fullScalethe pointer where the accelerometer full scale is stored
Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 533 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_X_Get_ODR ( float *  odr ) [protected]

Read Accelero Output Data Rate.

Parameters:
odrthe pointer where the accelerometer output data rate is stored
Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 396 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxes ( int32_t *  pData ) [protected]

Read data from LSM6DS3 Accelerometer and calculate linear acceleration in mg.

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

Definition at line 216 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_X_GetAxesRaw ( int16_t *  pData ) [protected]

Read raw data from LSM6DS3 Accelerometer output register.

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

Definition at line 178 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_X_GetSensitivity ( float *  pfData ) [protected]

Read Accelero Sensitivity.

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

Definition at line 493 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_Axes_Status ( uint8_t  enableX,
uint8_t  enableY,
uint8_t  enableZ 
) [protected]

Set the status of the axes for accelerometer.

Parameters:
enableXthe status of the x axis to be set
enableYthe status of the y axis to be set
enableZthe status of the z axis to be set
Return values:
IMU_6AXES_OKin case of success, an error code otherwise

Definition at line 284 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_FS ( float  fullScale ) [protected]

Write Accelero Full Scale.

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

Definition at line 573 of file lsm6ds3_class.cpp.

IMU_6AXES_StatusTypeDef LSM6DS3_X_Set_ODR ( float  odr ) [protected]

Write Accelero Output Data Rate.

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

Definition at line 455 of file lsm6ds3_class.cpp.