Atmel Software Framework

bma222.h File Reference

Bosch BMA222 3-axis accelerometer driver.

This file contains functions for initializing and reading data from a Bosch BMA222 3-axis accelerometer.

Copyright (c) 2012 Atmel Corporation. All rights reserved.

#include <asf.h>

Macros

#define BMA222_DATA_RESOLUTION   (8) /* signed axis data size (bits) */
 
#define BMA222_SPI_MODE   (3)
 
#define BMA222_TEMP_OFFSET   (24) /* temperature center (Celsius) */
 
#define BMA222_TWI_ADDR   (0x08)
 
#define hysteresis_in_g(hysteresis, range)   (((threshold) * 4) / (range))
 convert real G values into hysteresis register values More...
 
#define threshold_in_g(threshold, range)   (((threshold) * 16) / (range))
 convert real G values into register values More...
 
#define BMA222_ID_VAL   (0x03)
 BMA222 Register Bit Definitions. More...
 
#define BMA222_FLAT_INT   (1 << 7) /* flat interrupt status */
 
#define BMA222_ORIENT_INT   (1 << 6) /* orientation interrupt status */
 
#define BMA222_S_TAP_INT   (1 << 5) /* single tap interrupt status */
 
#define BMA222_D_TAP_INT   (1 << 4) /* double tap interrupt status */
 
#define BMA222_SLOPE_INT   (1 << 2) /* slope interrupt status */
 
#define BMA222_HIGH_INT   (1 << 1) /* high-g interrupt status */
 
#define BMA222_LOW_INT   (1 << 0) /* low-g interrupt status */
 
#define BMA222_DATA_INT   (1 << 7) /* new data interrupt status */
 
#define BMA222_TAP_SIGN_POS   (1 << 7) /* tap interrupt sign (0=negative) */
 
#define BMA222_TAP_FIRST_Z   (1 << 6) /* z-axis triggered tap interrupt */
 
#define BMA222_TAP_FIRST_Y   (1 << 5) /* y-axis triggered tap interrupt */
 
#define BMA222_TAP_FIRST_X   (1 << 4) /* x-axis triggered tap interrupt */
 
#define BMA222_SLOPE_SIGN_POS   (1 << 3) /* slope interrupt sign (0=negative) */
 
#define BMA222_SLOPE_FIRST_Z   (1 << 2) /* z-axis triggered slope interrupt */
 
#define BMA222_SLOPE_FIRST_Y   (1 << 1) /* y-axis triggered slope interrupt */
 
#define BMA222_SLOPE_FIRST_X   (1 << 0) /* x-axis triggered slope interrupt */
 
#define BMA222_FLAT   (1 << 7) /* flat condition is fulfilled */
 
#define BMA222_Z_DOWN   (1 << 6) /* z-axis orientation (0=upward) */
 
#define BMA222_XY_PORTRAIT_UP   (0 << 4) /* x-y plane portrait upright */
 
#define BMA222_XY_PORTRAIT_DOWN   (1 << 4) /* x-y plane portrait upside-down */
 
#define BMA222_XY_LANDSCAPE_L   (2 << 4) /* x-y plane landscape left */
 
#define BMA222_XY_LANDSCAPE_R   (3 << 4) /* x-y plane landscape right */
 
#define BMA222_HIGH_SIGN_NEG
 
#define BMA222_HIGH_FIRST_Z   (1 << 2) /* z-axis triggered high-g interrupt */
 
#define BMA222_HIGH_FIRST_Y   (1 << 1) /* y-axis triggered high-g interrupt */
 
#define BMA222_HIGH_FIRST_X   (1 << 0) /* x-axis triggered high-g interrupt */
 
#define BMA222_RANGE_2G   (0x03) /* +/- 2g range (default) */
 
#define BMA222_RANGE_4G   (0x05) /* +/- 4g range */
 
#define BMA222_RANGE_8G   (0x08) /* +/- 8g range */
 
#define BMA222_RANGE_16G   (0x0c) /* +/- 16g range */
 
#define BMA222_BANDWIDTH_8Hz   (0x08) /* 7.81 Hz filtered data bandwidth */
 
#define BMA222_BANDWIDTH_16Hz   (0x09) /* 15.63 Hz filtered data bandwidth */
 
#define BMA222_BANDWIDTH_31Hz   (0x0a) /* 31.25 Hz filtered data bandwidth */
 
#define BMA222_BANDWIDTH_63Hz   (0x0b) /* 62.5 Hz filtered data bandwidth */
 
#define BMA222_BANDWIDTH_125Hz   (0x0c) /* 125 Hz filtered data bandwidth */
 
#define BMA222_BANDWIDTH_250Hz   (0x0d) /* 250 Hz filtered data bandwidth */
 
#define BMA222_BANDWIDTH_500Hz   (0x0e) /* 500 Hz filtered data bandwidth */
 
#define BMA222_BANDWIDTH_1000Hz   (0x1f) /* 1000 Hz filtered data bandwidth */
 
#define BMA222_SUSPEND   (1 << 7) /* set suspend mode (0=reset mode) */
 
#define BMA222_LOWPOWER_EN   (1 << 6) /* set low-power mode (0=reset mode) */
 
#define BMA222_SLEEP_DUR_0_5ms   (5 << 1) /* 0.5 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_1ms   (6 << 1) /* 1 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_2ms   (7 << 1) /* 2 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_4ms   (8 << 1) /* 4 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_6ms   (9 << 1) /* 6 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_10ms   (10 << 1) /* 6 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_25ms   (11 << 1) /* 25 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_50ms   (12 << 1) /* 50 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_100ms   (13 << 1) /* 100 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_500ms   (14 << 1) /* 500 ms sleep phase duration */
 
#define BMA222_SLEEP_DUR_1000ms   (15 << 1) /* 1 s sleep phase duration */
 
#define BMA222_DATA_UNFILTERED   (1 << 7) /* unfiltered data (0=filtered) */
 
#define BMA222_RESET   (0xb6) /* user-triggered reset write value */
 
#define BMA222_FLAT_EN   (1 << 7) /* flat interrupt enable */
 
#define BMA222_ORIENT_EN   (1 << 6) /* orientation interrupt enable */
 
#define BMA222_S_TAP_EN   (1 << 5) /* single tap interrupt enable */
 
#define BMA222_D_TAP_EN   (1 << 4) /* double tap interrupt enable */
 
#define BMA222_SLOPE_EN_Z   (1 << 2) /* z-axis slope interrupt enable */
 
#define BMA222_SLOPE_EN_Y   (1 << 1) /* y-axis slope interrupt enable */
 
#define BMA222_SLOPE_EN_X   (1 << 0) /* x-axis slope interrupt enable */
 
#define BMA222_DATA_EN   (1 << 4) /* new data interrupt enable */
 
#define BMA222_LOW_EN   (1 << 3) /* low-g interrupt enable */
 
#define BMA222_HIGH_EN_Z   (1 << 2) /* z-axis high-g interrupt enable */
 
#define BMA222_HIGH_EN_Y   (1 << 1) /* y-axis high-g interrupt enable */
 
#define BMA222_HIGH_EN_X   (1 << 0) /* x-axis high-g interrupt enable */
 
#define BMA222_INT1_FLAT   (1 << 7) /* map flat interrupt to INT1 */
 
#define BMA222_INT1_ORIENT   (1 << 6) /* map orientation interrupt to INT1 */
 
#define BMA222_INT1_S_TAP   (1 << 5) /* map single tap interrupt to INT1 */
 
#define BMA222_INT1_D_TAP   (1 << 4) /* map double tap interrupt to INT1 */
 
#define BMA222_INT1_SLOPE   (1 << 2) /* map slope interrupt to INT1 */
 
#define BMA222_INT1_HIGH   (1 << 1) /* map high-g interrupt to INT1 */
 
#define BMA222_INT1_LOW   (1 << 0) /* map low-g interrupt to INT1 */
 
#define BMA222_INT2_DATA   (1 << 7) /* map new data interrupt to INT2 */
 
#define BMA222_INT1_DATA   (1 << 0) /* map new data interrupt to INT1 */
 
#define BMA222_INT2_FLAT   (1 << 7) /* map flat interrupt to INT2 */
 
#define BMA222_INT2_ORIENT   (1 << 6) /* map orientation interrupt to INT2 */
 
#define BMA222_INT2_S_TAP   (1 << 5) /* map single tap interrupt to INT2 */
 
#define BMA222_INT2_D_TAP   (1 << 4) /* map double tap interrupt to INT2 */
 
#define BMA222_INT2_SLOPE   (1 << 2) /* map slope interrupt to INT2 */
 
#define BMA222_INT2_HIGH   (1 << 1) /* map high-g interrupt to INT2 */
 
#define BMA222_INT2_LOW   (1 << 0) /* map low-g interrupt to INT2 */
 
#define BMA222_INT_SRC_DATA   (1 << 5) /* unfiltered new data interrupt */
 
#define BMA222_INT_SRC_TAP   (1 << 4) /* unfiltered s/d tap interrupt data */
 
#define BMA222_INT_SRC_SLOPE   (1 << 2) /* unfiltered slope interrupt data */
 
#define BMA222_INT_SRC_HIGH   (1 << 1) /* unfiltered high-g interrupt data */
 
#define BMA222_INT_SRC_LOW   (1 << 0) /* unfiltered low-g interrupt data */
 
#define BMA222_INT2_OD   (1 << 3) /* open drive for INT2 pin */
 
#define BMA222_INT2_LVL_1   (1 << 2) /* active level 1 for INT2 (default) */
 
#define BMA222_INT1_OD   (1 << 1) /* open drive for INT1 pin */
 
#define BMA222_INT1_LVL_1   (1 << 0) /* active level 1 for INT1 (default) */
 
#define BMA222_RESET_INT   (0x80) /* reset any latch interrupt */
 
#define BMA222_INT_NON_LATCHED   (0x00) /* non-latch interrupt (default) */
 
#define BMA222_INT_TMP_250ms   (0x01) /* 250ms temporary latch interrupt */
 
#define BMA222_INT_TMP_500ms   (0x02) /* 500ms temporary latch interrupt */
 
#define BMA222_INT_TMP_1sec   (0x03) /* 1000ms temporary latch interrupt */
 
#define BMA222_INT_TMP_2sec   (0x04) /* 2000ms temporary latch interrupt */
 
#define BMA222_INT_TMP_4sec   (0x05) /* 4000ms temporary latch interrupt */
 
#define BMA222_INT_TMP_8sec   (0x06) /* 8000ms temporary latch interrupt */
 
#define BMA222_INT_TMP_500us   (0x0a) /* 500us temporary latch interrupt */
 
#define BMA222_INT_TMP_1ms   (0x0b) /* 1ms temporary latch interrupt */
 
#define BMA222_INT_TMP_12_5ms   (0x0c) /* 12.5ms temporary latch interrupt */
 
#define BMA222_INT_TMP_25ms   (0x0d) /* 25ms temporary latch interrupt */
 
#define BMA222_INT_TMP_50ms   (0x0e) /* 50ms temporary latch interrupt */
 
#define BMA222_INT_LATCHED   (0x0f) /* latch interrupt mode */
 
#define BMA222_TAP_TH_FIELD   (0x1f) /* tap interrupt threshold field */
 BMA222_LOW_G_DURATION (0x22) More...
 
#define BMA222_TAP_SAMP_FIELD   (0xc0) /* tap wake-up samples count field */
 
#define BMA222_SELF_TEST_NONE   (0x00) /* no self-test (default) */
 
#define BMA222_SELF_TEST_AXIS_X   (0x01) /* self-test positive x-axis */
 
#define BMA222_SELF_TEST_AXIS_Y   (0x02) /* self-test positive y-axis */
 
#define BMA222_SELF_TEST_AXIS_Z   (0x03) /* self-test positive z-axis */
 

Enumerations

enum  bma222_register_t {
  BMA222_CHIP_ID = 0,
  BMA222_01_RSVD,
  BMA222_NEW_DATA_X,
  BMA222_ACC_X,
  BMA222_NEW_DATA_Y,
  BMA222_ACC_Y,
  BMA222_NEW_DATA_Z,
  BMA222_ACC_Z,
  BMA222_TEMP,
  BMA222_INTR_STATUS,
  BMA222_NEW_DATA_STATUS,
  BMA222_TAP_SLOPE_STATUS,
  BMA222_ORIENTATION_STATUS,
  BMA222_0D_RSVD,
  BMA222_0E_RSVD,
  BMA222_G_RANGE,
  BMA222_BANDWIDTH,
  BMA222_POWER_MODES,
  BMA222_12_RSVD,
  BMA222_DATA_HIGH_BW,
  BMA222_SOFTRESET,
  BMA222_15_RSVD,
  BMA222_16_INTR_EN,
  BMA222_17_INTR_EN,
  BMA222_18_RSVD,
  BMA222_19_INTR_MAP,
  BMA222_1A_INTR_MAP,
  BMA222_1B_INTR_MAP,
  BMA222_1C_RSVD,
  BMA222_1D_RSVD,
  BMA222_INTR_DATA_SRC,
  BMA222_1F_RSVD,
  BMA222_INTR_PIN_CONFIG,
  BMA222_INTR_PIN_MODE,
  BMA222_LOW_G_DURATION,
  BMA222_LOW_G_THRESHOLD,
  BMA222_EVENT_HYSTERESIS,
  BMA222_HIGH_G_DURATION,
  BMA222_HIGH_G_THRESHOLD,
  BMA222_SLOPE_DURATION,
  BMA222_SLOPE_THRESHOLD,
  BMA222_29_RSVD,
  BMA222_TAP_TIMING,
  BMA222_TAP_CONFIG,
  BMA222_ORIENTATION_CONFIG,
  BMA222_ORIENTATION_THETA,
  BMA222_FLAT_THETA,
  BMA222_FLAT_HOLD_TIME,
  BMA222_30_RSVD,
  BMA222_31_RSVD,
  BMA222_SENSOR_SELF_TEST,
  BMA222_EEPROM_CONTROL,
  BMA222_DIGITAL_IO_CONTROL,
  BMA222_35_RSVD,
  BMA222_FAST_OFFSET_COMP,
  BMA222_SLOW_OFFSET_COMP,
  BMA222_OFFSET_FILT_X,
  BMA222_OFFSET_FILT_Y,
  BMA222_OFFSET_FILT_Z,
  BMA222_OFFSET_UNFILT_X,
  BMA222_OFFSET_UNFILT_Y,
  BMA222_OFFSET_UNFILT_Z
}
 

Functions

bool bma222_init (sensor_t *, int)
 Bosch BMA222 accelerometer driver initialization. More...
 

#define BMA222_BANDWIDTH_1000Hz   (0x1f) /* 1000 Hz filtered data bandwidth */
#define BMA222_BANDWIDTH_125Hz   (0x0c) /* 125 Hz filtered data bandwidth */
#define BMA222_BANDWIDTH_16Hz   (0x09) /* 15.63 Hz filtered data bandwidth */
#define BMA222_BANDWIDTH_250Hz   (0x0d) /* 250 Hz filtered data bandwidth */
#define BMA222_BANDWIDTH_31Hz   (0x0a) /* 31.25 Hz filtered data bandwidth */
#define BMA222_BANDWIDTH_500Hz   (0x0e) /* 500 Hz filtered data bandwidth */
#define BMA222_BANDWIDTH_63Hz   (0x0b) /* 62.5 Hz filtered data bandwidth */
#define BMA222_BANDWIDTH_8Hz   (0x08) /* 7.81 Hz filtered data bandwidth */
#define BMA222_D_TAP_EN   (1 << 4) /* double tap interrupt enable */

Referenced by bma222_event().

#define BMA222_D_TAP_INT   (1 << 4) /* double tap interrupt status */
#define BMA222_DATA_EN   (1 << 4) /* new data interrupt enable */

Referenced by bma222_event().

#define BMA222_DATA_INT   (1 << 7) /* new data interrupt status */
#define BMA222_DATA_RESOLUTION   (8) /* signed axis data size (bits) */

Referenced by bma222_init().

#define BMA222_DATA_UNFILTERED   (1 << 7) /* unfiltered data (0=filtered) */
#define BMA222_FLAT   (1 << 7) /* flat condition is fulfilled */
#define BMA222_FLAT_EN   (1 << 7) /* flat interrupt enable */
#define BMA222_FLAT_INT   (1 << 7) /* flat interrupt status */
#define BMA222_HIGH_EN_X   (1 << 0) /* x-axis high-g interrupt enable */

Referenced by bma222_event().

#define BMA222_HIGH_EN_Y   (1 << 1) /* y-axis high-g interrupt enable */

Referenced by bma222_event().

#define BMA222_HIGH_EN_Z   (1 << 2) /* z-axis high-g interrupt enable */

Referenced by bma222_event().

#define BMA222_HIGH_FIRST_X   (1 << 0) /* x-axis triggered high-g interrupt */
#define BMA222_HIGH_FIRST_Y   (1 << 1) /* y-axis triggered high-g interrupt */
#define BMA222_HIGH_FIRST_Z   (1 << 2) /* z-axis triggered high-g interrupt */
#define BMA222_HIGH_INT   (1 << 1) /* high-g interrupt status */
#define BMA222_HIGH_SIGN_NEG
Value:
(1 << 3) /* high-g interrupt sign
* (0=positive) */
#define BMA222_ID_VAL   (0x03)

BMA222 Register Bit Definitions.

Referenced by bma222_init().

#define BMA222_INT1_D_TAP   (1 << 4) /* map double tap interrupt to INT1 */
#define BMA222_INT1_DATA   (1 << 0) /* map new data interrupt to INT1 */
#define BMA222_INT1_FLAT   (1 << 7) /* map flat interrupt to INT1 */
#define BMA222_INT1_HIGH   (1 << 1) /* map high-g interrupt to INT1 */
#define BMA222_INT1_LOW   (1 << 0) /* map low-g interrupt to INT1 */
#define BMA222_INT1_LVL_1   (1 << 0) /* active level 1 for INT1 (default) */
#define BMA222_INT1_OD   (1 << 1) /* open drive for INT1 pin */
#define BMA222_INT1_ORIENT   (1 << 6) /* map orientation interrupt to INT1 */
#define BMA222_INT1_S_TAP   (1 << 5) /* map single tap interrupt to INT1 */
#define BMA222_INT1_SLOPE   (1 << 2) /* map slope interrupt to INT1 */
#define BMA222_INT2_D_TAP   (1 << 4) /* map double tap interrupt to INT2 */
#define BMA222_INT2_DATA   (1 << 7) /* map new data interrupt to INT2 */
#define BMA222_INT2_FLAT   (1 << 7) /* map flat interrupt to INT2 */
#define BMA222_INT2_HIGH   (1 << 1) /* map high-g interrupt to INT2 */
#define BMA222_INT2_LOW   (1 << 0) /* map low-g interrupt to INT2 */
#define BMA222_INT2_LVL_1   (1 << 2) /* active level 1 for INT2 (default) */
#define BMA222_INT2_OD   (1 << 3) /* open drive for INT2 pin */
#define BMA222_INT2_ORIENT   (1 << 6) /* map orientation interrupt to INT2 */
#define BMA222_INT2_S_TAP   (1 << 5) /* map single tap interrupt to INT2 */
#define BMA222_INT2_SLOPE   (1 << 2) /* map slope interrupt to INT2 */
#define BMA222_INT_LATCHED   (0x0f) /* latch interrupt mode */
#define BMA222_INT_NON_LATCHED   (0x00) /* non-latch interrupt (default) */
#define BMA222_INT_SRC_DATA   (1 << 5) /* unfiltered new data interrupt */
#define BMA222_INT_SRC_HIGH   (1 << 1) /* unfiltered high-g interrupt data */
#define BMA222_INT_SRC_LOW   (1 << 0) /* unfiltered low-g interrupt data */
#define BMA222_INT_SRC_SLOPE   (1 << 2) /* unfiltered slope interrupt data */
#define BMA222_INT_SRC_TAP   (1 << 4) /* unfiltered s/d tap interrupt data */
#define BMA222_INT_TMP_12_5ms   (0x0c) /* 12.5ms temporary latch interrupt */
#define BMA222_INT_TMP_1ms   (0x0b) /* 1ms temporary latch interrupt */
#define BMA222_INT_TMP_1sec   (0x03) /* 1000ms temporary latch interrupt */
#define BMA222_INT_TMP_250ms   (0x01) /* 250ms temporary latch interrupt */
#define BMA222_INT_TMP_25ms   (0x0d) /* 25ms temporary latch interrupt */
#define BMA222_INT_TMP_2sec   (0x04) /* 2000ms temporary latch interrupt */
#define BMA222_INT_TMP_4sec   (0x05) /* 4000ms temporary latch interrupt */
#define BMA222_INT_TMP_500ms   (0x02) /* 500ms temporary latch interrupt */
#define BMA222_INT_TMP_500us   (0x0a) /* 500us temporary latch interrupt */
#define BMA222_INT_TMP_50ms   (0x0e) /* 50ms temporary latch interrupt */
#define BMA222_INT_TMP_8sec   (0x06) /* 8000ms temporary latch interrupt */
#define BMA222_LOW_EN   (1 << 3) /* low-g interrupt enable */

Referenced by bma222_event().

#define BMA222_LOW_INT   (1 << 0) /* low-g interrupt status */
#define BMA222_LOWPOWER_EN   (1 << 6) /* set low-power mode (0=reset mode) */

Referenced by bma222_sleep_en().

#define BMA222_ORIENT_EN   (1 << 6) /* orientation interrupt enable */
#define BMA222_ORIENT_INT   (1 << 6) /* orientation interrupt status */
#define BMA222_RANGE_16G   (0x0c) /* +/- 16g range */
#define BMA222_RANGE_2G   (0x03) /* +/- 2g range (default) */
#define BMA222_RANGE_4G   (0x05) /* +/- 4g range */
#define BMA222_RANGE_8G   (0x08) /* +/- 8g range */
#define BMA222_RESET   (0xb6) /* user-triggered reset write value */

Referenced by bma222_set_state().

#define BMA222_RESET_INT   (0x80) /* reset any latch interrupt */
#define BMA222_S_TAP_EN   (1 << 5) /* single tap interrupt enable */

Referenced by bma222_event().

#define BMA222_S_TAP_INT   (1 << 5) /* single tap interrupt status */
#define BMA222_SELF_TEST_AXIS_X   (0x01) /* self-test positive x-axis */
#define BMA222_SELF_TEST_AXIS_Y   (0x02) /* self-test positive y-axis */
#define BMA222_SELF_TEST_AXIS_Z   (0x03) /* self-test positive z-axis */
#define BMA222_SELF_TEST_NONE   (0x00) /* no self-test (default) */
#define BMA222_SLEEP_DUR_0_5ms   (5 << 1) /* 0.5 ms sleep phase duration */
#define BMA222_SLEEP_DUR_1000ms   (15 << 1) /* 1 s sleep phase duration */
#define BMA222_SLEEP_DUR_100ms   (13 << 1) /* 100 ms sleep phase duration */
#define BMA222_SLEEP_DUR_10ms   (10 << 1) /* 6 ms sleep phase duration */
#define BMA222_SLEEP_DUR_1ms   (6 << 1) /* 1 ms sleep phase duration */

Referenced by bma222_sleep_en().

#define BMA222_SLEEP_DUR_25ms   (11 << 1) /* 25 ms sleep phase duration */
#define BMA222_SLEEP_DUR_2ms   (7 << 1) /* 2 ms sleep phase duration */
#define BMA222_SLEEP_DUR_4ms   (8 << 1) /* 4 ms sleep phase duration */
#define BMA222_SLEEP_DUR_500ms   (14 << 1) /* 500 ms sleep phase duration */
#define BMA222_SLEEP_DUR_50ms   (12 << 1) /* 50 ms sleep phase duration */
#define BMA222_SLEEP_DUR_6ms   (9 << 1) /* 6 ms sleep phase duration */
#define BMA222_SLOPE_EN_X   (1 << 0) /* x-axis slope interrupt enable */

Referenced by bma222_event().

#define BMA222_SLOPE_EN_Y   (1 << 1) /* y-axis slope interrupt enable */

Referenced by bma222_event().

#define BMA222_SLOPE_EN_Z   (1 << 2) /* z-axis slope interrupt enable */

Referenced by bma222_event().

#define BMA222_SLOPE_FIRST_X   (1 << 0) /* x-axis triggered slope interrupt */
#define BMA222_SLOPE_FIRST_Y   (1 << 1) /* y-axis triggered slope interrupt */
#define BMA222_SLOPE_FIRST_Z   (1 << 2) /* z-axis triggered slope interrupt */
#define BMA222_SLOPE_INT   (1 << 2) /* slope interrupt status */
#define BMA222_SLOPE_SIGN_POS   (1 << 3) /* slope interrupt sign (0=negative) */
#define BMA222_SPI_MODE   (3)
#define BMA222_SUSPEND   (1 << 7) /* set suspend mode (0=reset mode) */

Referenced by bma222_set_state().

#define BMA222_TAP_FIRST_X   (1 << 4) /* x-axis triggered tap interrupt */
#define BMA222_TAP_FIRST_Y   (1 << 5) /* y-axis triggered tap interrupt */
#define BMA222_TAP_FIRST_Z   (1 << 6) /* z-axis triggered tap interrupt */
#define BMA222_TAP_SAMP_FIELD   (0xc0) /* tap wake-up samples count field */
#define BMA222_TAP_SIGN_POS   (1 << 7) /* tap interrupt sign (0=negative) */
#define BMA222_TAP_TH_FIELD   (0x1f) /* tap interrupt threshold field */

BMA222_LOW_G_DURATION (0x22)

Low-G interrupt delay time constants where the physical delay time is computed as: delay[ms] = [low_dur + 1] * 2ms. The default value is 0x09 corresponding to a delay of 20ms. BMA222_LOW_G_THRESHOLD (0x23)

The log-g interrupt threshold value LSB corresponds to an acceleration of 7.81mg with range 0 to 1.992g. The default value is 0x30 corresponding to 375mg.

Referenced by bma222_get_threshold(), and bma222_set_threshold().

#define BMA222_TEMP_OFFSET   (24) /* temperature center (Celsius) */

Referenced by bma222_get_temperature().

#define BMA222_TWI_ADDR   (0x08)
#define BMA222_XY_LANDSCAPE_L   (2 << 4) /* x-y plane landscape left */
#define BMA222_XY_LANDSCAPE_R   (3 << 4) /* x-y plane landscape right */
#define BMA222_XY_PORTRAIT_DOWN   (1 << 4) /* x-y plane portrait upside-down */
#define BMA222_XY_PORTRAIT_UP   (0 << 4) /* x-y plane portrait upright */
#define BMA222_Z_DOWN   (1 << 6) /* z-axis orientation (0=upward) */
#define hysteresis_in_g (   hysteresis,
  range 
)    (((threshold) * 4) / (range))

convert real G values into hysteresis register values

Note
no range checking is included
#define threshold_in_g (   threshold,
  range 
)    (((threshold) * 16) / (range))

convert real G values into register values

Note
no range checking is included

Enumerator
BMA222_CHIP_ID 
BMA222_01_RSVD 
BMA222_NEW_DATA_X 
BMA222_ACC_X 
BMA222_NEW_DATA_Y 
BMA222_ACC_Y 
BMA222_NEW_DATA_Z 
BMA222_ACC_Z 
BMA222_TEMP 
BMA222_INTR_STATUS 
BMA222_NEW_DATA_STATUS 
BMA222_TAP_SLOPE_STATUS 
BMA222_ORIENTATION_STATUS 
BMA222_0D_RSVD 
BMA222_0E_RSVD 
BMA222_G_RANGE 
BMA222_BANDWIDTH 
BMA222_POWER_MODES 
BMA222_12_RSVD 
BMA222_DATA_HIGH_BW 
BMA222_SOFTRESET 
BMA222_15_RSVD 
BMA222_16_INTR_EN 
BMA222_17_INTR_EN 
BMA222_18_RSVD 
BMA222_19_INTR_MAP 
BMA222_1A_INTR_MAP 
BMA222_1B_INTR_MAP 
BMA222_1C_RSVD 
BMA222_1D_RSVD 
BMA222_INTR_DATA_SRC 
BMA222_1F_RSVD 
BMA222_INTR_PIN_CONFIG 
BMA222_INTR_PIN_MODE 
BMA222_LOW_G_DURATION 
BMA222_LOW_G_THRESHOLD 
BMA222_EVENT_HYSTERESIS 
BMA222_HIGH_G_DURATION 
BMA222_HIGH_G_THRESHOLD 
BMA222_SLOPE_DURATION 
BMA222_SLOPE_THRESHOLD 
BMA222_29_RSVD 
BMA222_TAP_TIMING 
BMA222_TAP_CONFIG 
BMA222_ORIENTATION_CONFIG 
BMA222_ORIENTATION_THETA 
BMA222_FLAT_THETA 
BMA222_FLAT_HOLD_TIME 
BMA222_30_RSVD 
BMA222_31_RSVD 
BMA222_SENSOR_SELF_TEST 
BMA222_EEPROM_CONTROL 
BMA222_DIGITAL_IO_CONTROL 
BMA222_35_RSVD 
BMA222_FAST_OFFSET_COMP 
BMA222_SLOW_OFFSET_COMP 
BMA222_OFFSET_FILT_X 
BMA222_OFFSET_FILT_Y 
BMA222_OFFSET_FILT_Z 
BMA222_OFFSET_UNFILT_X 
BMA222_OFFSET_UNFILT_Y 
BMA222_OFFSET_UNFILT_Z 

bool bma222_init ( sensor_t sensor,
int  resvd 
)

Bosch BMA222 accelerometer driver initialization.

This is the main initialization function for the BMA222 device.

Parameters
sensorAddress of a sensor device descriptor.
resvdReserved value.
Returns
bool true if the call succeeds, else false is returned.