HW 4.2.1 submission
Fork of MMA8451Q8b by
Revision 9:84011f06d1ea, committed 2015-02-09
- Comitter:
- bomalley
- Date:
- Mon Feb 09 06:57:21 2015 +0000
- Parent:
- 8:993bb9e96a4b
- Commit message:
- HW 4.2.1 submission
Changed in this revision
MMA8451Q8.cpp | Show annotated file Show diff for this revision Revisions of this file |
MMA8451Q8.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 993bb9e96a4b -r 84011f06d1ea MMA8451Q8.cpp --- a/MMA8451Q8.cpp Tue Feb 03 17:59:00 2015 +0000 +++ b/MMA8451Q8.cpp Mon Feb 09 06:57:21 2015 +0000 @@ -82,6 +82,19 @@ data[DATA_INDEX] = 0x01; writeRegs(data, 2); // make active } +void MMA8451Q::setRegisterInStandby(uint8_t regAddress, uint8_t regData) { + uint8_t configBits; + uint8_t data[NUM_DATA] = {REG_CTRL_REG_1, 0x00}; // put in standby mode +// set up configuration bits. + configBits = regData; + writeRegs(data, NUM_DATA); // put in standby + data[ADDRESS_INDEX ] = regAddress; + data[DATA_INDEX] = configBits; + writeRegs(data, NUM_DATA); + data[ADDRESS_INDEX ] = REG_CTRL_REG_1; // put back in active mode + data[DATA_INDEX] = 0x01; + writeRegs(data, 2); // make active +} float MMA8451Q::getAccX() { return (float(getAccAxis(REG_OUT_X_MSB))/gScaling[gChosen]); }
diff -r 993bb9e96a4b -r 84011f06d1ea MMA8451Q8.h --- a/MMA8451Q8.h Tue Feb 03 17:59:00 2015 +0000 +++ b/MMA8451Q8.h Mon Feb 09 06:57:21 2015 +0000 @@ -111,7 +111,8 @@ **/ void setGLimit(int gSelect); // added in .cpp file for tap configuration - void setPulseConfiguration(uint8_t latch,uint8_t axisSet); + void setPulseConfiguration(uint8_t latch, uint8_t axisSet); + void setRegisterInStandby(uint8_t regAddress,uint8_t regData); void readRegs(int addr, uint8_t * data, int len); void writeRegs(uint8_t * data, int len);