Ultra-compact high-performance eCompass module: ultra-low power 3D accelerometer and 3D magnetometer.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   HelloWorld_ST_Sensors MOTENV_Mbed mbed-os-mqtt-client LSM303AGR_JS ... more

Embed: (wiki syntax)

« Back to documentation index

LSM303AGRAccSensor Class Reference

LSM303AGRAccSensor Class Reference

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

#include <LSM303AGRAccSensor.h>

Public Member Functions

 LSM303AGRAccSensor (DevI2C *i2c, uint8_t address=LSM303AGR_ACC_I2C_ADDRESS, 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 LSM303AGR Accelerometer.
virtual int get_x_axes (int32_t *pData)
 Read data from LSM303AGR Accelerometer.
virtual int get_x_axes_raw (int16_t *pData)
 Read raw data from LSM303AGR Accelerometer.
virtual int get_x_sensitivity (float *pfData)
 Read Accelerometer Sensitivity.
virtual int get_x_odr (float *odr)
 Read LSM303AGR Accelerometer output data rate.
virtual int set_x_odr (float odr)
 Set ODR.
virtual int get_x_fs (float *fullScale)
 Read LSM303AGR Accelerometer full scale.
virtual int set_x_fs (float fullScale)
 Set full scale.
int enable (void)
 Enable LSM303AGR Accelerator.
int disable (void)
 Disable LSM303AGR Accelerator.
int read_reg (uint8_t reg, uint8_t *data)
 Read accelerometer data from register.
int write_reg (uint8_t reg, uint8_t data)
 Write accelerometer data to register.
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 LSM303AGR Inertial Measurement Unit (IMU) 6 axes sensor.

Definition at line 72 of file LSM303AGRAccSensor.h.


Constructor & Destructor Documentation

LSM303AGRAccSensor ( DevI2C *  i2c,
uint8_t  address = LSM303AGR_ACC_I2C_ADDRESS,
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 68 of file LSM303AGRAccSensor.cpp.


Member Function Documentation

int disable ( void   )

Disable LSM303AGR Accelerator.

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

Definition at line 157 of file LSM303AGRAccSensor.cpp.

int enable ( void   )

Enable LSM303AGR Accelerator.

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

Definition at line 134 of file LSM303AGRAccSensor.cpp.

int get_x_axes ( int32_t *  pData ) [virtual]

Read data from LSM303AGR Accelerometer.

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

Definition at line 208 of file LSM303AGRAccSensor.cpp.

int get_x_axes_raw ( int16_t *  pData ) [virtual]

Read raw data from LSM303AGR Accelerometer.

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

Definition at line 386 of file LSM303AGRAccSensor.cpp.

int get_x_fs ( float *  fullScale ) [virtual]

Read LSM303AGR Accelerometer full scale.

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

Definition at line 551 of file LSM303AGRAccSensor.cpp.

int get_x_odr ( float *  odr ) [virtual]

Read LSM303AGR 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 434 of file LSM303AGRAccSensor.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 231 of file LSM303AGRAccSensor.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 80 of file LSM303AGRAccSensor.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 98 of file LSM303AGRAccSensor.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 122 of file LSM303AGRAccSensor.h.

int read_id ( uint8_t *  id ) [virtual]

Read ID of LSM303AGR Accelerometer.

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 187 of file LSM303AGRAccSensor.cpp.

int read_reg ( uint8_t  reg,
uint8_t *  data 
)

Read accelerometer data from register.

Parameters:
regregister address
dataregister data
Return values:
0in case of success
1in case of failure

Definition at line 611 of file LSM303AGRAccSensor.cpp.

int set_x_fs ( float  fullScale ) [virtual]

Set full scale.

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

Definition at line 587 of file LSM303AGRAccSensor.cpp.

int set_x_odr ( float  odr ) [virtual]

Set ODR.

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

Definition at line 482 of file LSM303AGRAccSensor.cpp.

int write_reg ( uint8_t  reg,
uint8_t  data 
)

Write accelerometer data to register.

Parameters:
regregister address
dataregister data
Return values:
0in case of success
1in case of failure

Definition at line 629 of file LSM303AGRAccSensor.cpp.