Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
63:4820a4460f00
Parent:
62:4b59c1eb429f
Child:
65:2cb3e99ce466
--- a/main.cpp	Thu Nov 27 03:12:32 2014 +0000
+++ b/main.cpp	Fri Nov 28 05:41:42 2014 +0000
@@ -6,7 +6,7 @@
 #include "Watchdog.h"
 Watchdog::SnKickStarter gKickStarter(WDFAILSAFE);
 
-//#define DISABLE_CONFIG_SAFETYNETS
+#define DISABLE_CONFIG_SAFETYNETS
 
 // CHIPBOARD is defined in SnConstants.h
 
@@ -18,7 +18,7 @@
 //#define USE_RTOS // change USE_RTOS in CommConstants and EthernetPower also
 //#define USE_ETH_INTERFACE
 //#define EVT_TIME_PROFILE
-//#define DEBUG
+#define DEBUG
 //#define SSNOTIFY
 #define USE_MODSERIAL
 
@@ -741,10 +741,14 @@
     // initialize the SD card. this should prevent the issue with
     // seq 0 being overwritten upon power up or the SD card first
     // being insterted
-    const int ret = sd.disk_initialize();
+    int ret = sd.disk_initialize();
+    // may need to try a bunch of times to get it to init
+    for (int i=0; i<25 && (ret!=0); ++i) {
+        ret = sd.disk_initialize();
 #ifdef DEBUG
-    printf("called disk_initialize (ret=%d)\r\n",ret);
+        printf("called disk_initialize (ret=%d)\r\n",ret);
 #endif
+    }
     return ret;
 }
 
@@ -752,22 +756,13 @@
     // a failsafe
     //Watchdog::kick(WDFAILSAFE);
 #ifdef DEBUG
-    printf("Restart watchdog with time [%u]\r\n",
-        gConf.GetWatchdogPeriod());
+    printf("Restart watchdog with time [%u] at [%u]\r\n",
+        gConf.GetWatchdogPeriod(), time(0));
 #endif
     Watchdog::kick(gConf.GetWatchdogPeriod());
     
     gCpu.baud(CPUBAUD_SN);
 
-    // check in case we need to go to low power
-    //wait(4); // TODO: the vADCs read high for first ~4-5sec
-    CheckPower(false, false);
-#ifdef DEBUG
-    printf("startup power: cards %d, amps %d, irid %d, afar %d\r\n",
-        PIN_turn_on_system.read(), PIN_turn_on_amps.read(),
-        PIN_iridSbd_power.read(), PIN_afar_power.read());
-#endif
-
     {
 #if defined(SSNOTIFY) || defined(DEBUG)
         printf("\n\n\n\n\nmain: start\r\n");
@@ -790,6 +785,16 @@
     // the function that initializes it, so it can call the fcn later
     SnSDUtils::fgDoInit = &InitSDCard;
     
+    // check in case we need to go to low power
+    //wait(4); // TODO: the vADCs read high for first ~4-5sec
+    CheckPower(false, false);
+#ifdef DEBUG
+    printf("startup power: cards %d, amps %d, irid %d, afar %d\r\n",
+        PIN_turn_on_system.read(), PIN_turn_on_amps.read(),
+        PIN_iridSbd_power.read(), PIN_afar_power.read());
+#endif
+
+
     /*
     // Note: the brownout isn't useful since it sees either 5V or nothing on our board
     // set up the brownout interrupt