Utilities for BORCH accelerometer BMA250E
Dependents: MtConnect04S_Bike_Proximity Mt05_MtSense03
Revision 1:b6bb47e17a9a, committed 2018-04-27
- Comitter:
- johnathanlyu
- Date:
- Fri Apr 27 09:54:54 2018 +0000
- Parent:
- 0:8273e9b80c39
- Commit message:
- update library flow
Changed in this revision
BMA250E.cpp | Show annotated file Show diff for this revision Revisions of this file |
BMA250E.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8273e9b80c39 -r b6bb47e17a9a BMA250E.cpp --- a/BMA250E.cpp Mon Dec 19 06:07:10 2016 +0000 +++ b/BMA250E.cpp Fri Apr 27 09:54:54 2018 +0000 @@ -20,21 +20,23 @@ /******************************* * Public methods *******************************/ -BMA250E::BMA250E(PinName i2c_sda, PinName i2c_scl, PinName interrupt1_pinname, PinName interrupt2_pinname) +BMA250E::BMA250E(PinName i2c_sda, PinName i2c_scl, PinName interrupt1_pinname, PinName interrupt2_pinname,uint8_t range, uint8_t bandwith) : i2c_(i2c_sda, i2c_scl), interrupt1_pinname_(interrupt1_pinname), interrupt1_(interrupt1_pinname), interrupt2_pinname_(interrupt2_pinname), - interrupt2_(interrupt2_pinname) { + interrupt2_(interrupt2_pinname), + range_(range), bandwith_(bandwith) { + /* Basic */ - RegWrite(0x14, 0xB6); // softreset - RegWrite(0x0F, 0x03); // range((+/-)2G) - RegWrite(0x10, 0x0C); // bandwidth(125Hz) + RegWrite(0x14, 0xB6); // softreset + RegWrite(0x0F, range_); // range + RegWrite(0x10, bandwith_); // bandwidth /* Interrupt */ RegWrite(0x16, 0x00); // Disable all interrupts RegWrite(0x17, 0x00); // - RegWrite(0x20, 0x00); // int1_od(PP), int1_lvl(Low active), int2_od(PP), int2_lvl(Low active) + RegWrite(0x20, 0x00); // int1_od(PP), int1_lvl(Low active), int2_od(PP), int2a_lvl(Low active) RegWrite(0x21, 0x80); // reset_int, latch_int(non_latched) } @@ -51,6 +53,7 @@ xyz[0] >>= 6; xyz[1] >>= 6; xyz[2] >>= 6; + } void BMA250E::NewData(void(*fptr)(void)) { @@ -152,4 +155,4 @@ RegRead (reg, &val, 1); // Read val = (val & ~clr_mask) | set_mask; // Modify RegWrite(reg, val); // Write -} +} \ No newline at end of file
diff -r 8273e9b80c39 -r b6bb47e17a9a BMA250E.h --- a/BMA250E.h Mon Dec 19 06:07:10 2016 +0000 +++ b/BMA250E.h Fri Apr 27 09:54:54 2018 +0000 @@ -24,7 +24,7 @@ class BMA250E { public: - BMA250E(PinName i2c_sda, PinName i2c_scl, PinName int1 = NC, PinName int2 = NC); + BMA250E(PinName i2c_sda, PinName i2c_scl, PinName int1 = NC, PinName int2 = NC, uint8_t range = 0x03, uint8_t bandwith =0x0C); void ReadXYZ(int16_t *xyz); @@ -45,6 +45,8 @@ InterruptIn interrupt1_; PinName interrupt2_pinname_; InterruptIn interrupt2_; + uint8_t range_; + uint8_t bandwith_; void RegWrite(char reg, char val); void RegRead (char reg, char *val, int len);