libpropeller
Making PropellerGCC Easier
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
LSM303DLHC Class Reference

Provides an interface to the LSM303DLHC accelerometer and magnetometer. More...

#include <lsm303dlhc.h>

Public Member Functions

 LSM303DLHC ()
 Create a new LSM303DLHC instance. More...
 
bool Init (I2C *i2c_bus)
 Tests to make sure that the LSM303DLHC is actually on the bus, and returns false if it is not. More...
 
bool ReadAccl (int &x, int &y, int &z)
 Reads the accelerometer at the current settings, and updates the three reference values. More...
 
bool ReadMagn (int &x, int &y, int &z)
 Reads the magnetometer at the current settings, and updates the three reference values. More...
 

Detailed Description

Provides an interface to the LSM303DLHC accelerometer and magnetometer.

"Output Data Rate, in digital-output accelerometers, defines the rate at which data is sampled. Bandwidth is the highest frequency signal that can be sampled without aliasing by the specified Output Data Rate. Per the Nyquist sampling criterion, bandwidth is half the Output Data Rate." -Analog Devices

See this question for more information on ODR: http://electronics.stackexchange.com/questions/67610/lsm303dlhc-low-power-and-high-precision-modes

Author
SRLM (srlm@.nosp@m.srlm.nosp@m.produ.nosp@m.ctio.nosp@m.ns.co.nosp@m.m)

Constructor & Destructor Documentation

LSM303DLHC::LSM303DLHC ( )
inline

Create a new LSM303DLHC instance.

Member Function Documentation

bool LSM303DLHC::Init ( I2C i2c_bus)
inline

Tests to make sure that the LSM303DLHC is actually on the bus, and returns false if it is not.

Otherwise, sets the registers as follows and returns true.

  Set the control registers of the accelerometer:
  • CTRL_REG1_A:
    • 1.344kHz output rate
    • Normal power
    • XYZ enabled
  • CTRL_REG4_A:
    • Block data continuous update (default)
    • data LSB @ lower address (default)
    • Full scale +-16G
    • High resolution output enable (SRLM: what does this mean? datasheet is no help)
    • 00 (no functionality)
    • SPI interface mode (default, not used)
   Set the control registers of the Magn :
  • CRA_REG_M:
    • Temperature sensor enable true
    • 00 (no functionality)
    • 220Hz Output data rate
  • CRB_REG_M:
    • 8.1+- guass
    • 00000 (no functionality)
  • MR_REG_M:
    • 000000 (no functionality)
    • Continuous conversion mode (SRLM: What does this actually mean? Datasheet is no help)
Parameters
i2cbusThe bus that the LSM303DLHC is on.
Returns
true when both devices are successfully initialized.

Here is the call graph for this function:

bool LSM303DLHC::ReadAccl ( int &  x,
int &  y,
int &  z 
)
inline

Reads the accelerometer at the current settings, and updates the three reference values.

If there is an error then x, y, and z will be set to zero and false will be returned.

Parameters
xThe acceleration x axis value. Will be overwritten.
yThe acceleration y axis value. Will be overwritten.
zThe acceleration z axis value. Will be overwritten.
Returns
true if all is successful, false otherwise. If false, try reinitilizing

Here is the call graph for this function:

bool LSM303DLHC::ReadMagn ( int &  x,
int &  y,
int &  z 
)
inline

Reads the magnetometer at the current settings, and updates the three reference values.

If there is an error then x, y, and z will be set to zero and false will be returned.

Parameters
xThe magnetometer x axis value. Will be overwritten.
yThe magnetometer y axis value. Will be overwritten.
zThe magnetometer z axis value. Will be overwritten.
Returns
true if all is successful, false otherwise. If false, try reinitilizing

Here is the call graph for this function:


The documentation for this class was generated from the following file: