Updated OCE 360 Assignment 4
Dependents: Barros_Assignment4
Diff: MMA8452Q.cpp
- Revision:
- 2:1d10bcf263d2
- Parent:
- 0:098406435cd2
diff -r e70270d1025e -r 1d10bcf263d2 MMA8452Q.cpp --- a/MMA8452Q.cpp Fri Nov 17 04:09:39 2017 +0000 +++ b/MMA8452Q.cpp Thu Dec 07 23:20:41 2017 +0000 @@ -73,6 +73,20 @@ writeRegister(REG_CTRL_REG1, c); // Write back to CONTROL register } +// Set accelerometer into standby mode +void MMA8452Q::standby1() +{ + uint8_t k = readRegister(REG_FF_MT_CFG); + k &= ~(0x07); + writeRegister(REG_FF_MT_CFG, k); +} +void MMA8452Q::active1() +{ + uint8_t k = readRegister(REG_FF_MT_CFG); + k |= ~0x07; + writeRegister(REG_FF_MT_CFG, k); +} + // Read X registers float MMA8452Q::readX() { @@ -172,4 +186,6 @@ // Write the data to the register m_i2c.write(data); m_i2c.stop(); -} \ No newline at end of file +} + + //IIC_RegWrite(0x15, 0xB8); //Enable Latch, Freefall, X-axis, Y-axis and Z-axis