library mma8452

Dependents:   APP3_Capteur_V2

Fork of MMA8452 by Ashley Mills

Revision:
16:d6dde2318edc
Parent:
14:0602b45ca70f
Child:
17:6e4232c421c0
--- a/MMA8452.cpp	Wed Mar 05 15:36:03 2014 +0000
+++ b/MMA8452.cpp	Wed Mar 05 16:47:13 2014 +0000
@@ -121,14 +121,31 @@
    );
 }
 
-int MMA8452::isXYZReady() {
+char MMA8452::getMaskedRegister(int reg, char mask) {
    char rval = 0;
-   if(readRegister(MMA8452_STATUS,&rval)) {
+   if(readRegister(reg,&rval)) {
       return 0;
    }
-   return (rval&MMA8452_STATUS_ZYXDR_MASK);
+   return (rval&mask);
+}
+
+int MMA8452::isXYZReady() {
+   return getMaskedRegister(MMA8452_STATUS,MMA8452_STATUS_ZYXDR_MASK)>0;
+}
+
+int MMA8452::isXReady() {
+   return getMaskedRegister(MMA8452_STATUS,MMA8452_STATUS_XDR_MASK)>0;
 }
- 
+
+int MMA8452::isYReady() {
+   return getMaskedRegister(MMA8452_STATUS,MMA8452_STATUS_YDR_MASK)>0;
+}
+
+int MMA8452::isZReady() {
+   return getMaskedRegister(MMA8452_STATUS,MMA8452_STATUS_ZDR_MASK)>0;
+}
+
+
 int MMA8452::getDeviceID(char *dst) {
    return readRegister(MMA8452_WHO_AM_I,dst);
 }