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

API for the BMA220 3-axis Accelerometer. More...

Detailed Description

The BMA220 is a low cost, very small 3-axis accelerometer with 6 bits of resolution. It can also detect orientation and tap events.

The BMA220 has a linear acceleration full scale of 2g/4g/8g/16g.

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 DFRobot BMA (Tiny).

Classes

class  CONFIG2_LAT_T
 
class  CONFIG_ORIENT_T
 
class  ENABLE_CONFIG2_BITS_T
 
class  ENABLE_CONFIG3_BITS_T
 
class  ENABLE_CONFIG_BITS_T
 
class  FILTER_CONFIG_BITS_T
 
class  FILTER_CONFIG_T
 
class  FSL_RANGE_T
 
class  H_HYST_DUR_HIGH_BITS_T
 
class  I2C_WATCHDOG_BITS_T
 
class  INT_STATUS1_BITS_T
 
class  INT_STATUS2_BITS_T
 
class  L_HYST_DUR_LOW_BITS_T
 
class  REG_T
 
class  SBIST_FSL_CONFIG_BITS_T
 
class  SBIST_T
 
class  SLEEP_DUR_T
 
class  SLOPE_CONFIG_BITS_T
 
class  TAP_CONFIG2_BITS_T
 
class  TAP_CONFIG_BITS_T
 
class  TAP_ORIENT_BLOCK_T
 
class  TAP_SAMP_T
 
class  THRESHOLD_BITS_T
 

Public Member Functions

synchronized void delete ()
 
 BMA220 (int bus, short addr)
 
 BMA220 (int bus)
 
void update ()
 
short readReg (short reg)
 
boolean writeReg (short reg, short val)
 
short getChipID ()
 
short getChipRevision ()
 
boolean setAccelerometerScale (BMA220.FSL_RANGE_T scale)
 
float[] getAccelerometer ()
 
boolean setFilterConfig (BMA220.FILTER_CONFIG_T filter)
 
boolean setSerialHighBW (boolean high)
 
boolean enableAxes (boolean xEn, boolean yEn, boolean zEn)
 
short suspend ()
 
short softReset ()
 
boolean sleep (boolean enable)
 
boolean setSleepDuration (BMA220.SLEEP_DUR_T dur)
 
boolean setLowGThreshold (short thresh)
 
boolean setHighGThreshold (short thresh)
 
boolean setLowGHysteresis (short hyst)
 
boolean setLowGDuration (short dur)
 
boolean setHighGHysteresis (short hyst)
 
boolean setHighGDuration (short dur)
 
boolean setTapDuration (short dur)
 
boolean setTapThreshold (short thresh)
 
boolean enableTapFilter (boolean filt)
 
boolean setSlopeDuration (short dur)
 
boolean setSlopeThreshold (short thresh)
 
boolean enableSlopeFilter (boolean filt)
 
short getInterruptStatus1 ()
 
BMA220.CONFIG_ORIENT_T getOrient ()
 
short getInterruptStatus2 ()
 
boolean setInterruptEnables1 (short bits)
 
short getInterruptEnables1 ()
 
boolean setInterruptEnables2 (short bits)
 
short getInterruptEnables2 ()
 
boolean setInterruptLatch (BMA220.CONFIG2_LAT_T lat)
 
boolean resetInterrupts ()
 
void installISR (int gpio, int level, IsrCallback cb)
 
void uninstallISR ()
 

Constructor & Destructor Documentation

BMA220 ( int  bus,
short  addr 
)

BMA220 constructor

Parameters
busi2c bus to use
addressthe address for this device

Member Function Documentation

boolean enableAxes ( boolean  xEn,
boolean  yEn,
boolean  zEn 
)

enable or disable axis channels

Parameters
xEntrue to enable the axis, false otherwise
yEntrue to enable the axis, false otherwise
zEntrue to enable the axis, false otherwise
Returns
true if successful
boolean enableSlopeFilter ( boolean  filt)

enable or disable slope filtering

Parameters
filttrue to enable filtering, false otherwise
Returns
true if successful
boolean enableTapFilter ( boolean  filt)

unable to disable tap filtering

Parameters
filttrue to enable, false otherwise
Returns
true if successful
float [] getAccelerometer ( )

get the accelerometer values in gravities

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

return the chip ID

Returns
the chip ID (usually 0xdd)
short getChipRevision ( )

return the chip revision

Returns
the chip revision (usually 0x00)
short getInterruptEnables1 ( )

return the enabled interrupts for events in interrupt config register 1

Returns
bitmask of ENABLE_CONFIG_BITS_T values
short getInterruptEnables2 ( )

return the enabled interrupts for events in interrupt config register 2

Returns
bitmask of ENABLE_CONFIG2_BITS_T values
short getInterruptStatus1 ( )

return a bitmask of the interrupt status 1 register

Returns
bitmask of INT_STATUS1_BITS_T bits (minus the orient value)
short getInterruptStatus2 ( )

return a bitmask of the interrupt status 2 register

Returns
bitmask of INT_STATUS2_BITS_T bits
BMA220.CONFIG_ORIENT_T getOrient ( )

return the orient value from the interrupt status 1 register

Returns
one of the CONFIG_ORIENT_T values
short readReg ( short  reg)

read a register

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

reset the interrupt controller. This should be called after any changes are made to interrupt configuration, or to reset interrupts if latched interrupts have been enabled and an interrupt has occurred..

Returns
true if successful
boolean setAccelerometerScale ( BMA220.FSL_RANGE_T  scale)

set the scaling mode of the accelerometer (2g/4g/8g/16g)

Parameters
scaleone of the FSL_RANGE_T values
Returns
true if successful, false otherwise
boolean setFilterConfig ( BMA220.FILTER_CONFIG_T  filter)

set the filtering configuration

Parameters
filterone of the FILTER_CONFIG_T values
Returns
true if successful
boolean setHighGDuration ( short  dur)

specify the sample duration for high G detection

Parameters
durthe number of samples (depends on bandwidth)
Returns
true if successful
boolean setHighGHysteresis ( short  hyst)

specify the hysteresis for high G detection

Parameters
hyst2 bit hysteresis value
Returns
true if successful
boolean setHighGThreshold ( short  thresh)

specify the threshold for high G detection

Parameters
threshsee the datasheet
Returns
true if successful
boolean setInterruptEnables1 ( short  bits)

enable interrupts for events in interrupt config register 1

Parameters
bitsbitmask of ENABLE_CONFIG_BITS_T values
Returns
true if successful
boolean setInterruptEnables2 ( short  bits)

enable interrupts for events in interrupt config register 2

Parameters
bitsbitmask of ENABLE_CONFIG2_BITS_T values
Returns
true if successful
boolean setInterruptLatch ( BMA220.CONFIG2_LAT_T  lat)

configure interrupt latching behavior

Parameters
latone of the CONFIG2_LAT_T values
Returns
true if successful
boolean setLowGDuration ( short  dur)

specify the sample duration for low G detection

Parameters
durthe number of samples (depends on bandwidth)
Returns
true if successful
boolean setLowGHysteresis ( short  hyst)

specify the hysteresis for low G detection

Parameters
hyst2 bit hysteresis value
Returns
true if successful
boolean setLowGThreshold ( short  thresh)

specify the threshold for low G detection

Parameters
threshsee the datasheet
Returns
true if successful
boolean setSerialHighBW ( boolean  high)

enable or disable high bandwidth serial access (1Khz). This essentially disables filtering and makes the raw unfiltered data available in the axis registers.

Parameters
hightrue to enable high bw access, false otherwise
Returns
true if successful
boolean setSleepDuration ( BMA220.SLEEP_DUR_T  dur)

when in low power (sleep) mode, specify how often the device wakes up to acquire samples.

Parameters
durone of the SLEEP_DUR_T values
Returns
true if successful
boolean setSlopeDuration ( short  dur)

specify the sample duration for slope detection

Parameters
durthe number of samples (depends on bandwidth)
Returns
true if successful
boolean setSlopeThreshold ( short  thresh)

specify the threshold for slope detection

Parameters
threshsee the datasheet
Returns
true if successful
boolean setTapDuration ( short  dur)

specify the sample duration for tap detection

Parameters
durthe number of samples (depends on bandwidth)
Returns
true if successful
boolean setTapThreshold ( short  thresh)

specify the threshold for tap detection

Parameters
threshsee the datasheet
Returns
true if successful
boolean sleep ( boolean  enable)

place the device into, or take the device out of low power mode. See the datasheet for information on how low power mode is implemented on this device.

Parameters
enabletrue to set low power mode, false otherwise
Returns
true if successful
short softReset ( )

place the device into, or take the device out of soft reset mode

Returns
0x00 if the device was in active mode, 0xff if the device was in soft reset mode
short suspend ( )

place the device into, or take the device out of suspend mode

Returns
0x00 if the device was in active mode, 0xff if the device was in suspend mode
void uninstallISR ( )

uninstall a previously installed interrupt handler

void update ( )

update the accelerometer values

boolean writeReg ( 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: