upm
0.8.0
Sensor/Actuator repository for libmraa (v1.1.1)
|
API for the BMA250E 10 bit Trixial Accelerometer. More...
The BMA250E is a triaxial, low-g acceleration sensor with digital output for consumer applications. It allows measurements of acceleration in three perpendicular axes. An evaluation circuitry (ASIC) converts the output of a micromechanical acceleration-sensing structure (MEMS) that works according to the differential capacitance principle.
Not all functionality of this chip has been implemented in this driver, however all the pieces are present to add any desired functionality. This driver supports both I2C (default) and SPI operation.
This driver attempts to support verious flavors of this chip, such as the version on the BMX050, BMI050 (chipid 0xfa) and the version on the bmc050 (chipid 0x03). Not all functionality is appropriate, or even present on all chips. Consult the relevant datasheets.
This device requires 3.3v operation.
Public Types | |
enum | BMA250E_REGS_T : uint8_t { REG_CHIP_ID = 0x00, REG_ACCD_X_LSB = 0x02, REG_ACCD_X_MSB = 0x03, REG_ACCD_Y_LSB = 0x04, REG_ACCD_Y_MSB = 0x05, REG_ACCD_Z_LSB = 0x06, REG_ACCD_Z_MSB = 0x07, REG_TEMP = 0x08, REG_INT_STATUS_0 = 0x09, REG_INT_STATUS_1 = 0x0a, REG_INT_STATUS_2 = 0x0b, REG_INT_STATUS_3 = 0x0c, REG_FIFO_STATUS = 0x0e, REG_PMU_RANGE = 0x0f, REG_PMU_BW = 0x10, REG_PMU_LPW = 0x11, REG_PMU_LOW_POWER = 0x12, REG_ACC_HBW = 0x13, REG_SOFTRESET = 0x14, REG_INT_EN_0 = 0x16, REG_INT_EN_1 = 0x17, REG_INT_EN_2 = 0x18, REG_INT_MAP_0 = 0x19, REG_INT_MAP_1 = 0x1a, REG_INT_MAP_2 = 0x1b, REG_INT_SRC = 0x1e, REG_INT_OUT_CTRL = 0x20, REG_INT_RST_LATCH = 0x21, REG_INT_0 = 0x22, REG_INT_1 = 0x23, REG_INT_2 = 0x24, REG_INT_3 = 0x25, REG_INT_4 = 0x26, REG_INT_5 = 0x27, REG_INT_6 = 0x28, REG_INT_7 = 0x29, REG_INT_8 = 0x2a, REG_INT_9 = 0x2b, REG_INT_A = 0x2c, REG_INT_B = 0x2d, REG_INT_C = 0x2e, REG_INT_D = 0x2f, REG_FIFO_CONFIG_0 = 0x30, REG_PMU_SELFTEST = 0x32, REG_TRIM_NVM_CTRL = 0x33, REG_SPI3_WDT = 0x34, REG_OFC_CTRL = 0x36, REG_OFC_SETTING = 0x37, REG_OFC_OFFSET_X = 0x38, REG_OFC_OFFSET_Y = 0x39, REG_OFC_OFFSET_Z = 0x3a, REG_TRIM_GP0 = 0x3b, REG_TRIM_GP1 = 0x3c, REG_FIFO_CONFIG_1 = 0x3e, REG_FIFO_DATA = 0x3f } |
enum | ACCD10_LSB_BITS_T { ACCD10_LSB_NEW_DATA = 0x01, ACCD10_LSB0 = 0x40, ACCD10_LSB1 = 0x80, _ACCD10_LSB_MASK = 3, _ACCD10_LSB_SHIFT = 6 } |
enum | ACCD12_LSB_BITS_T { ACCD12_LSB_NEW_DATA = 0x01, ACCD12_LSB0 = 0x10, ACCD12_LSB1 = 0x20, ACCD12_LSB2 = 0x40, ACCD12_LSB3 = 0x80, _ACCD12_LSB_MASK = 15, _ACCD12_LSB_SHIFT = 4 } |
enum | INT_STATUS_0_BITS_T { INT_STATUS_0_LOW = 0x01, INT_STATUS_0_HIGH = 0x02, INT_STATUS_0_SLOPE = 0x04, INT_STATUS_0_SLO_NOT_MOT = 0x08, INT_STATUS_0_D_TAP = 0x10, INT_STATUS_0_S_TAP = 0x20, INT_STATUS_0_ORIENT = 0x40, INT_STATUS_0_FLAT = 0x80 } |
enum | INT_STATUS_1_BITS_T { _INT_STATUS_1_RESERVED_BITS = 0x0f | 0x10, INT_STATUS_1_FIFO_FULL = 0x20, INT_STATUS_1_FIFO_WM = 0x40, INT_STATUS_1_DATA = 0x80 } |
enum | INT_STATUS_2_BITS_T { INT_STATUS_2_SLOPE_FIRST_X = 0x01, INT_STATUS_2_SLOPE_FIRST_Y = 0x02, INT_STATUS_2_SLOPE_FIRST_Z = 0x04, INT_STATUS_2_SLOPE_SIGN = 0x08, INT_STATUS_2_TAP_FIRST_X = 0x10, INT_STATUS_2_TAP_FIRST_Y = 0x20, INT_STATUS_2_TAP_FIRST_Z = 0x40, INT_STATUS_2_TAP_SIGN = 0x80 } |
enum | INT_STATUS_3_BITS_T { INT_STATUS_3_HIGH_FIRST_X = 0x01, INT_STATUS_3_HIGH_FIRST_Y = 0x02, INT_STATUS_3_HIGH_FIRST_Z = 0x04, INT_STATUS_3_HIGH_SIGN = 0x08, INT_STATUS_3_ORIENT0 = 0x10, INT_STATUS_3_ORIENT1 = 0x20, INT_STATUS_3_ORIENT2 = 0x40, _INT_STATUS_3_ORIENT_MASK = 7, _INT_STATUS_3_ORIENT_SHIFT = 4, INT_STATUS_3_FLAT = 0x80 } |
enum | ORIENT_T { ORIENT_POTRAIT_UPRIGHT = 0, ORIENT_POTRAIT_UPSIDE_DOWN = 1, ORIENT_LANDSCAPE_LEFT = 2, ORIENT_LANDSCAPE_RIGHT = 3 } |
enum | FIFO_STATUS_BITS_T { FIFO_STATUS_FRAME_COUNTER0 = 0x01, FIFO_STATUS_FRAME_COUNTER1 = 0x02, FIFO_STATUS_FRAME_COUNTER2 = 0x04, FIFO_STATUS_FRAME_COUNTER3 = 0x08, FIFO_STATUS_FRAME_COUNTER4 = 0x10, FIFO_STATUS_FRAME_COUNTER5 = 0x20, FIFO_STATUS_FRAME_COUNTER6 = 0x40, _FIFO_STATUS_FRAME_COUNTER_MASK = 127, _FIFO_STATUS_FRAME_COUNTER_SHIFT = 0, FIFO_STATUS_FIFO_OVERRUN = 0x80 } |
enum | PMU_RANGE_BITS_T { PMU_RANGE0 = 0x01, PMU_RANGE1 = 0x02, PMU_RANGE2 = 0x04, PMU_RANGE3 = 0x08, _PMU_RANGE_MASK = 15, _PMU_RANGE_SHIFT = 0 } |
enum | RANGE_T { RANGE_2G = 3, RANGE_4G = 5, RANGE_8G = 8, RANGE_16G = 12 } |
enum | PMU_BW_BITS_T { PMU_BW0 = 0x01, PMU_BW1 = 0x02, PMU_BW2 = 0x04, PMU_BW3 = 0x08, PMU_BW4 = 0x10, _PMU_BW_MASK = 31, _PMU_BW_SHIFT = 0 } |
enum | BW_T { BW_7_81 = 8, BW_15_63 = 9, BW_31_25 = 10, BW_62_5 = 11, BW_125 = 12, BW_250 = 13, BW_500 = 14, BW_1000 = 15 } |
enum | PMU_LPW_BITS_T { _PMU_LPW_RESERVED_MASK = 0x01, PMU_LPW_SLEEP_DUR0 = 0x02, PMU_LPW_SLEEP_DUR1 = 0x04, PMU_LPW_SLEEP_DUR2 = 0x08, PMU_LPW_SLEEP_DUR3 = 0x10, _PMU_LPW_SLEEP_MASK = 15, _PMU_LPW_SLEEP_SHIFT = 1, PMU_LPW_POWER_MODE0 = 0x20, PMU_LPW_POWER_MODE1 = 0x40, PMU_LPW_POWER_MODE2 = 0x80, _PMU_LPW_POWER_MODE_MASK = 7, _PMU_LPW_POWER_MODE_SHIFT = 5 } |
enum | SLEEP_DUR_T { SLEEP_DUR_0_5 = 0, SLEEP_DUR_1 = 6, SLEEP_DUR_2 = 7, SLEEP_DUR_4 = 8, SLEEP_DUR_6 = 9, SLEEP_DUR_10 = 10, SLEEP_DUR_25 = 11, SLEEP_DUR_50 = 12, SLEEP_DUR_100 = 13, SLEEP_DUR_500 = 14, SLEEP_DUR_1000 = 15 } |
enum | POWER_MODE_T { POWER_MODE_NORMAL = 0, POWER_MODE_DEEP_SUSPEND = 1, POWER_MODE_LOW_POWER = 2, POWER_MODE_SUSPEND = 4 } |
enum | LOW_POWER_BITS_T { _LOW_POWER_RESERVED_BITS = 0x0f | 0x10 | 0x80, LOW_POWER_SLEEPTIMER_MODE = 0x20, LOW_POWER_LOWPOWER_MODE = 0x40 } |
enum | ACC_HBW_BITS_T { _ACC_HBW_RESERVED_BITS = 0x0f | 0x10 | 0x20, ACC_HBW_SHADOW_DIS = 0x40, ACC_HBW_DATA_HIGH_BW = 0x80 } |
enum | INT_EN_0_BITS_T { _INT_EN_0_RESERVED_BITS = 0x08, INT_EN_0_SLOPE_EN_X = 0x01, INT_EN_0_SLOPE_EN_Y = 0x02, INT_EN_0_SLOPE_EN_Z = 0x04, INT_EN_0_D_TAP_EN = 0x10, INT_EN_0_S_TAP_EN = 0x20, INT_EN_0_ORIENT_EN = 0x40, INT_EN_0_FLAT_EN = 0x80 } |
enum | INT_EN_1_BITS_T { _INT_EN_1_RESERVED_BITS = 0x80, INT_EN_1_HIGH_EN_X = 0x01, INT_EN_1_HIGH_EN_Y = 0x02, INT_EN_1_HIGH_EN_Z = 0x04, INT_EN_1_LOW_EN = 0x08, INT_EN_1_DATA_EN = 0x10, INT_EN_1_INT_FFULL_EN = 0x20, INT_EN_1_INT_FWM_EN = 0x40 } |
enum | INT_EN_2_BITS_T { _INT_EN_2_RESERVED_BITS = 0xf0, INT_EN_2_SLO_NO_MOT_EN_X = 0x01, INT_EN_2_SLO_NO_MOT_EN_Y = 0x02, INT_EN_2_SLO_NO_MOT_EN_Z = 0x04, INT_EN_2_SLO_NO_MOT_SEL = 0x08 } |
enum | INT_MAP_0_BITS_T { INT_MAP_0_INT1_LOW = 0x01, INT_MAP_0_INT1_HIGH = 0x02, INT_MAP_0_INT1_SLOPE = 0x04, INT_MAP_0_INT1_SLO_NO_MOT = 0x08, INT_MAP_0_INT1_D_TAP = 0x10, INT_MAP_0_INT1_S_TAP = 0x20, INT_MAP_0_INT1_ORIENT = 0x40, INT_MAP_0_INT1_FLAT = 0x80 } |
enum | INT_MAP_1_BITS_T { _INT_MAP_1_INT1_RESERVED_BITS = 0x08 | 0x10, INT_MAP_1_INT1_DATA = 0x01, INT_MAP_1_INT1_FWM = 0x02, INT_MAP_1_INT1_FFULL = 0x04, INT_MAP_1_INT2_FFULL = 0x20, INT_MAP_1_INT2_FWM = 0x40, INT_MAP_1_INT2_DATA = 0x80 } |
enum | INT_MAP_2_BITS_T { INT_MAP_2_INT2_LOW = 0x01, INT_MAP_2_INT2_HIGH = 0x02, INT_MAP_2_INT2_SLOPE = 0x04, INT_MAP_2_INT2_SLO_NO_MOT = 0x08, INT_MAP_2_INT2_D_TAP = 0x10, INT_MAP_2_INT2_S_TAP = 0x20, INT_MAP_2_INT2_ORIENT = 0x40, INT_MAP_2_INT2_FLAT = 0x80 } |
enum | INT_SRC_BITS_T { _INT_SRC_RESERVED_BITS = 0x40 | 0x80, INT_SRC_LOW = 0x01, INT_SRC_HIGH = 0x02, INT_SRC_SLO_NO_MOT = 0x04, INT_SRC_SLOPE = 0x08, INT_SRC_TAP = 0x10, INT_SRC_DATA = 0x20 } |
enum | INT_OUT_CTRL_BITS_T { _INT_OUT_CTRL_INT1_RESERVED_BITS = 0xf0, INT_OUT_CTRL_INT1_LVL = 0x01, INT_OUT_CTRL_INT1_OD = 0x02, INT_OUT_CTRL_INT2_LVL = 0x04, INT_OUT_CTRL_INT2_OD = 0x08 } |
enum | INT_RST_LATCH_BITS_T { _INT_RST_LATCH_RESERVED_BITS = 0x10 | 0x20 | 0x40, INT_RST_LATCH0 = 0x01, INT_RST_LATCH1 = 0x02, INT_RST_LATCH2 = 0x04, INT_RST_LATCH3 = 0x08, _INT_RST_LATCH_MASK = 15, _INT_RST_LATCH_SHIFT = 0, INT_RST_LATCH_RESET_INT = 0x80 } |
enum | RST_LATCH_T { RST_LATCH_NON_LATCHED = 0, RST_LATCH_TEMPORARY_250MS = 1, RST_LATCH_TEMPORARY_500MS = 2, RST_LATCH_TEMPORARY_1S = 3, RST_LATCH_TEMPORARY_2S = 4, RST_LATCH_TEMPORARY_4S = 5, RST_LATCH_TEMPORARY_8S = 6, RST_LATCH_LATCHED = 7, RST_LATCH_TEMPORARY_250US = 9, RST_LATCH_TEMPORARY_500US = 10, RST_LATCH_TEMPORARY_1MS = 11, RST_LATCH_TEMPORARY_12_5MS = 12, RST_LATCH_TEMPORARY_25MS = 13, RST_LATCH_TEMPORARY_50MS = 14 } |
enum | INT_2_BITS_T { INT_2_LOW_HY0 = 0x01, INT_2_LOW_HY1 = 0x02, _INT_2_LOW_HY_MASK = 3, _INT_2_LOW_HY_SHIFT = 0, INT_2_LOW_MODE = 0x04, INT_2_HIGH_HY0 = 0x40, INT_2_HIGH_HY1 = 0x80, _INT_2_HIGH_HY_MASK = 3, _INT_2_HIGH_HY_SHIFT = 6 } |
enum | INT_5_BITS_T { INT_5_SLOPE_DUR0 = 0x01, INT_5_SLOPE_DUR1 = 0x02, _INT_5_SLOPE_DUR_MASK = 3, _INT_5_SLOPE_DUR_SHIFT = 0, INT_5_SLO_NO_MOT_DUR0 = 0x04, INT_5_SLO_NO_MOT_DUR1 = 0x08, INT_5_SLO_NO_MOT_DUR2 = 0x10, INT_5_SLO_NO_MOT_DUR3 = 0x20, INT_5_SLO_NO_MOT_DUR4 = 0x40, INT_5_SLO_NO_MOT_DUR5 = 0x80, _INT_5_SLO_NO_MOT_DUR_MASK = 63, _INT_5_SLO_NO_MOT_DUR_SHIFT = 2 } |
enum | INT_8_BITS_T { INT_8_TAP_DUR0 = 0x01, INT_8_TAP_DUR1 = 0x02, INT_8_TAP_DUR2 = 0x04, _INT_8_TAP_DUR_MASK = 7, _INT_8_TAP_DUR_SHIFT = 0, INT_8_TAP_SHOCK = 0x40, INT_8_TAP_QUIET = 0x80 } |
enum | INT_9_BITS_T { INT_9_TAP_TH0 = 0x01, INT_9_TAP_TH1 = 0x02, INT_9_TAP_TH2 = 0x04, INT_9_TAP_TH3 = 0x08, INT_9_TAP_TH4 = 0x10, _INT_5_TAP_TH_MASK = 31, _INT_5_TAP_TH_SHIFT = 0, INT_9_TAP_SAMP0 = 0x40, INT_9_TAP_SAMP1 = 0x80, INT_9_TAP_SAMP1_MASK = 3, INT_9_TAP_SAMP1_SHIFT = 6 } |
enum | INT_A_BITS_T { INT_A_ORIENT_MODE0 = 0x01, INT_A_ORIENT_MODE1 = 0x02, _INT_A_ORIENT_MODE_MASK = 3, _INT_A_ORIENT_MODE_SHIFT = 0, INT_A_ORIENT_BLOCKING0 = 0x04, INT_A_ORIENT_BLOCKING1 = 0x08, _INT_A_ORIENT_BLOCKING_MASK = 3, _INT_A_ORIENT_BLOCKING_SHIFT = 2, INT_A_ORIENT_HYST0 = 0x10, INT_A_ORIENT_HYST1 = 0x20, INT_A_ORIENT_HYST2 = 0x40, _INT_A_ORIENT_HYST_MASK = 7, _INT_A_ORIENT_HYST_SHIFT = 4 } |
enum | ORIENT_MODE_T { ORIENT_MODE_SYMETRICAL = 0, ORIENT_MODE_HIGH_ASYMETRICAL = 1, ORIENT_MODE_LOW_ASYMETRICAL = 2 } |
enum | ORIENT_BLOCKING_T { ORIENT_BLOCKING_NONE = 0, ORIENT_BLOCKING_THETA_ACC_1_5G = 1, ORIENT_BLOCKING_THETA_ACC_0_2G_1_5G = 2, ORIENT_BLOCKING_THETA_ACC_0_4G_1_5G = 3 } |
enum | INT_B_BITS_T { INT_B_ORIENT_THETA0 = 0x01, INT_B_ORIENT_THETA1 = 0x02, INT_B_ORIENT_THETA2 = 0x04, INT_B_ORIENT_THETA3 = 0x08, INT_B_ORIENT_THETA4 = 0x10, INT_B_ORIENT_THETA5 = 0x20, _INT_B_ORIENT_THETA_MASK = 63, _INT_B_ORIENT_THETA_SHIFT = 0, INT_B_ORIENT_UD_EN = 0x40 } |
enum | INT_C_BITS_T { INT_B_FLAT_THETA0 = 0x01, INT_B_FLAT_THETA1 = 0x02, INT_B_FLAT_THETA2 = 0x04, INT_B_FLAT_THETA3 = 0x08, INT_B_FLAT_THETA4 = 0x10, INT_B_FLAT_THETA5 = 0x20, _INT_B_FLAT_THETA_MASK = 63, _INT_B_FLAT_THETA_SHIFT = 0 } |
enum | INT_D_BITS_T { INT_D_FLAT_HY0 = 0x01, INT_D_FLAT_HY1 = 0x02, INT_D_FLAT_HY2 = 0x04, _INT_B_FLAT_HY_MASK = 7, _INT_B_FLAT_HY_SHIFT = 0, INT_D_FLAT_HOLD_TIME0 = 0x10, INT_D_FLAT_HOLD_TIME1 = 0x20, _INT_B_FLAT_HOLD_TIME_MASK = 3, _INT_B_FLAT_HOLD_TIME_SHIFT = 4 } |
enum | FIFO_CONFIG_0_BITS_T { _FIFO_CONFIG_0_RESERVED_BITS = 0x80 | 0x40, FIFO_CONFIG_0_WATER_MARK0 = 0x01, FIFO_CONFIG_0_WATER_MARK1 = 0x02, FIFO_CONFIG_0_WATER_MARK2 = 0x04, FIFO_CONFIG_0_WATER_MARK3 = 0x08, FIFO_CONFIG_0_WATER_MARK4 = 0x10, FIFO_CONFIG_0_WATER_MARK5 = 0x20, _FIFO_CONFIG_0_WATER_MARK_MASK = 63, _FIFO_CONFIG_0_WATER_MARK_SHIFT = 0 } |
enum | PMU_SELFTTEST_BITS_T { PMU_SELFTTEST_AXIS0 = 0x01, PMU_SELFTTEST_AXIS1 = 0x02, _PMU_SELFTTEST_AXIS_MASK = 3, _PMU_SELFTTEST_AXIS_SHIFT = 0, PMU_SELFTTEST_SIGN = 0x04, PMU_SELFTTEST_AMP = 0x10 } |
enum | SELFTTEST_AXIS_T { SELFTTEST_AXIS_NONE = 0, SELFTTEST_AXIS_X = 1, SELFTTEST_AXIS_Y = 2, SELFTTEST_AXIS_Z = 3 } |
enum | TRIM_NVM_CTRL_BITS_T { TRIM_NVM_CTRL_NVM_PROG_MODE = 0x01, TRIM_NVM_CTRL_NVM_PROG_TRIG = 0x02, TRIM_NVM_CTRL_NVM_PROG_RDY = 0x04, TRIM_NVM_CTRL_NVM_PROG_LOAD = 0x08, TRIM_NVM_CTRL_NVM_REMAIN0 = 0x10, TRIM_NVM_CTRL_NVM_REMAIN1 = 0x20, TRIM_NVM_CTRL_NVM_REMAIN2 = 0x40, TRIM_NVM_CTRL_NVM_REMAIN3 = 0x80, _TRIM_NVM_CTRL_NVM_REMAIN_MASK = 15, _TRIM_NVM_CTRL_NVM_REMAIN_SHIFT = 4 } |
enum | SPI3_WDT_BITS_T { _SPI3_WDT_RESERVED_BITS = 0xf0 | 0x08, SPI3_WDT_SPI3 = 0x01, SPI3_WDT_I2C_WDT_SEL = 0x02, SPI3_WDT_I2C_WDT_EN = 0x04 } |
enum | OFC_CTRL_BITS_T { OFC_CTRL_HP_X_EN = 0x01, OFC_CTRL_HP_Y_EN = 0x02, OFC_CTRL_HP_Z_EN = 0x04, OFC_CTRL_CAL_RDY = 0x10, OFC_CTRL_CAL_TRIGGER0 = 0x20, OFC_CTRL_CAL_TRIGGER1 = 0x40, _OFC_CTRL_CAL_TRIGGER_MASK = 3, _OFC_CTRL_CAL_TRIGGER_SHIFT = 5, OFC_CTRL_OFFSET_RESET = 0x80 } |
enum | CAL_TRIGGER_T { CAL_TRIGGER_NONE = 0, CAL_TRIGGER_X = 1, CAL_TRIGGER_Y = 2, CAL_TRIGGER_Z = 3 } |
enum | OFC_SETTING_BITS_T { OFC_SETTING_CUT_OFF = 0x01, OFC_SETTING_OFFSET_TARGET_X0 = 0x02, OFC_SETTING_OFFSET_TARGET_X1 = 0x04, _OFC_SETTING_OFFSET_TARGET_X_MASK = 3, _OFC_SETTING_OFFSET_TARGET_X_SHIFT = 1, OFC_SETTING_OFFSET_TARGET_Y0 = 0x08, OFC_SETTING_OFFSET_TARGET_Y1 = 0x10, _OFC_SETTING_OFFSET_TARGET_Y_MASK = 3, _OFC_SETTING_OFFSET_TARGET_Y_SHIFT = 3, OFC_SETTING_OFFSET_TARGET_Z0 = 0x20, OFC_SETTING_OFFSET_TARGET_Z1 = 0x40, _OFC_SETTING_OFFSET_TARGET_Z_MASK = 3, _OFC_SETTING_OFFSET_TARGET_Z_SHIFT = 5 } |
enum | OFFSET_TARGET_T { OFFSET_TARGET_0G = 0, OFFSET_TARGET_PLUS_1G = 1, OFFSET_TARGET_MINUS_1G = 2 } |
enum | FIFO_CONFIG_1_BITS_T { FIFO_CONFIG_1_FIFO_DATA_SEL0 = 0x01, FIFO_CONFIG_1_FIFO_DATA_SEL1 = 0x02, _FIFO_CONFIG_1_FIFO_DATA_SEL = 3, _FIFO_CONFIG_1_FIFO_DATA_SHIFT = 0, FIFO_CONFIG_1_FIFO_MODE0 = 0x40, FIFO_CONFIG_1_FIFO_MODE1 = 0x80, _FIFO_CONFIG_1_FIFO_MODE_MASK = 3, _FIFO_CONFIG_1_FIFO_MODE_SHIFT = 5 } |
enum | FIFO_DATA_SEL_T { FIFO_DATA_SEL_XYZ = 0, FIFO_DATA_SEL_X = 1, FIFO_DATA_SEL_Y = 2, FIFO_DATA_SEL_Z = 3 } |
enum | FIFO_MODE_T { FIFO_MODE_BYPASS = 0, FIFO_MODE_FIFO = 1, FIFO_MODE_STREAM = 2 } |
enum | INTERRUPT_PINS_T { INTERRUPT_INT1, INTERRUPT_INT2 } |
enum | RESOLUTION_T { RESOLUTION_10BITS, RESOLUTION_12BITS } |
Public Member Functions | |
BMA250E (int bus=BMA250E_I2C_BUS, int addr=BMA250E_DEFAULT_ADDR, int cs=-1) | |
~BMA250E () | |
void | update () |
uint8_t | getChipID () |
void | getAccelerometer (float *x, float *y, float *z) |
float * | getAccelerometer () |
float | getTemperature (bool fahrenheit=false) |
void | init (POWER_MODE_T pwr=POWER_MODE_NORMAL, RANGE_T range=RANGE_2G, BW_T bw=BW_250) |
void | reset () |
void | setRange (RANGE_T range) |
void | setBandwidth (BW_T bw) |
void | setPowerMode (POWER_MODE_T power) |
void | enableFIFO (bool useFIFO) |
void | fifoSetWatermark (int wm) |
void | fifoConfig (FIFO_MODE_T mode, FIFO_DATA_SEL_T axes) |
void | setSelfTest (bool sign, bool amp, SELFTTEST_AXIS_T axis) |
uint8_t | getInterruptEnable0 () |
void | setInterruptEnable0 (uint8_t bits) |
uint8_t | getInterruptEnable1 () |
void | setInterruptEnable1 (uint8_t bits) |
uint8_t | getInterruptEnable2 () |
void | setInterruptEnable2 (uint8_t bits) |
uint8_t | getInterruptMap0 () |
void | setInterruptMap0 (uint8_t bits) |
uint8_t | getInterruptMap1 () |
void | setInterruptMap1 (uint8_t bits) |
uint8_t | getInterruptMap2 () |
void | setInterruptMap2 (uint8_t bits) |
uint8_t | getInterruptSrc () |
void | setInterruptSrc (uint8_t bits) |
uint8_t | getInterruptOutputControl () |
void | setInterruptOutputControl (uint8_t bits) |
void | clearInterruptLatches () |
RST_LATCH_T | getInterruptLatchBehavior () |
void | setInterruptLatchBehavior (RST_LATCH_T latch) |
uint8_t | getInterruptStatus0 () |
uint8_t | getInterruptStatus1 () |
uint8_t | getInterruptStatus2 () |
uint8_t | getInterruptStatus3Bits () |
ORIENT_T | getInterruptStatus3Orientation () |
void | enableRegisterShadowing (bool shadow) |
void | enableOutputFiltering (bool filter) |
void | setLowPowerMode2 () |
void | installISR (INTERRUPT_PINS_T intr, int gpio, mraa::Edge level, void(*isr)(void *), void *arg) |
void | uninstallISR (INTERRUPT_PINS_T intr) |
uint8_t | readReg (uint8_t reg) |
int | readRegs (uint8_t reg, uint8_t *buffer, int len) |
void | writeReg (uint8_t reg, uint8_t val) |
Static Public Attributes | |
static const uint8_t | BMA250E_RESET_BYTE = 0xb6 |
Protected Member Functions | |
void | csOn () |
void | csOff () |
enum BMA250E_REGS_T : uint8_t |
BMA250E registers
enum ACCD10_LSB_BITS_T |
REG_ACCD_*_LSB bits - handle X, Y, and Z LSB regs, for 10 bit resolution
enum ACCD12_LSB_BITS_T |
REG_ACCD_*_LSB bits - handle X, Y, and Z LSB regs, for 12 bit resolution
enum INT_STATUS_0_BITS_T |
REG_INT_STATUS_0 bits
enum INT_STATUS_1_BITS_T |
REG_INT_STATUS_1 bits
enum INT_STATUS_2_BITS_T |
REG_INT_STATUS_2 bits
enum INT_STATUS_3_BITS_T |
REG_INT_STATUS_3 bits
enum ORIENT_T |
INT_STATUS_3_ORIENT values
enum FIFO_STATUS_BITS_T |
REG_FIFO_STATUS bits
enum PMU_RANGE_BITS_T |
REG_PMU_RANGE bits
enum RANGE_T |
PMU_RANGE (accelerometer g-range) values
enum PMU_BW_BITS_T |
REG_PMU_BW bits
enum BW_T |
PMU_BW (accelerometer filter bandwidth) values
enum PMU_LPW_BITS_T |
REG_PMU_LPW bits
enum SLEEP_DUR_T |
SLEEP_DUR values
enum POWER_MODE_T |
POWER_MODE values
enum LOW_POWER_BITS_T |
REG_PMU_LOW_POWER bits
enum ACC_HBW_BITS_T |
REG_ACC_HBW bits
enum INT_EN_0_BITS_T |
REG_INT_EN_0 bits
enum INT_EN_1_BITS_T |
REG_INT_EN_1 bits
enum INT_EN_2_BITS_T |
REG_INT_EN_2 bits
enum INT_MAP_0_BITS_T |
REG_INT_MAP_0 bits
enum INT_MAP_1_BITS_T |
REG_INT_MAP_1 bits
enum INT_MAP_2_BITS_T |
REG_INT_MAP_2 bits
enum INT_SRC_BITS_T |
REG_INT_SRC bits
enum INT_OUT_CTRL_BITS_T |
REG_INT_OUT_CTRL bits
enum INT_RST_LATCH_BITS_T |
REG_INT_RST_LATCH bits
enum RST_LATCH_T |
RST_LATCH values
enum INT_2_BITS_T |
REG_INT_2 bits
enum INT_5_BITS_T |
REG_INT_5 bits
enum INT_8_BITS_T |
REG_INT_8 bits
enum INT_9_BITS_T |
REG_INT_9 bits
enum INT_A_BITS_T |
REG_INT_A bits
enum ORIENT_MODE_T |
INT_A_ORIENT_MODE values
enum ORIENT_BLOCKING_T |
INT_A_ORIENT_BLOCKING values
enum INT_B_BITS_T |
REG_INT_B bits
enum INT_C_BITS_T |
REG_INT_C bits
enum INT_D_BITS_T |
REG_INT_D bits
enum FIFO_CONFIG_0_BITS_T |
REG_FIFO_CONFIG_0 bits
enum PMU_SELFTTEST_BITS_T |
REG_PMU_SELFTTEST bits
enum SELFTTEST_AXIS_T |
PMU_SELFTTEST_AXIS values
enum TRIM_NVM_CTRL_BITS_T |
REG_TRIM_NVM_CTRL bits
enum SPI3_WDT_BITS_T |
REG_SPI3_WDT bits
enum OFC_CTRL_BITS_T |
REG_OFC_CTRL bits
enum CAL_TRIGGER_T |
OFC_CTRL_CAL_TRIGGER values
enum OFC_SETTING_BITS_T |
REG_OFC_SETTING bits
enum OFFSET_TARGET_T |
OFC_SETTING_OFFSET_TARGET (for X, Y and Z axis) values
enum FIFO_CONFIG_1_BITS_T |
REG_FIFO_CONFIG_1 bits
enum FIFO_DATA_SEL_T |
FIFO_DATA_SEL values
enum FIFO_MODE_T |
FIFO_MODE values
BMA250E | ( | int | bus = BMA250E_I2C_BUS , |
int | addr = BMA250E_DEFAULT_ADDR , |
||
int | cs = -1 |
||
) |
BMA250E constructor.
This device can support both I2C and SPI. For SPI, set the addr to -1, and specify a positive integer representing the Chip Select (CS) pin for the cs argument. If you are using a hardware CS pin (like edison with arduino breakout), then you can connect the proper pin to the hardware CS pin on your MCU and supply -1 for cs. The default operating mode is I2C.
bus | I2C or SPI bus to use. |
addr | The address for this device. -1 for SPI. |
cs | The gpio pin to use for the SPI Chip Select. -1 for I2C or for SPI with a hardware controlled pin. |
void update | ( | void | ) |
Update the internal stored values from sensor data.
uint8_t getChipID | ( | ) |
Return the chip ID.
void getAccelerometer | ( | float * | x, |
float * | y, | ||
float * | z | ||
) |
Return accelerometer data in gravities. update() must have been called prior to calling this method.
x | Pointer to a floating point value that will have the current x component placed into it. |
y | Pointer to a floating point value that will have the current y component placed into it. |
z | Pointer to a floating point value that will have the current z component placed into it. |
float * getAccelerometer | ( | ) |
Return accelerometer data in gravities in the form of a floating point array. The pointer returned by this function is statically allocated and will be rewritten on each call. update() must have been called prior to calling this method.
float getTemperature | ( | bool | fahrenheit = false | ) |
Return the current measured temperature. Note, this is not ambient temperature. update() must have been called prior to calling this method.
fahrenheit | true to return data in Fahrenheit, false for Celicus. Celsius is the default. |
void init | ( | POWER_MODE_T | pwr = POWER_MODE_NORMAL , |
RANGE_T | range = RANGE_2G , |
||
BW_T | bw = BW_250 |
||
) |
Initialize the device and start operation. This function is called from the constructor so will not typically need to be called by a user unless the device is reset.
pwr | One of the POWER_MODE_T values. The default is POWER_MODE_NORMAL. |
range | One of the RANGE_T values. The default is RANGE_2G. |
bw | One of the filtering BW_T values. The default is BW_250. |
void reset | ( | ) |
void setRange | ( | RANGE_T | range | ) |
Set the acceleration scaling range. This device supports 2, 4, 8, and 16g ranges.
range | One of the RANGE_T values. |
void setBandwidth | ( | BW_T | bw | ) |
Set the output filtering bandwidth of the device.
bw | One of the BW_T values. |
void setPowerMode | ( | POWER_MODE_T | power | ) |
Set the power mode of the device. Care must be taken when setting a low power or suspend mode. By default init() calls setLowPowerMode2() to ensure that if any of these modes are entered we can still talk to the device. The default low power mode is LPM1, which requires slowing down register writes, which we cannot support. setLowPowerMode2() enables LPM2 which keeps the digital interface operational in low power or suspend modes. See the datasheet for details.
So if you reset your device and don't call init() or setLowPowerMode2(), you could lose control of the device by calling this function with anything other than POWER_MODE_NORMAL. You've been warned :)
power | One of the POWER_MODE_T values. |
void enableFIFO | ( | bool | useFIFO | ) |
Enable update() to read from the FIFO rather than the acceleration axis registers directly. init() enables this mode by default if the chip variant supports a FIFO. An advantage to this mode that all axis data is sampled from the same timeslice. When reading directly from the acceleration output registers, it's possible for one axis to be updated while another is being read, causing a temporal anomaly that even Captain Picard can't resolve. If there is no FIFO present, this call is ignored.
Using the FIFO removes this problem.
useFIFO | true to enable update() to read from the FIFO. When false, update will read from the acceleration output registers directly. |
void fifoSetWatermark | ( | int | wm | ) |
Set the FIFO watermark. When the watermark is reached an interrupt (if enabled) will be generated. If there is no FIFO present, this call is ignored.
wm | The FIFO watermark to use. The maximum value is 63. |
void fifoConfig | ( | FIFO_MODE_T | mode, |
FIFO_DATA_SEL_T | axes | ||
) |
Set the FIFO configuration. init() uses the FIFO_MODE_BYPASS mode with axes set to FIFO_DATA_SEL_XYZ by default. If there is no FIFO present, this call is ignored.
mode | One of the FIFO_MODE_T values. |
axes | One of the FIFO_DATA_SEL_T values. |
void setSelfTest | ( | bool | sign, |
bool | amp, | ||
SELFTTEST_AXIS_T | axis | ||
) |
Enable, disable, and configure the built in self test on a per axis basis. See the datasheet for details.
sign | true for a positive deflection, false for negative |
amp | true for a high deflection, false for a low deflection |
axis | One of the SELFTTEST_AXIS_T values. Note, only one axis at a time can be tested. Accelerometer output for other axes should be ignored. |
uint8_t getInterruptEnable0 | ( | ) |
Return the Interrupt Enables 0 register. These resgisters allow you to enable various interrupt conditions. See the datasheet for details.
void setInterruptEnable0 | ( | uint8_t | bits | ) |
Set the Interrupt Enables 0 register. See the datasheet for details.
bits | A bitmask of INT_EN_0_BITS_T bits. |
uint8_t getInterruptEnable1 | ( | ) |
Return the Interrupt Enables 1 register. See the datasheet for details.
void setInterruptEnable1 | ( | uint8_t | bits | ) |
Set the Interrupt Enables 1 register. See the datasheet for details.
bits | A bitmask of INT_EN_1_BITS_T bits. |
uint8_t getInterruptEnable2 | ( | ) |
Return the Interrupt Enables 2 register. See the datasheet for details.
void setInterruptEnable2 | ( | uint8_t | bits | ) |
Set the Interrupt Enables 2 register. See the datasheet for details.
bits | A bitmask of INT_EN_2_BITS_T bits. |
uint8_t getInterruptMap0 | ( | ) |
Return the Interrupt Map 0 register. These registers allow you to map specific interrupts to the interrupt 1 or interrupt 2 pin. See the datasheet for details.
void setInterruptMap0 | ( | uint8_t | bits | ) |
Set the Interrupt Map 0 register. These registers allow you to map specific interrupts to the interrupt 1 or interrupt 2 pin. See the datasheet for details.
A | bitmask of INT_MAP_0_BITS_T bits. |
uint8_t getInterruptMap1 | ( | ) |
Return the Interrupt Map 1 register. See the datasheet for details.
void setInterruptMap1 | ( | uint8_t | bits | ) |
Set the Interrupt Map 1 register. See the datasheet for details.
A | bitmask of INT_MAP_1_BITS_T bits. |
uint8_t getInterruptMap2 | ( | ) |
Return the Interrupt Map 2 register. See the datasheet for details.
void setInterruptMap2 | ( | uint8_t | bits | ) |
Set the Interrupt Map 2 register. See the datasheet for details.
A | bitmask of INT_MAP_2_BITS_T bits. |
uint8_t getInterruptSrc | ( | ) |
Return the Interrupt source register. This register allows determining where data comes from (filtered/unfiltered) for those interrupt sources where this is selectable. See the datasheet for details.
void setInterruptSrc | ( | uint8_t | bits | ) |
Set the Interrupt source register. This register allows determining where data comes from (filtered/unfiltered) for those interrupt sources where this is selectable. See the datasheet for details.
bits | A bitmask of INT_SRC_BITS_T bits. |
uint8_t getInterruptOutputControl | ( | ) |
Return the Interrupt output control register. This register allows determining the electrical characteristics of the 2 interrupt pins (open-drain/push-pull and level/edge triggering). See the datasheet for details.
void setInterruptOutputControl | ( | uint8_t | bits | ) |
Set the Interrupt output control register. This register allows determining the electrical characteristics of the 2 interrupt pins (open-drain/push-pull and level/edge triggering). See the datasheet for details.
bits | A bitmask of INT_OUT_CTRL_BITS_T bits. |
void clearInterruptLatches | ( | ) |
Clear all latched interrupts. See the datasheet for details.
BMA250E::RST_LATCH_T getInterruptLatchBehavior | ( | ) |
Return the current interrupt latching behavior. See the datasheet for details.
void setInterruptLatchBehavior | ( | RST_LATCH_T | latch | ) |
Set the current interrupt latching behavior. See the datasheet for details.
latch | One of the RST_LATCH_T values. |
uint8_t getInterruptStatus0 | ( | ) |
Return the interrupt status 0 register. These registers indicate which interrupts have been triggered. See the datasheet for details.
uint8_t getInterruptStatus1 | ( | ) |
Return the interrupt status 1 register. See the datasheet for details.
uint8_t getInterruptStatus2 | ( | ) |
Return the interrupt status 2 register. See the datasheet for details.
uint8_t getInterruptStatus3Bits | ( | ) |
Return the interrupt status 3 register bitfields. See the datasheet for details. The Orientation value is not returned by this function, see getInterruptStatus3Orientation() for that information.
BMA250E::ORIENT_T getInterruptStatus3Orientation | ( | ) |
Return the interrupt status 3 register Orientation value. See the datasheet for details.
void enableRegisterShadowing | ( | bool | shadow | ) |
Enable shadowing of the accelerometer output registers. When enabled, a read of an axis LSB register automatically locks the MSB register of that axis until it has been read. This is usually a good thing to have enabled. init() enables this by default. If disabled, then it becomes possible for part of an axis value to change while another part is being read, causing inconsistent data.
shadow | true to enable axis register shadowing, false otherwise. |
void enableOutputFiltering | ( | bool | filter | ) |
Enable filtering of the accelerometer axis data. init() enables this by default. If disabled, then accelerometer data that is read will be raw and unfiltered (rated R). See the datasheet for details.
filter | true to enable filtering, false to disable. |
void setLowPowerMode2 | ( | ) |
Make sure low power mode config (LPM2) is set in case we later go into the low power or suspend power modes. LPM1 mode (the default) requires drastically slowed register writes which we cannot handle.
void installISR | ( | INTERRUPT_PINS_T | intr, |
int | gpio, | ||
mraa::Edge | level, | ||
void(*)(void *) | isr, | ||
void * | arg | ||
) |
install an interrupt handler.
intr | one of the INTERRUPT_PINS_T values specifying which interrupt pin you are installing. |
gpio | gpio pin to use as interrupt pin |
level | the interrupt trigger level (one of mraa::Edge values). Make sure that you have configured the interrupt pin properly for whatever level you choose. |
isr | the interrupt handler, accepting a void * argument |
arg | the argument to pass the the interrupt handler |
void uninstallISR | ( | INTERRUPT_PINS_T | intr | ) |
uninstall a previously installed interrupt handler
intr | one of the INTERRUPT_PINS_T values specifying which interrupt pin you are removing. |
uint8_t readReg | ( | uint8_t | reg | ) |
Read a register.
reg | The register to read. |
int readRegs | ( | uint8_t | reg, |
uint8_t * | buffer, | ||
int | len | ||
) |
Read contiguous registers into a buffer.
buffer | The buffer to store the results. |
len | The number of registers to read. |
void writeReg | ( | uint8_t | reg, |
uint8_t | val | ||
) |
Write to a register
reg | The register to write to. |
val | The value to write. |