BMA220 Class
- ID: bma220
- Name: Digital Triaxial Acceleration Sensor
- Category: accelerometer
- Manufacturer: bosch dfrobot
- Connection: i2c gpio
- Link: http://www.dfrobot.com/index.php?route=product/product&product_id=1085
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).
Item Index
Methods
- BMA220
- update
- readReg
- writeReg
- getChipID
- getChipRevision
- setAccelerometerScale
- getAccelerometer
- getAccelerometer
- setFilterConfig
- setSerialHighBW
- enableAxes
- suspend
- softReset
- sleep
- setSleepDuration
- setLowGThreshold
- setHighGThreshold
- setLowGHysteresis
- setLowGDuration
- setHighGHysteresis
- setHighGDuration
- setTapDuration
- setTapThreshold
- enableTapFilter
- setSlopeDuration
- setSlopeThreshold
- enableSlopeFilter
- getInterruptStatus1
- getOrient
- getInterruptStatus2
- setInterruptEnables1
- getInterruptEnables1
- setInterruptEnables2
- getInterruptEnables2
- setInterruptLatch
- resetInterrupts
- installISR
- uninstallISR
- get_gpioIntr
Properties
- REG_CHIPID
- REG_REVISIONID
- REG_ACC_X
- REG_ACC_Y
- REG_ACC_Z
- REG_H_HYST_DUR
- REG_THRESHOLD
- REG_L_HYST_DUR
- REG_TAP_CONFIG
- REG_SLOPE_CONFIG
- REG_TAP_CONFIG2
- REG_INT_STATUS1
- REG_INT_STATUS2
- REG_ENABLE_CONFIG
- REG_ENABLE_CONFIG2
- REG_ENABLE_CONFIG3
- REG_FILTER_CONFIG
- REG_SBIST_FSL_CONFIG
- REG_I2C_WATCHDOG
- REG_SUSPEND
- REG_SOFTRESET
- H_HYST_DUR_HIGH_DUR0
- H_HYST_DUR_HIGH_DUR1
- H_HYST_DUR_HIGH_DUR2
- H_HYST_DUR_HIGH_DUR3
- H_HYST_DUR_HIGH_DUR4
- H_HYST_DUR_HIGH_DUR5
- _H_HYST_DUR_HIGH_DUR_MASK
- _H_HYST_DUR_HIGH_DUR_SHIFT
- H_HYST_DUR_HIGH_HY1
- H_HYST_DUR_HIGH_HY2
- _H_HYST_DUR_HIGH_HY_MASK
- _H_HYST_DUR_HIGH_HY_SHIFT
- THRESHOLD_HIGH0
- THRESHOLD_HIGH1
- THRESHOLD_HIGH2
- THRESHOLD_HIGH3
- _THRESHOLD_HIGH_MASK
- _THRESHOLD_HIGH_SHIFT
- THRESHOLD_LOW0
- THRESHOLD_LOW1
- THRESHOLD_LOW2
- THRESHOLD_LOW3
- _THRESHOLD_LOW_MASK
- _THRESHOLD_LOW_SHIFT
- L_HYST_DUR_LOW_DUR0
- L_HYST_DUR_LOW_DUR1
- L_HYST_DUR_LOW_DUR2
- L_HYST_DUR_LOW_DUR3
- L_HYST_DUR_LOW_DUR4
- L_HYST_DUR_LOW_DUR5
- _L_HYST_DUR_LOW_DUR_MASK
- _L_HYST_DUR_LOW_DUR_SHIFT
- L_HYST_DUR_LOW_HY1
- L_HYST_DUR_LOW_HY2
- _L_HYST_DUR_LOW_HY_MASK
- _L_HYST_DUR_LOW_HY_SHIFT
- TAP_CONFIG_DUR0
- TAP_CONFIG_DUR1
- TAP_CONFIG_DUR2
- _TAP_CONFIG_DUR_MASK
- _TAP_CONFIG_DUR_SHIFT
- TAP_CONFIG_THRESH0
- TAP_CONFIG_THRESH1
- TAP_CONFIG_THRESH2
- TAP_CONFIG_THRESH3
- _TAP_CONFIG_THRESH_MASK
- _TAP_CONFIG_THRESH_SHIFT
- TAP_CONFIG_FILTER
- SLOPE_CONFIG_DUR0
- SLOPE_CONFIG_DUR1
- _SLOPE_CONFIG_DUR_MASK
- _SLOPE_CONFIG_DUR_SHIFT
- SLOPE_CONFIG_THRESH0
- SLOPE_CONFIG_THRESH1
- SLOPE_CONFIG_THRESH2
- SLOPE_CONFIG_THRESH3
- _SLOPE_CONFIG_THRESH_MASK
- _SLOPE_CONFIG_THRESH_SHIFT
- SLOPE_CONFIG_FILTER
- SLOPE_CONFIG_ORIENT_EX
- TAP_CONFIG2_SAMP0
- TAP_CONFIG2_SAMP1
- _TAP_CONFIG2_SAMP_MASK
- _TAP_CONFIG2_SAMP_SHIFT
- TAP_CONFIG2_ORIENT_BLOCK0
- TAP_CONFIG2_ORIENT_BLOCK1
- _TAP_CONFIG2_ORIENT_BLOCK_MASK
- _TAP_CONFIG2_ORIENT_BLOCK_SHIFT
- TAP_CONFIG2_TIP_EN
- TAP_SAMP_2
- TAP_SAMP_4
- TAP_SAMP_8
- TAP_SAMP_16
- TAP_ORIENT_BLOCK_0
- TAP_ORIENT_BLOCK_2
- TAP_ORIENT_BLOCK_3
- TAP_ORIENT_BLOCK_4
- INT_STATUS1_SIGN
- INT_STATUS1_FIRST_Z
- INT_STATUS1_FIRST_Y
- INT_STATUS1_FIRST_X
- INT_STATUS1_ORIENT0
- INT_STATUS1_ORIENT1
- INT_STATUS1_ORIENT2
- _INT_STATUS1_ORIENT_MASK
- _INT_STATUS1_ORIENT_SHIFT
- INT_STATUS1_ORIENT_INT
- CONFIG_ORI_UP_PORT_UPRIGHT
- CONFIG_ORI_UP_PORT_UPSIDE_DOWN
- CONFIG_ORI_UP_LAND_LEFT
- CONFIG_ORI_UP_LAND_RIGHT
- CONFIG_ORI_DN_PORT_UPRIGHT
- CONFIG_ORI_DN_PORT_UPSIDE_DOWN
- CONFIG_ORI_DN_LAND_LEFT
- CONFIG_ORI_DN_LAND_RIGHT
- INT_STATUS2_SLOPE
- INT_STATUS2_DATA
- INT_STATUS2_HIGH
- INT_STATUS2_LOW
- INT_STATUS2_TAP
- ENABLE_CONFIG_TT_Z
- ENABLE_CONFIG_TT_Y
- ENABLE_CONFIG_TT_X
- ENABLE_CONFIG_SLOPE_Z
- ENABLE_CONFIG_SLOPE_Y
- ENABLE_CONFIG_SLOPE_X
- ENABLE_CONFIG_ORIENT
- ENABLE_CONFIG_DATA
- ENABLE_CONFIG2_HIGH_Z
- ENABLE_CONFIG2_HIGH_Y
- ENABLE_CONFIG2_HIGH_X
- ENABLE_CONFIG2_LOW
- ENABLE_CONFIG2_LAT_INT0
- ENABLE_CONFIG2_LAT_INT1
- ENABLE_CONFIG2_LAT_INT2
- _ENABLE_CONFIG2_LAT_INT_MASK
- _ENABLE_CONFIG2_LAT_INT_SHIFT
- ENABLE_CONFIG2_RESET_INT
- CONFIG2_LAT_UNLATCH
- CONFIG2_LAT_0_25
- CONFIG2_LAT_0_5
- CONFIG2_LAT_1
- CONFIG2_LAT_2
- CONFIG2_LAT_4
- CONFIG2_LAT_8
- CONFIG2_LAT_PERM
- ENABLE_CONFIG3_Z_CHAN
- ENABLE_CONFIG3_Y_CHAN
- ENABLE_CONFIG3_X_CHAN
- ENABLE_CONFIG3_SLEEP_DUR0
- ENABLE_CONFIG3_SLEEP_DUR1
- ENABLE_CONFIG3_SLEEP_DUR2
- _ENABLE_CONFIG3_SLEEP_DUR_MASK
- _ENABLE_CONFIG3_SLEEP_DUR_SHIFT
- ENABLE_CONFIG3_SLEEP_EN
- SLEEP_DUR_2MS
- SLEEP_DUR_10MS
- SLEEP_DUR_25MS
- SLEEP_DUR_50MS
- SLEEP_DUR_100MS
- SLEEP_DUR_500MS
- SLEEP_DUR_1S
- SLEEP_DUR_2S
- FILTER_CONFIG_FILTER0
- FILTER_CONFIG_FILTER1
- FILTER_CONFIG_FILTER2
- FILTER_CONFIG_FILTER3
- _FILTER_CONFIG_FILTER_MASK
- _FILTER_CONFIG_FILTER_SHIFT
- FILTER_CONFIG_SERIAL_HIGH_BW
- FILTER_CONFIG_1KHZ
- FILTER_CONFIG_500HZ
- FILTER_CONFIG_250HZ
- FILTER_CONFIG_125HZ
- FILTER_CONFIG_64HZ
- FILTER_CONFIG_32HZ
- REG_SBIST_FSL_RANGE0
- REG_SBIST_FSL_RANGE1
- _REG_SBIST_FSL_RANGE_MASK
- _REG_SBIST_FSL_RANGE_SHIFT
- REG_SBIST_FSL_SBIST0
- REG_SBIST_FSL_SBIST1
- _REG_SBIST_FSL_SBIST_MASK
- _REG_SBIST_FSL_SBIST_SHIFT
- REG_SBIST_FSL_SBIST_SIGN
- FSL_RANGE_2G
- FSL_RANGE_4G
- FSL_RANGE_8G
- FSL_RANGE_16G
- SBIST_OFF
- SBIST_X
- SBIST_Y
- SBIST_Z
- I2C_WATCHDOG_SPI3
- I2C_WATCHDOG_TO_SEL
- I2C_WATCHDOG_TO_EN
Methods
BMA220
-
bus
-
addr
BMA220 constructor
Parameters:
-
bus
Numberi2c bus to use
-
addr
Numberthe address for this device
Returns:
update
()
update the accelerometer values
readReg
-
reg
read a register
Parameters:
-
reg
Numberthe register to read
Returns:
the value of the register
writeReg
-
reg
-
val
write to a register
Parameters:
-
reg
Numberthe register to write to
-
val
Numberthe value to write
Returns:
true if successful, false otherwise
getChipID
()
Number
return the chip ID
Returns:
the chip ID (usually 0xdd)
getChipRevision
()
Number
return the chip revision
Returns:
the chip revision (usually 0x00)
setAccelerometerScale
-
scale
set the scaling mode of the accelerometer (2g/4g/8g/16g)
Parameters:
-
scale
FSL_RANGE_Tone of the FSL_RANGE_T values
Returns:
true if successful, false otherwise
getAccelerometer
-
x
-
y
-
z
get the accelerometer values in gravities
Parameters:
-
x
Float *the returned x value, if arg is non-NULL
-
y
Float *the returned y value, if arg is non-NULL
-
z
Float *the returned z value, if arg is non-NULL
getAccelerometer
()
Std::vector float
get the accelerometer values in gravities
Returns:
std::vector containing X, Y, Z acceleration values
setFilterConfig
-
filter
set the filtering configuration
Parameters:
-
filter
FILTER_CONFIG_Tone of the FILTER_CONFIG_T values
Returns:
true if successful
setSerialHighBW
-
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:
-
high
Booleantrue to enable high bw access, false otherwise
Returns:
true if successful
enableAxes
-
xEn
-
yEn
-
zEn
enable or disable axis channels
Parameters:
-
xEn
Booleantrue to enable the axis, false otherwise
-
yEn
Booleantrue to enable the axis, false otherwise
-
zEn
Booleantrue to enable the axis, false otherwise
Returns:
true if successful
suspend
()
Number
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
softReset
()
Number
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
sleep
-
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:
-
enable
Booleantrue to set low power mode, false otherwise
Returns:
true if successful
setSleepDuration
-
dur
when in low power (sleep) mode, specify how often the device wakes up to acquire samples.
Parameters:
-
dur
SLEEP_DUR_Tone of the SLEEP_DUR_T values
Returns:
true if successful
setLowGThreshold
-
thresh
specify the threshold for low G detection
Parameters:
-
thresh
Numbersee the datasheet
Returns:
true if successful
setHighGThreshold
-
thresh
specify the threshold for high G detection
Parameters:
-
thresh
Numbersee the datasheet
Returns:
true if successful
setLowGHysteresis
-
hyst
specify the hysteresis for low G detection
Parameters:
-
hyst
Number2 bit hysteresis value
Returns:
true if successful
setLowGDuration
-
dur
specify the sample duration for low G detection
Parameters:
-
dur
Numberthe number of samples (depends on bandwidth)
Returns:
true if successful
setHighGHysteresis
-
hyst
specify the hysteresis for high G detection
Parameters:
-
hyst
Number2 bit hysteresis value
Returns:
true if successful
setHighGDuration
-
dur
specify the sample duration for high G detection
Parameters:
-
dur
Numberthe number of samples (depends on bandwidth)
Returns:
true if successful
setTapDuration
-
dur
specify the sample duration for tap detection
Parameters:
-
dur
Numberthe number of samples (depends on bandwidth)
Returns:
true if successful
setTapThreshold
-
thresh
specify the threshold for tap detection
Parameters:
-
thresh
Numbersee the datasheet
Returns:
true if successful
enableTapFilter
-
filt
unable to disable tap filtering
Parameters:
-
filt
Booleantrue to enable, false otherwise
Returns:
true if successful
setSlopeDuration
-
dur
specify the sample duration for slope detection
Parameters:
-
dur
Numberthe number of samples (depends on bandwidth)
Returns:
true if successful
setSlopeThreshold
-
thresh
specify the threshold for slope detection
Parameters:
-
thresh
Numbersee the datasheet
Returns:
true if successful
enableSlopeFilter
-
filt
enable or disable slope filtering
Parameters:
-
filt
Booleantrue to enable filtering, false otherwise
Returns:
true if successful
getInterruptStatus1
()
Number
return a bitmask of the interrupt status 1 register
Returns:
bitmask of INT_STATUS1_BITS_T bits (minus the orient value)
getOrient
()
CONFIG_ORIENT_T
return the orient value from the interrupt status 1 register
Returns:
one of the CONFIG_ORIENT_T values
getInterruptStatus2
()
Number
return a bitmask of the interrupt status 2 register
Returns:
bitmask of INT_STATUS2_BITS_T bits
setInterruptEnables1
-
bits
enable interrupts for events in interrupt config register 1
Parameters:
-
bits
Numberbitmask of ENABLE_CONFIG_BITS_T values
Returns:
true if successful
getInterruptEnables1
()
Number
return the enabled interrupts for events in interrupt config register 1
Returns:
bitmask of ENABLE_CONFIG_BITS_T values
setInterruptEnables2
-
bits
enable interrupts for events in interrupt config register 2
Parameters:
-
bits
Numberbitmask of ENABLE_CONFIG2_BITS_T values
Returns:
true if successful
getInterruptEnables2
()
Number
return the enabled interrupts for events in interrupt config register 2
Returns:
bitmask of ENABLE_CONFIG2_BITS_T values
setInterruptLatch
-
lat
configure interrupt latching behavior
Parameters:
-
lat
CONFIG2_LAT_Tone of the CONFIG2_LAT_T values
Returns:
true if successful
resetInterrupts
()
Boolean
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
installISR
-
gpio
-
level
-
isr
-
arg
install an interrupt handler.
Parameters:
-
gpio
Numbergpio pin to use as interrupt pin
-
level
Mraa::Edgethe interrupt trigger level (one of mraa::Edge values). Make sure that you have configured the interrupt pin properly for whatever level you choose.
-
isr
Functionthe interrupt handler, accepting a void * argument
-
arg
Void *the argument to pass the the interrupt handler
uninstallISR
()
uninstall a previously installed interrupt handler