Generic library for configuring the register

Fork of MMA8451Q8b by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
vbharam
Date:
Mon Feb 09 04:41:57 2015 +0000
Parent:
8:993bb9e96a4b
Commit message:
Single Tap

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
--- 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]);
 }
--- a/MMA8451Q8.h	Tue Feb 03 17:59:00 2015 +0000
+++ b/MMA8451Q8.h	Mon Feb 09 04:41:57 2015 +0000
@@ -112,6 +112,7 @@
   void setGLimit(int gSelect); 
   // added in .cpp file for tap configuration
   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);