upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Classes | Public Member Functions | List of all members

API for the LSM9DS0 3-axis Gyroscope, Accelerometer, and Magnetometer. More...

Detailed Description

The LSM9DS0 is a system-in-package featuring a 3D digital linear acceleration sensor, a 3D digital angular rate sensor, and a 3D digital magnetic sensor.

The LSM9DS0 has a linear acceleration full scale of 2g/4g/6g/8g/16g, a magnetic field full scale of 2/4/8/12 gauss and an angular rate of 245/500/2000 dps.

While not all of the functionality of this device is supported initially, methods and register definitions are provided that should allow an end user to implement whatever features are required.

This driver was developed on a Sparkfun 9DOF edison block.

Classes

class  ACT_THS_BITS_T
 
class  CLICK_CONFIG_BITS_T
 
class  CLICK_SRC_BITS_T
 
class  CLICK_THS_BITS_T
 
class  CLICK_TIME_LIMIT_BITS_T
 
class  CTRL_REG0_XM_BITS_T
 
class  CTRL_REG1_G_BITS_T
 
class  CTRL_REG1_XM_BITS_T
 
class  CTRL_REG2_G_BITS_T
 
class  CTRL_REG2_XM_BITS_T
 
class  CTRL_REG3_G_BITS_T
 
class  CTRL_REG3_XM_BITS_T
 
class  CTRL_REG4_G_BITS_T
 
class  CTRL_REG4_XM_BITS_T
 
class  CTRL_REG5_G_BITS_T
 
class  CTRL_REG5_XM_BITS_T
 
class  CTRL_REG6_XM_BITS_T
 
class  CTRL_REG7_XM_BITS_T
 
class  DEVICE_T
 
class  FIFO_CTRL_REG_G_T
 
class  FIFO_CTRL_REG_T
 
class  FIFO_SRC_REG_BITS_T
 
class  FIFO_SRC_REG_G_BITS_T
 
class  FM_T
 
class  G_FM_T
 
class  G_FS_T
 
class  G_HPCF_T
 
class  G_HPM_T
 
class  G_INT1OUTSEL_T
 
class  G_ODR_T
 
class  G_ST_T
 
class  INT1_CFG_G_BITS_T
 
class  INT1_SRC_G_BITS_T
 
class  INT_CTRL_REG_M_BITS_T
 
class  INT_GEN_X_DUR_BITS_T
 
class  INT_GEN_X_REG_BITS_T
 
class  INT_GEN_X_SRC_BITS_T
 
class  INT_GEN_X_THS_BITS_T
 
class  INT_SRC_REG_M_BITS_T
 
class  INTERRUPT_PINS_T
 
class  REG_G_T
 
class  REG_XM_T
 
class  STATUS_REG_A_BITS_T
 
class  STATUS_REG_G_BITS_T
 
class  STATUS_REG_M_BITS_T
 
class  XM_ABW_T
 
class  XM_AFS_T
 
class  XM_AHPM_T
 
class  XM_AODR_T
 
class  XM_AST_T
 
class  XM_MD_T
 
class  XM_MFS_T
 
class  XM_ODR_T
 
class  XM_RES_T
 

Public Member Functions

synchronized void delete ()
 
 LSM9DS0 (int bus, short gAddress, short xmAddress)
 
 LSM9DS0 (int bus, short gAddress)
 
 LSM9DS0 (int bus)
 
boolean init ()
 
void update ()
 
void updateGyroscope ()
 
void updateAccelerometer ()
 
void updateMagnetometer ()
 
void updateTemperature ()
 
short readReg (LSM9DS0.DEVICE_T dev, short reg)
 
void readRegs (LSM9DS0.DEVICE_T dev, short reg, byte[] buffer)
 
boolean writeReg (LSM9DS0.DEVICE_T dev, short reg, short val)
 
boolean setGyroscopePowerDown (boolean enable)
 
boolean setGyroscopeEnableAxes (short axes)
 
boolean setGyroscopeODR (LSM9DS0.G_ODR_T odr)
 
boolean setGyroscopeScale (LSM9DS0.G_FS_T scale)
 
boolean setAccelerometerEnableAxes (short axes)
 
boolean setAccelerometerODR (LSM9DS0.XM_AODR_T odr)
 
boolean setAccelerometerScale (LSM9DS0.XM_AFS_T scale)
 
boolean setMagnetometerResolution (LSM9DS0.XM_RES_T res)
 
boolean setMagnetometerODR (LSM9DS0.XM_ODR_T odr)
 
boolean setMagnetometerMode (LSM9DS0.XM_MD_T mode)
 
boolean setMagnetometerLPM (boolean enable)
 
boolean setMagnetometerScale (LSM9DS0.XM_MFS_T scale)
 
float[] getAccelerometer ()
 
float[] getGyroscope ()
 
float[] getMagnetometer ()
 
float getTemperature ()
 
boolean enableTemperatureSensor (boolean enable)
 
short getGyroscopeStatus ()
 
short getMagnetometerStatus ()
 
short getAccelerometerStatus ()
 
short getGyroscopeInterruptConfig ()
 
boolean setGyroscopeInterruptConfig (short enables)
 
short getGyroscopeInterruptSrc ()
 
short getMagnetometerInterruptControl ()
 
boolean setMagnetometerInterruptControl (short enables)
 
short getMagnetometerInterruptSrc ()
 
short getInterruptGen1 ()
 
boolean setInterruptGen1 (short enables)
 
short getInterruptGen1Src ()
 
short getInterruptGen2 ()
 
boolean setInterruptGen2 (short enables)
 
short getInterruptGen2Src ()
 
void installISR (LSM9DS0.INTERRUPT_PINS_T intr, int gpio, int level, IsrCallback cb)
 
void uninstallISR (LSM9DS0.INTERRUPT_PINS_T intr)
 

Constructor & Destructor Documentation

LSM9DS0 ( int  bus,
short  gAddress,
short  xmAddress 
)

lsm9ds0 constructor

Parameters
busi2c bus to use
addressthe address for this device

Member Function Documentation

boolean enableTemperatureSensor ( boolean  enable)

enable onboard temperature measurement sensor

Parameters
enabletrue to enable temperature sensor, false to disable
Returns
true if successful, false otherwise
float [] getAccelerometer ( )

get the accelerometer values in gravities

Returns
Array containing X, Y, Z acceleration values
short getAccelerometerStatus ( )

return the accelerometer status register

Returns
bitmask of STATUS_REG_A_BITS_T bits
float [] getGyroscope ( )

get the gyroscope values in degrees per second

Returns
Array containing X, Y, Z gyroscope values
short getGyroscopeInterruptConfig ( )

return the gyroscope interrupt config register

Returns
bitmask of INT1_CFG_G_BITS_T bits
short getGyroscopeInterruptSrc ( )

return the gyroscope interrupt src register

Returns
bitmask of INT1_SRC_G_BITS_T bits
short getGyroscopeStatus ( )

return the gyroscope status register

Returns
bitmask of STATUS_REG_G_BITS_T bits
short getInterruptGen1 ( )

return the inertial interrupt generator 1 register

Returns
bitmask of INT_GEN_X_REG_BITS_T bits
short getInterruptGen1Src ( )

return the inertial interrupt generator 1 src register

Returns
bitmask of INT_GEN_X_SRC_BITS_T bits
short getInterruptGen2 ( )

return the inertial interrupt generator 2 register

Returns
bitmask of INT_GEN_X_REG_BITS_T bits
short getInterruptGen2Src ( )

return the inertial interrupt generator 2 src register

Returns
bitmask of INT_GEN_X_SRC_BITS_T bits
float [] getMagnetometer ( )

get the magnetometer values in gauss

Returns
Array containing X, Y, Z magnetometer values
short getMagnetometerInterruptControl ( )

return the magnetometer interrupt control register

Returns
bitmask of INT_CTRL_REG_M_BITS_T bits
short getMagnetometerInterruptSrc ( )

return the magnetometer interrupt src register

Returns
bitmask of INT_SRC_REG_M_BITS_T bits
short getMagnetometerStatus ( )

return the magnetometer status register

Returns
bitmask of STATUS_REG_M_BITS_T bits
float getTemperature ( )

get the temperature value. Unfortunately the datasheet does not provide a mechanism to convert the temperature value into the correct value, so I made a 'guess'. If it's wrong, and you figure it out, send a patch!

Returns
the temperature value in degrees Celcius
boolean init ( )

set up initial values and start operation

Returns
true if successful
short readReg ( LSM9DS0.DEVICE_T  dev,
short  reg 
)

read a register

Parameters
devthe device to access (XM or G)
regthe register to read
Returns
the value of the register
boolean setAccelerometerEnableAxes ( short  axes)

enable or disable accelerometer axes.

Parameters
axesbit mask of valid axes, (CTRL_REG1_XM_AXEN, ...)
Returns
true if successful, false otherwise
boolean setAccelerometerODR ( LSM9DS0.XM_AODR_T  odr)

set the accelerometer Output Data Rate (ODR)

Parameters
odrone of the XM_AODR_T values
Returns
true if successful, false otherwise
boolean setAccelerometerScale ( LSM9DS0.XM_AFS_T  scale)

set the scaling mode of the accelerometer

Parameters
scaleone of the XM_AFS_T values
Returns
true if successful, false otherwise
boolean setGyroscopeEnableAxes ( short  axes)

enable or disable gyroscope axes. If all axis are disabled, and powerdown mode is not set, then the gyro goes into sleep mode.

Parameters
axesbit mask of valid axes, (CTRL_REG1_G_YEN, ...)
Returns
true if successful, false otherwise
boolean setGyroscopeInterruptConfig ( short  enables)

set the gyroscope interrupt config register

Parameters
enablesbitmask of INT1_CFG_G_BITS_T values
Returns
true if successful
boolean setGyroscopeODR ( LSM9DS0.G_ODR_T  odr)

set the gyroscope Output Data Rate (ODR)

Parameters
odrone of the G_ODR_T values
Returns
true if successful, false otherwise
boolean setGyroscopePowerDown ( boolean  enable)

enable or disable the gyro power down mode

Parameters
enabletrue to put device to sleep, false to wake up
Returns
true if successful, false otherwise
boolean setGyroscopeScale ( LSM9DS0.G_FS_T  scale)

set the scaling mode of the gyroscope

Parameters
scaleone of the G_FS_T values
Returns
true if successful, false otherwise
boolean setInterruptGen1 ( short  enables)

set the inertial interrupt generator 1 register

Parameters
enablesbitmask of INT_GEN_X_REG_BITS_T values
Returns
true if successful
boolean setInterruptGen2 ( short  enables)

set the inertial interrupt generator 2 register

Parameters
enablesbitmask of INT_GEN_X_REG_BITS_T values
Returns
true if successful
boolean setMagnetometerInterruptControl ( short  enables)

set the magnetometer interrupt control register

Parameters
enablesbitmask of INT_CTRL_REG_M_BITS_T values
Returns
true if successful
boolean setMagnetometerLPM ( boolean  enable)

enable or disable magnetometer low power mode (LPM). When in low power mode, the magnetometer updates at 3.125Hz, regardless of it's ODR setting.

Parameters
enabletrue to enable LPM, false otherwise
Returns
true if successful, false otherwise
boolean setMagnetometerMode ( LSM9DS0.XM_MD_T  mode)

set the magnetometer sensor mode

Parameters
modeone of the XM_MD_T values
Returns
true if successful, false otherwise
boolean setMagnetometerODR ( LSM9DS0.XM_ODR_T  odr)

set the magnetometer Output Data Rate (ODR)

Parameters
odrone of the XM_ODR_T values
Returns
true if successful, false otherwise
boolean setMagnetometerResolution ( LSM9DS0.XM_RES_T  res)

set the magnetometer resolution

Parameters
resone of the XM_RES_T values
Returns
true if successful, false otherwise
boolean setMagnetometerScale ( LSM9DS0.XM_MFS_T  scale)

set the scaling mode of the magnetometer

Parameters
scaleone of the XM_MFS_T values
Returns
true if successful, false otherwise
void uninstallISR ( LSM9DS0.INTERRUPT_PINS_T  intr)

uninstall a previously installed interrupt handler

Parameters
introne of the INTERRUPT_PINS_T values specifying which interrupt pin out of 4 you are uninstalling
void update ( )

update the accelerometer, gyroscope, magnetometer and termperature values.

void updateAccelerometer ( )

update the accelerometer values only

void updateGyroscope ( )

update the gyroscope values only

void updateMagnetometer ( )

update the magnetometer values only

void updateTemperature ( )

update the temperature value only

boolean writeReg ( LSM9DS0.DEVICE_T  dev,
short  reg,
short  val 
)

write to a register

Parameters
devthe device to access (XM or G)
regthe register to write to
valthe value to write
Returns
true if successful, false otherwise

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