3-axis MEMS ultra low power accelerometer

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   X_NUCLEO_IKS01A3 X_NUCLEO_IKS01A3

Embed: (wiki syntax)

« Back to documentation index

LIS2DW12Sensor Class Reference

LIS2DW12Sensor Class Reference

Abstract class of an LIS2DW12 Inertial Measurement Unit (IMU) 3 axes sensor. More...

#include <LIS2DW12Sensor.h>

Public Member Functions

 LIS2DW12Sensor (DevI2C *i2c, uint8_t address=LIS2DW12_I2C_ADD_H, PinName int1_pin=NC, PinName int2_pin=NC)
 Constructor.
 LIS2DW12Sensor (SPI *spi, PinName cs_pin, PinName int1_pin=NC, PinName int2_pin=NC, SPI_type_t spi_type=SPI4W)
 Constructor.
virtual int init (void *init)
 Initializing the component.
virtual int read_id (uint8_t *id)
 Read ID of LIS2DW12 Accelerometer and Gyroscope.
virtual int get_x_axes (int32_t *pData)
 Read data from LIS2DW12 Accelerometer.
virtual int get_x_sensitivity (float *pfData)
 Read Accelerometer Sensitivity.
virtual int get_x_axes_raw (int16_t *pData)
 Read raw data from LIS2DW12 Accelerometer.
virtual int get_x_odr (float *odr)
 Read LIS2DW12 Accelerometer output data rate.
virtual int set_x_odr (float odr)
 Set LIS2DW12 Accelerometer output data rate.
virtual int get_x_fs (float *fullScale)
 Read LIS2DW12 Accelerometer full scale.
virtual int set_x_fs (float fullScale)
 Set LIS2DW12 Accelerometer full scale.
int set_x_odr_with_mode (float odr, LIS2DW12_Operating_Mode_t mode=LIS2DW12_HIGH_PERFORMANCE_MODE, LIS2DW12_Low_Noise_t noise=LIS2DW12_LOW_NOISE_DISABLE)
 Set LIS2DW12 Accelerometer output data rate.
int enable_x (void)
 Enable LIS2DW12 Accelerator.
int disable_x (void)
 Disable LIS2DW12 Accelerator.
int enable_wake_up_detection (void)
 Enable the wake up detection for LIS2DW12 accelerometer sensor.
int disable_wake_up_detection (void)
 Disable the wake up detection for LIS2DW12 accelerometer sensor.
int set_wake_up_threshold (uint8_t thr)
 Set the wake up threshold for LIS2DW12 accelerometer sensor.
int set_wake_up_duration (uint8_t dur)
 Set the wake up duration for LIS2DW12 accelerometer sensor.
int enable_inactivity_detection (void)
 Enable the inactivity detection for LIS2DW12 accelerometer sensor.
int disable_inactivity_detection (void)
 Disable the inactivity detection for LIS2DW12 accelerometer sensor.
int set_sleep_duration (uint8_t dur)
 Set the sleep duration for LIS2DW12 accelerometer sensor.
int enable_6d_orientation (void)
 Enable the 6D orientation detection for LIS2DW12 accelerometer sensor.
int disable_6d_orientation (void)
 Disable the 6D orientation detection for LIS2DW12 accelerometer sensor.
int set_6d_orientation_threshold (uint8_t thr)
 Set the 6D orientation threshold for LIS2DW12 accelerometer sensor.
int get_6d_orientation_xl (uint8_t *xl)
 Get the 6D orientation XL axis for LIS2DW12 accelerometer sensor.
int get_6d_orientation_xh (uint8_t *xh)
 Get the 6D orientation XH axis for LIS2DW12 accelerometer sensor.
int get_6d_orientation_yl (uint8_t *yl)
 Get the 6D orientation YL axis for LIS2DW12 accelerometer sensor.
int get_6d_orientation_yh (uint8_t *yh)
 Get the 6D orientation YH axis for LIS2DW12 accelerometer sensor.
int get_6d_orientation_zl (uint8_t *zl)
 Get the 6D orientation ZL axis for LIS2DW12 accelerometer sensor.
int get_6d_orientation_zh (uint8_t *zh)
 Get the 6D orientation ZH axis for LIS2DW12 accelerometer sensor.
int get_event_status (LIS2DW12_Event_Status_t *status)
 Get the status of all hardware events for LIS2DW12 accelerometer sensor.
int get_fifo_num_samples (uint16_t *num_samples)
 Get the number of samples contained into the FIFO.
int set_fifo_mode (uint8_t mode)
 Set the FIFO mode.
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 LIS2DW12 Inertial Measurement Unit (IMU) 3 axes sensor.

Definition at line 94 of file LIS2DW12Sensor.h.


Constructor & Destructor Documentation

LIS2DW12Sensor ( DevI2C *  i2c,
uint8_t  address = LIS2DW12_I2C_ADD_H,
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
int1_pinthe interrupt 1 pin
int2_pinthe interrupt 2 pin

Definition at line 53 of file LIS2DW12Sensor.cpp.

LIS2DW12Sensor ( SPI *  spi,
PinName  cs_pin,
PinName  int1_pin = NC,
PinName  int2_pin = NC,
SPI_type_t  spi_type = SPI4W 
)

Constructor.

Parameters:
spiobject of an helper class which handles the SPI peripheral
cs_pinthe chip select pin
int1_pinthe interrupt 1 pin
int2_pinthe interrupt 2 pin
spi_typethe SPI type (4-Wires or 3-Wires)

Definition at line 70 of file LIS2DW12Sensor.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 138 of file LIS2DW12Sensor.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 168 of file LIS2DW12Sensor.h.

int disable_6d_orientation ( void   )

Disable the 6D orientation detection for LIS2DW12 accelerometer sensor.

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

Definition at line 1107 of file LIS2DW12Sensor.cpp.

int disable_inactivity_detection ( void   )

Disable the inactivity detection for LIS2DW12 accelerometer sensor.

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

Definition at line 996 of file LIS2DW12Sensor.cpp.

void disable_int1_irq ( void   )

Disabling the INT1 interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 158 of file LIS2DW12Sensor.h.

void disable_int2_irq ( void   )

Disabling the INT2 interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 188 of file LIS2DW12Sensor.h.

int disable_wake_up_detection ( void   )

Disable the wake up detection for LIS2DW12 accelerometer sensor.

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

Definition at line 875 of file LIS2DW12Sensor.cpp.

int disable_x ( void   )

Disable LIS2DW12 Accelerator.

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

Definition at line 172 of file LIS2DW12Sensor.cpp.

int enable_6d_orientation ( void   )

Enable the 6D orientation detection for LIS2DW12 accelerometer sensor.

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

Definition at line 1069 of file LIS2DW12Sensor.cpp.

int enable_inactivity_detection ( void   )

Enable the inactivity detection for LIS2DW12 accelerometer sensor.

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

Definition at line 957 of file LIS2DW12Sensor.cpp.

void enable_int1_irq ( void   )

Enabling the INT1 interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 148 of file LIS2DW12Sensor.h.

void enable_int2_irq ( void   )

Enabling the INT2 interrupt handling.

Parameters:
None.
Return values:
None.

Definition at line 178 of file LIS2DW12Sensor.h.

int enable_wake_up_detection ( void   )

Enable the wake up detection for LIS2DW12 accelerometer sensor.

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

Definition at line 833 of file LIS2DW12Sensor.cpp.

int enable_x ( void   )

Enable LIS2DW12 Accelerator.

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

Definition at line 151 of file LIS2DW12Sensor.cpp.

int get_6d_orientation_xh ( uint8_t *  xh )

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

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

Definition at line 1191 of file LIS2DW12Sensor.cpp.

int get_6d_orientation_xl ( uint8_t *  xl )

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

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

Definition at line 1173 of file LIS2DW12Sensor.cpp.

int get_6d_orientation_yh ( uint8_t *  yh )

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

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

Definition at line 1227 of file LIS2DW12Sensor.cpp.

int get_6d_orientation_yl ( uint8_t *  yl )

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

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

Definition at line 1209 of file LIS2DW12Sensor.cpp.

int get_6d_orientation_zh ( uint8_t *  zh )

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

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

Definition at line 1263 of file LIS2DW12Sensor.cpp.

int get_6d_orientation_zl ( uint8_t *  zl )

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

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

Definition at line 1245 of file LIS2DW12Sensor.cpp.

int get_event_status ( LIS2DW12_Event_Status_t *  status )

Get the status of all hardware events for LIS2DW12 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 1281 of file LIS2DW12Sensor.cpp.

int get_fifo_num_samples ( uint16_t *  num_samples )

Get the number of samples contained into the FIFO.

Parameters:
num_samplesthe number of samples contained into the FIFO
Return values:
0in case of success, an error code otherwise

Definition at line 1327 of file LIS2DW12Sensor.cpp.

int get_x_axes ( int32_t *  acceleration ) [virtual]

Read data from LIS2DW12 Accelerometer.

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

Definition at line 213 of file LIS2DW12Sensor.cpp.

int get_x_axes_raw ( int16_t *  value ) [virtual]

Read raw data from LIS2DW12 Accelerometer.

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

Definition at line 338 of file LIS2DW12Sensor.cpp.

int get_x_fs ( float *  full_scale ) [virtual]

Read LIS2DW12 Accelerometer full scale.

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

Definition at line 769 of file LIS2DW12Sensor.cpp.

int get_x_odr ( float *  odr ) [virtual]

Read LIS2DW12 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 398 of file LIS2DW12Sensor.cpp.

int get_x_sensitivity ( float *  sensitivity ) [virtual]

Read Accelerometer Sensitivity.

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

Definition at line 241 of file LIS2DW12Sensor.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 102 of file LIS2DW12Sensor.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 200 of file LIS2DW12Sensor.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 233 of file LIS2DW12Sensor.h.

int read_id ( uint8_t *  id ) [virtual]

Read ID of LIS2DW12 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 194 of file LIS2DW12Sensor.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 1384 of file LIS2DW12Sensor.cpp.

int set_6d_orientation_threshold ( uint8_t  thr )

Set the 6D orientation threshold for LIS2DW12 accelerometer sensor.

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

Definition at line 1155 of file LIS2DW12Sensor.cpp.

int set_fifo_mode ( uint8_t  mode )

Set the FIFO mode.

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

Definition at line 1349 of file LIS2DW12Sensor.cpp.

int set_sleep_duration ( uint8_t  dur )

Set the sleep duration for LIS2DW12 accelerometer sensor.

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

Definition at line 1054 of file LIS2DW12Sensor.cpp.

int set_wake_up_duration ( uint8_t  dur )

Set the wake up duration for LIS2DW12 accelerometer sensor.

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

Definition at line 943 of file LIS2DW12Sensor.cpp.

int set_wake_up_threshold ( uint8_t  thr )

Set the wake up threshold for LIS2DW12 accelerometer sensor.

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

Definition at line 928 of file LIS2DW12Sensor.cpp.

int set_x_fs ( float  full_scale ) [virtual]

Set LIS2DW12 Accelerometer full scale.

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

Definition at line 810 of file LIS2DW12Sensor.cpp.

int set_x_odr ( float  odr ) [virtual]

Set LIS2DW12 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 587 of file LIS2DW12Sensor.cpp.

int set_x_odr_with_mode ( float  odr,
LIS2DW12_Operating_Mode_t  mode = LIS2DW12_HIGH_PERFORMANCE_MODE,
LIS2DW12_Low_Noise_t  noise = LIS2DW12_LOW_NOISE_DISABLE 
)

Set LIS2DW12 Accelerometer output data rate.

Parameters:
odrthe output data rate to be set
modethe operating mode to be used
noisethe low noise option
Return values:
0in case of success, an error code otherwise

Definition at line 599 of file LIS2DW12Sensor.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 1400 of file LIS2DW12Sensor.cpp.