Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Revision:
23:ccf39298f205
Parent:
22:f957c4f840ad
Child:
25:57b2627fe756
--- a/main.cpp	Tue Oct 16 04:47:44 2012 +0000
+++ b/main.cpp	Tue Oct 23 20:07:57 2012 +0000
@@ -166,7 +166,7 @@
 static uint32_t       gNcommWinChecks   = 0;
 // heartbeat
 static time_t         gLastHrtbt        = 0;
-static bool           gHrtbtFired       = false;
+static volatile bool  gHrtbtFired       = false;
 static uint32_t       gHrtbtNum         = 0;
 // rates
 static double         gThmDtSum         = 0; // sum of all time diffs between thermal trigs
@@ -188,7 +188,7 @@
 #endif
         gEvent.SetTrgBit(kFrcTrg);
         gEvent.SetTrgNum(++(gTrgNum[kFrcTrg]));
-        PIN_forceTrigger = 0;
+        //PIN_forceTrigger = 0;
         PIN_forceTrigger = 1;     // force a trigger
         PIN_forceTrigger = 0;
 #ifdef DEBUG
@@ -205,7 +205,7 @@
 #ifdef DEBUG
         printf("proc heartbeat\r\n");
 #endif
-        PIN_heartbeat = 0;
+        //PIN_heartbeat = 0;
         PIN_heartbeat = 1; // heartbeat pulse
         PIN_heartbeat = 0;
         gLastHrtbt    = time(0);
@@ -507,7 +507,7 @@
         led3=0; led4=1; wait(0.2);
         led4=0;
     }
-
+        
 #ifdef DEBUG
     printf("initializing SD card..\r\n");
 #endif
@@ -528,8 +528,8 @@
     gComms[0] = new SnCommAfarNetIf(gConf);
 #endif
     */
-    //gComms[0] = new SnCommSBD(&gSBDport, &gCpu);
-    gComms[0] = new SnCommUsb(&gCpu);
+    gComms[0] = new SnCommSBD(&gSBDport, &gCpu);
+    //gComms[0] = new SnCommUsb(&gCpu);
 
 #ifdef DEBUG
     printf("make comm objects\r\n");
@@ -602,12 +602,6 @@
         WaitTrigAndSendClock();
         PIN_lockRegisters = 1; // block registers during readout
         
-        
-        if (gHrtbtFired) {
-            SaveHeartbeat();
-            gHrtbtFired=false;
-        }
-        
 #ifdef EVT_TIME_PROFILE
         Timer prof;
         prof.start();
@@ -691,6 +685,11 @@
         printf("past reading out\r\n");
 #endif
         
+        if (gHrtbtFired) {
+            SaveHeartbeat();
+            gHrtbtFired=false;
+        }
+
         led4=0; led2=0;
                 
 #ifdef EVT_TIME_PROFILE
@@ -1135,7 +1134,7 @@
                       procCommWin();
 */
         
-        //wait_us(6);
+        //wait_us(5);
         
         //
         // collect data from daughter cards