Ag demo with soil moisture

Dependencies:   DOGS102 ISL29011 MMA845x MPL3115A2 NCP5623B libmDot mbed-rtos mbed-src

Fork of MTDOT-EVBDemo-DRH by Dave Heitzman

Revision:
7:74c027d0353b
Parent:
6:b62e5106b5bc
Child:
9:daa92715f700
--- a/main.cpp	Mon Aug 24 16:38:59 2015 +0000
+++ b/main.cpp	Mon Aug 24 18:55:25 2015 +0000
@@ -96,6 +96,8 @@
 
 SPI mDotspi(PA_7,PA_6,PA_5);					// mDot external SPI mDot11, mDot4, and mDot18
 
+MPL3115A2* resetBaro(const MPL3115A2* oldBaro);
+
 /* **** replace these values with the proper public or private network settings ****
  * config_network_nameand config_network_pass are for private networks.
  */
@@ -423,7 +425,10 @@
             result = evbAccel->getStatus();
         	failtime--;
         } while ((result & MMA845x::XYZDR) == 0 && failtime > 0);
-		if (failtime==0) {continue; }
+		if (failtime==0) { 		  
+		  evbBaro=resetBaro(evbBaro);
+		  continue; 
+		}
 
         /*
          * Retrieve and print out accelerometer data
@@ -455,7 +460,12 @@
             result = evbBaro->getStatus();
             failtime--;
         } while ((result & MPL3115A2::PTDR) == 0 && failtime > 0 );
-		if (failtime==0) {continue; }
+		if (failtime==0) { 		  
+		  evbBaro=resetBaro(evbBaro);
+		  continue; 
+		}
+
+
         /*
          * Retrieve and print out barometric pressure
          */
@@ -488,7 +498,10 @@
             result = evbBaro->getStatus();
         	failtime--;
         } while ((result & MPL3115A2::PTDR) == 0 && failtime > 0 );
-		if (failtime==0) {continue; }
+		if (failtime==0) { 		  
+		  evbBaro=resetBaro(evbBaro);
+		  continue; 
+		}
 
         /*
          * Retrieve and print out altitude and temperature
@@ -727,3 +740,14 @@
 	return res;
 }
 
+MPL3115A2* resetBaro(const MPL3115A2* oldBaro){
+	delete oldBaro;
+	MPL3115A2* baro = new MPL3115A2(mDoti2c);
+	baro->testWhoAmI();
+
+    printf("Resetting barometer.. %x \n\r", baro->getStatus() );	
+    baro->setParameters(MPL3115A2::DATA_NORMAL, MPL3115A2::DM_BAROMETER, MPL3115A2::OR_16,
+                           MPL3115A2::AT_1);
+    evbBaro->clearMinMaxRegs();
+	return baro;
+}
\ No newline at end of file