Use accelerometer to interrupt.

Dependencies:   mbed SDFileSystem

Fork of shomberg_hw_7 by Russell Shomberg

Revision:
28:a59485b1626b
Parent:
23:61d87ea09c26
Child:
29:d33071ffaa5f
--- a/MMA8452Q.cpp	Thu Nov 15 15:08:42 2018 +0000
+++ b/MMA8452Q.cpp	Fri Nov 16 19:53:25 2018 +0000
@@ -12,7 +12,7 @@
 MMA8452Q::MMA8452Q(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr)
 {
     // Initialize members
-    scale = DEFAULT_FSR;
+    scale = DEFAULT_FSR; // is this necessary
 }
 
 // Destructor
@@ -34,6 +34,7 @@
     standby();
     setScale(DEFAULT_FSR);
     setODR(DEFAULT_ODR);
+    setInterrupt();
     active();
 
     return true;
@@ -182,13 +183,11 @@
 void MMA8452Q::setInterrupt()
 {
     // write all registers associated with interrupt
-    //REG_TRANSIENT_CFG
-    //REG_TRANSIENT_SRC
-    writeRegister(REG_CTRL_REG4, 0x20); // turn on transient flag
-    writeRegister(REG_CTRL_REG5, 0x20); // route transient interrupt to pin1
-    writeRegister(REG_TRANSIENT_CFG, 0x1E); // detection turned on for x,y,z and reading source clears flag
-    // writeRegister(REG_TRANSIENT_THS, ); //
-    // writeRegister(REG_TRANSIENT_COUNT, ); //
+    writeRegister( REG_CTRL_REG4, 0x20 ); // turn on transient flag
+    writeRegister( REG_CTRL_REG5, 0x20 ); // route transient interrupt to pin1
+    writeRegister( REG_TRANSIENT_CFG, 0x1E ); // detection turned on for x,y,z and reading source clears flag
+    //writeRegister( REG_TRANSIENT_THS,  ); //
+    //writeRegister( REG_TRANSIENT_COUNT,  ); //
 
 }