Generic library for configuring the register
Fork of MMA8451Q8b by
Diff: MMA8451Q8.cpp
- Revision:
- 9:acccb8faf90c
- Parent:
- 8:993bb9e96a4b
diff -r 993bb9e96a4b -r acccb8faf90c MMA8451Q8.cpp --- a/MMA8451Q8.cpp Tue Feb 03 17:59:00 2015 +0000 +++ b/MMA8451Q8.cpp Mon Feb 09 04:41:57 2015 +0000 @@ -67,6 +67,7 @@ data[DATA_INDEX] = 0x01; writeRegs(data, 2); // make active } + // add Puse configuratioin register access // Also add function prototype to .h file void MMA8451Q::setPulseConfiguration(uint8_t latch,uint8_t axisSet) { @@ -82,6 +83,19 @@ data[DATA_INDEX] = 0x01; writeRegs(data, 2); // make active } + +//Generic register set mode for those needing to be put in standby to update +void MMA8451Q::setRegisterInStandby(uint8_t regAddress, uint8_t regData) { + uint8_t data[NUM_DATA] = {REG_CTRL_REG_1, 0x00}; + writeRegs(data, NUM_DATA); // put in standby + data[ADDRESS_INDEX ] = regAddress; + data[DATA_INDEX] = regData; + 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]); }