27 #include <mraa/common.hpp>
28 #include <mraa/i2c.hpp>
29 #include <mraa/gpio.hpp>
31 #define BMA220_I2C_BUS 0
32 #define BMA220_DEFAULT_ADDR 0x0a
84 REG_REVISIONID = 0x02,
91 REG_H_HYST_DUR = 0x0a,
93 REG_L_HYST_DUR = 0x0e,
95 REG_TAP_CONFIG = 0x10,
97 REG_SLOPE_CONFIG = 0x12,
98 REG_TAP_CONFIG2 = 0x14,
100 REG_INT_STATUS1 = 0x16,
101 REG_INT_STATUS2 = 0x18,
103 REG_ENABLE_CONFIG = 0x1a,
104 REG_ENABLE_CONFIG2 = 0x1c,
105 REG_ENABLE_CONFIG3 = 0x1e,
107 REG_FILTER_CONFIG = 0x20,
109 REG_SBIST_FSL_CONFIG = 0x22,
113 REG_I2C_WATCHDOG = 0x2e,
124 H_HYST_DUR_HIGH_DUR0 = 0x01,
125 H_HYST_DUR_HIGH_DUR1 = 0x02,
126 H_HYST_DUR_HIGH_DUR2 = 0x04,
127 H_HYST_DUR_HIGH_DUR3 = 0x08,
128 H_HYST_DUR_HIGH_DUR4 = 0x10,
129 H_HYST_DUR_HIGH_DUR5 = 0x20,
130 _H_HYST_DUR_HIGH_DUR_MASK = 63,
131 _H_HYST_DUR_HIGH_DUR_SHIFT = 0,
133 H_HYST_DUR_HIGH_HY1 = 0x40,
134 H_HYST_DUR_HIGH_HY2 = 0x80,
135 _H_HYST_DUR_HIGH_HY_MASK = 3,
136 _H_HYST_DUR_HIGH_HY_SHIFT = 6
143 THRESHOLD_HIGH0 = 0x01,
144 THRESHOLD_HIGH1 = 0x02,
145 THRESHOLD_HIGH2 = 0x04,
146 THRESHOLD_HIGH3 = 0x08,
147 _THRESHOLD_HIGH_MASK = 15,
148 _THRESHOLD_HIGH_SHIFT = 0,
150 THRESHOLD_LOW0 = 0x10,
151 THRESHOLD_LOW1 = 0x20,
152 THRESHOLD_LOW2 = 0x40,
153 THRESHOLD_LOW3 = 0x80,
154 _THRESHOLD_LOW_MASK = 15,
155 _THRESHOLD_LOW_SHIFT = 4
162 L_HYST_DUR_LOW_DUR0 = 0x01,
163 L_HYST_DUR_LOW_DUR1 = 0x02,
164 L_HYST_DUR_LOW_DUR2 = 0x04,
165 L_HYST_DUR_LOW_DUR3 = 0x08,
166 L_HYST_DUR_LOW_DUR4 = 0x10,
167 L_HYST_DUR_LOW_DUR5 = 0x20,
168 _L_HYST_DUR_LOW_DUR_MASK = 63,
169 _L_HYST_DUR_LOW_DUR_SHIFT = 0,
171 L_HYST_DUR_LOW_HY1 = 0x40,
172 L_HYST_DUR_LOW_HY2 = 0x80,
173 _L_HYST_DUR_LOW_HY_MASK = 3,
174 _L_HYST_DUR_LOW_HY_SHIFT = 6
181 TAP_CONFIG_DUR0 = 0x01,
182 TAP_CONFIG_DUR1 = 0x02,
183 TAP_CONFIG_DUR2 = 0x04,
184 _TAP_CONFIG_DUR_MASK = 7,
185 _TAP_CONFIG_DUR_SHIFT = 0,
187 TAP_CONFIG_THRESH0 = 0x08,
188 TAP_CONFIG_THRESH1 = 0x10,
189 TAP_CONFIG_THRESH2 = 0x20,
190 TAP_CONFIG_THRESH3 = 0x40,
191 _TAP_CONFIG_THRESH_MASK = 15,
192 _TAP_CONFIG_THRESH_SHIFT = 3,
194 TAP_CONFIG_FILTER = 0x80
201 SLOPE_CONFIG_DUR0 = 0x01,
202 SLOPE_CONFIG_DUR1 = 0x02,
203 _SLOPE_CONFIG_DUR_MASK = 3,
204 _SLOPE_CONFIG_DUR_SHIFT = 0,
206 SLOPE_CONFIG_THRESH0 = 0x04,
207 SLOPE_CONFIG_THRESH1 = 0x08,
208 SLOPE_CONFIG_THRESH2 = 0x10,
209 SLOPE_CONFIG_THRESH3 = 0x20,
210 _SLOPE_CONFIG_THRESH_MASK = 15,
211 _SLOPE_CONFIG_THRESH_SHIFT = 2,
213 SLOPE_CONFIG_FILTER = 0x40,
214 SLOPE_CONFIG_ORIENT_EX = 0x80
221 TAP_CONFIG2_SAMP0 = 0x01,
222 TAP_CONFIG2_SAMP1 = 0x02,
223 _TAP_CONFIG2_SAMP_MASK = 3,
224 _TAP_CONFIG2_SAMP_SHIFT = 0,
226 TAP_CONFIG2_ORIENT_BLOCK0 = 0x04,
227 TAP_CONFIG2_ORIENT_BLOCK1 = 0x08,
228 _TAP_CONFIG2_ORIENT_BLOCK_MASK = 3,
229 _TAP_CONFIG2_ORIENT_BLOCK_SHIFT = 2,
231 TAP_CONFIG2_TIP_EN = 0x10
251 TAP_ORIENT_BLOCK_0 = 0,
252 TAP_ORIENT_BLOCK_2 = 1,
253 TAP_ORIENT_BLOCK_3 = 2,
254 TAP_ORIENT_BLOCK_4 = 3,
261 INT_STATUS1_SIGN = 0x01,
262 INT_STATUS1_FIRST_Z = 0x02,
263 INT_STATUS1_FIRST_Y = 0x04,
264 INT_STATUS1_FIRST_X = 0x08,
266 INT_STATUS1_ORIENT0 = 0x10,
267 INT_STATUS1_ORIENT1 = 0x20,
268 INT_STATUS1_ORIENT2 = 0x40,
269 _INT_STATUS1_ORIENT_MASK = 7,
270 _INT_STATUS1_ORIENT_SHIFT = 4,
272 INT_STATUS1_ORIENT_INT = 0x80
282 CONFIG_ORI_UP_PORT_UPRIGHT = 0,
283 CONFIG_ORI_UP_PORT_UPSIDE_DOWN = 1,
284 CONFIG_ORI_UP_LAND_LEFT = 2,
285 CONFIG_ORI_UP_LAND_RIGHT = 3,
286 CONFIG_ORI_DN_PORT_UPRIGHT = 4,
287 CONFIG_ORI_DN_PORT_UPSIDE_DOWN = 5,
288 CONFIG_ORI_DN_LAND_LEFT = 6,
289 CONFIG_ORI_DN_LAND_RIGHT = 7
296 INT_STATUS2_SLOPE = 0x01,
297 INT_STATUS2_DATA = 0x02,
298 INT_STATUS2_HIGH = 0x04,
299 INT_STATUS2_LOW = 0x08,
300 INT_STATUS2_TAP = 0x10
309 ENABLE_CONFIG_TT_Z = 0x01,
310 ENABLE_CONFIG_TT_Y = 0x02,
311 ENABLE_CONFIG_TT_X = 0x04,
312 ENABLE_CONFIG_SLOPE_Z = 0x08,
313 ENABLE_CONFIG_SLOPE_Y = 0x10,
314 ENABLE_CONFIG_SLOPE_X = 0x20,
315 ENABLE_CONFIG_ORIENT = 0x40,
316 ENABLE_CONFIG_DATA = 0x80
323 ENABLE_CONFIG2_HIGH_Z = 0x01,
324 ENABLE_CONFIG2_HIGH_Y = 0x02,
325 ENABLE_CONFIG2_HIGH_X = 0x04,
327 ENABLE_CONFIG2_LOW = 0x08,
329 ENABLE_CONFIG2_LAT_INT0 = 0x10,
330 ENABLE_CONFIG2_LAT_INT1 = 0x20,
331 ENABLE_CONFIG2_LAT_INT2 = 0x40,
332 _ENABLE_CONFIG2_LAT_INT_MASK = 7,
333 _ENABLE_CONFIG2_LAT_INT_SHIFT = 4,
335 ENABLE_CONFIG2_RESET_INT = 0x80
344 CONFIG2_LAT_UNLATCH = 0,
345 CONFIG2_LAT_0_25 = 1,
358 ENABLE_CONFIG3_Z_CHAN = 0x01,
359 ENABLE_CONFIG3_Y_CHAN = 0x02,
360 ENABLE_CONFIG3_X_CHAN = 0x04,
362 ENABLE_CONFIG3_SLEEP_DUR0 = 0x08,
363 ENABLE_CONFIG3_SLEEP_DUR1 = 0x10,
364 ENABLE_CONFIG3_SLEEP_DUR2 = 0x20,
365 _ENABLE_CONFIG3_SLEEP_DUR_MASK = 7,
366 _ENABLE_CONFIG3_SLEEP_DUR_SHIFT = 3,
368 ENABLE_CONFIG3_SLEEP_EN = 0x40
394 FILTER_CONFIG_FILTER0 = 0x01,
395 FILTER_CONFIG_FILTER1 = 0x02,
396 FILTER_CONFIG_FILTER2 = 0x04,
397 FILTER_CONFIG_FILTER3 = 0x08,
398 _FILTER_CONFIG_FILTER_MASK = 15,
399 _FILTER_CONFIG_FILTER_SHIFT = 0,
403 FILTER_CONFIG_SERIAL_HIGH_BW = 0x80
412 FILTER_CONFIG_1KHZ = 0,
413 FILTER_CONFIG_500HZ = 1,
414 FILTER_CONFIG_250HZ = 2,
415 FILTER_CONFIG_125HZ = 3,
416 FILTER_CONFIG_64HZ = 4,
417 FILTER_CONFIG_32HZ = 5
424 REG_SBIST_FSL_RANGE0 = 0x01,
425 REG_SBIST_FSL_RANGE1 = 0x02,
426 _REG_SBIST_FSL_RANGE_MASK = 3,
427 _REG_SBIST_FSL_RANGE_SHIFT = 0,
429 REG_SBIST_FSL_SBIST0 = 0x04,
430 REG_SBIST_FSL_SBIST1 = 0x08,
431 _REG_SBIST_FSL_SBIST_MASK = 3,
432 _REG_SBIST_FSL_SBIST_SHIFT = 2,
434 REG_SBIST_FSL_SBIST_SIGN = 0x10
467 I2C_WATCHDOG_SPI3 = 0x01,
469 I2C_WATCHDOG_TO_SEL = 0x02,
470 I2C_WATCHDOG_TO_EN = 0x04
482 BMA220(
int bus=BMA220_I2C_BUS, uint8_t addr=BMA220_DEFAULT_ADDR);
511 bool writeReg(uint8_t reg, uint8_t val);
544 #if defined(SWIGJAVA) || defined(JAVACALLBACK)
579 bool enableAxes(
bool xEn,
bool yEn,
bool zEn);
605 bool sleep(
bool enable);
781 #if defined(SWIGJAVA) || defined(JAVACALLBACK)
782 void installISR(
int gpio, mraa::Edge level, jobject runnable);
795 void (*isr)(
void *),
void *arg);
806 mraa::Gpio *m_gpioIntr;
821 void updateAccelerometer();
823 #if defined(SWIGJAVA) || defined(JAVACALLBACK)
825 void (*isr)(
void *),
void *arg);
uint8_t readReg(uint8_t reg)
Definition: bma220.cxx:97
uint8_t softReset()
Definition: bma220.cxx:239
SBIST_FSL_CONFIG_BITS_T
Definition: bma220.h:423
bool enableTapFilter(bool filt)
Definition: bma220.cxx:371
FILTER_CONFIG_BITS_T
Definition: bma220.h:393
uint8_t getInterruptEnables1()
Definition: bma220.cxx:447
bool setTapDuration(uint8_t dur)
Definition: bma220.cxx:345
uint8_t getInterruptStatus2()
Definition: bma220.cxx:437
bool resetInterrupts()
Definition: bma220.cxx:481
TAP_SAMP_T
Definition: bma220.h:239
THRESHOLD_BITS_T
Definition: bma220.h:142
void getAccelerometer(float *x, float *y, float *z)
Definition: bma220.cxx:158
uint8_t getInterruptEnables2()
Definition: bma220.cxx:465
bool setAccelerometerScale(FSL_RANGE_T scale)
Definition: bma220.cxx:115
L_HYST_DUR_LOW_BITS_T
Definition: bma220.h:161
bool setSleepDuration(SLEEP_DUR_T dur)
Definition: bma220.cxx:256
bool setInterruptEnables1(uint8_t bits)
Definition: bma220.cxx:442
bool setInterruptEnables2(uint8_t bits)
Definition: bma220.cxx:452
bool setSlopeThreshold(uint8_t thresh)
Definition: bma220.cxx:396
bool setLowGThreshold(uint8_t thresh)
Definition: bma220.cxx:267
ENABLE_CONFIG3_BITS_T
Definition: bma220.h:357
SLOPE_CONFIG_BITS_T
Definition: bma220.h:200
void uninstallISR()
Definition: bma220.cxx:521
I2C_WATCHDOG_BITS_T
Definition: bma220.h:466
TAP_CONFIG2_BITS_T
Definition: bma220.h:220
uint8_t getInterruptStatus1()
Definition: bma220.cxx:421
uint8_t getChipRevision()
Definition: bma220.cxx:184
FSL_RANGE_T
Definition: bma220.h:444
bool setHighGThreshold(uint8_t thresh)
Definition: bma220.cxx:280
void update()
Definition: bma220.cxx:73
REG_T
Definition: bma220.h:82
bool enableSlopeFilter(bool filt)
Definition: bma220.cxx:409
uint8_t suspend()
Definition: bma220.cxx:234
CONFIG_ORIENT_T getOrient()
Definition: bma220.cxx:426
TAP_CONFIG_BITS_T
Definition: bma220.h:180
bool setFilterConfig(FILTER_CONFIG_T filter)
Definition: bma220.cxx:189
void installISR(int gpio, mraa::Edge level, void(*isr)(void *), void *arg)
Definition: bma220.cxx:507
SBIST_T
Definition: bma220.h:456
bool enableAxes(bool xEn, bool yEn, bool zEn)
Definition: bma220.cxx:212
ENABLE_CONFIG_BITS_T
Definition: bma220.h:308
INT_STATUS1_BITS_T
Definition: bma220.h:260
CONFIG2_LAT_T
Definition: bma220.h:343
FILTER_CONFIG_T
Definition: bma220.h:411
bool setInterruptLatch(CONFIG2_LAT_T lat)
Definition: bma220.cxx:470
bool writeReg(uint8_t reg, uint8_t val)
Definition: bma220.cxx:102
ENABLE_CONFIG2_BITS_T
Definition: bma220.h:322
bool setHighGDuration(uint8_t dur)
Definition: bma220.cxx:332
bool sleep(bool enable)
Definition: bma220.cxx:244
API for the BMA220 3-axis Accelerometer.
Definition: bma220.h:70
CONFIG_ORIENT_T
Definition: bma220.h:281
H_HYST_DUR_HIGH_BITS_T
Definition: bma220.h:123
bool setSlopeDuration(uint8_t dur)
Definition: bma220.cxx:383
TAP_ORIENT_BLOCK_T
Definition: bma220.h:250
uint8_t getChipID()
Definition: bma220.cxx:179
INT_STATUS2_BITS_T
Definition: bma220.h:295
bool setHighGHysteresis(uint8_t hyst)
Definition: bma220.cxx:319
bool setLowGDuration(uint8_t dur)
Definition: bma220.cxx:306
bool setTapThreshold(uint8_t thresh)
Definition: bma220.cxx:358
SLEEP_DUR_T
Definition: bma220.h:379
BMA220(int bus=BMA220_I2C_BUS, uint8_t addr=BMA220_DEFAULT_ADDR)
Definition: bma220.cxx:37
bool setLowGHysteresis(uint8_t hyst)
Definition: bma220.cxx:293
bool setSerialHighBW(bool high)
Definition: bma220.cxx:200
~BMA220()
Definition: bma220.cxx:68