Class module for MPL3115A2 I2C Barometric Sensor

Dependents:   mDotEVBM2X MTDOT-EVBDemo-DRH MTDOT-BOX-EVB-Factory-Firmware-LIB-108 MTDOT-UDKDemo_Senet ... more

Revision:
4:b612babc2c3b
Parent:
3:c41ffe71300f
Child:
5:8be678fd9e55
--- a/MPL3115A2.cpp	Mon Oct 17 08:41:40 2016 -0500
+++ b/MPL3115A2.cpp	Mon Jul 31 17:34:55 2017 -0500
@@ -57,16 +57,14 @@
     // Reset all registers to POR values
     reg_val[0] = 0x04;
     result = MPL3115A2::writeRegister(CTRL_REG1, reg_val);
-    if (result == 0) {
-        do {
-            // wait for the reset bit to clear. readRegister may error out so we re-try 10 times
-            osDelay(200);
-            reg_val[0] = 0x40;
-            result = MPL3115A2::readRegister(CTRL_REG1,reg_val);
-            reg_val[0] = reg_val[0] & 0x04;
-            i++;
-        } while(((reg_val[0] != 0) || (result != 0)) && (i<=10));
-    }
+    do {
+         // wait for the reset bit to clear. readRegister may error out so we re-try 10 times
+        osDelay(200);
+        reg_val[0] = 0x40;
+        result = MPL3115A2::readRegister(CTRL_REG1,reg_val);
+        reg_val[0] = reg_val[0] & 0x04;
+        i++;
+    } while(((reg_val[0] != 0) || (result != 0)) && (i<=10));
 
     if ((result == 0) && (MPL3115A2::testWhoAmI() == true)) {
 
@@ -83,7 +81,7 @@
     if(result != 0) {
         debug("MPL3115A2:init failed\n\r");
     }
-
+    _i2c->stop();
     return result;
 }