Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Barros_Assignment4
Revision 2:1d10bcf263d2, committed 2017-12-07
- Comitter:
- Kaitlyn_Barros
- Date:
- Thu Dec 07 23:20:41 2017 +0000
- Parent:
- 1:e70270d1025e
- Commit message:
- Assignment 6. Attempt to employ free fall register.
Changed in this revision
| MMA8452Q.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MMA8452Q.h | Show annotated file Show diff for this revision Revisions of this file |
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
diff -r e70270d1025e -r 1d10bcf263d2 MMA8452Q.h
--- a/MMA8452Q.h Fri Nov 17 04:09:39 2017 +0000
+++ b/MMA8452Q.h Thu Dec 07 23:20:41 2017 +0000
@@ -17,6 +17,7 @@
#define REG_WHO_AM_I 0x0D
#define REG_XYZ_DATA_CFG 0x0E
#define REG_CTRL_REG1 0x2A
+#define REG_FF_MT_CFG 0x15
// WHO_AM_I check
#define FACTORY_ID 0x2A
@@ -53,6 +54,8 @@
void setODR(uint8_t odr);
void standby();
void active();
+ void standby1();
+ void active1();
float readX();
float readY();
float readZ();
