Versão limpa em 04/09/2014. Telnet funcionando.

Dependencies:   EthernetInterface mbed-rtos mbed NTPClient

Revision:
38:132e83a591d0
Parent:
33:3abe9d906312
Child:
41:a413c26109c2
Child:
42:d6f9ce115eaf
--- a/main.cpp	Thu Jul 30 21:42:06 2015 +0000
+++ b/main.cpp	Thu Jan 07 18:44:44 2016 +0000
@@ -37,8 +37,13 @@
 
 #include "NTPClient.h"
 
+#include "whatchdog.h"
+
+
+
 //__attribute((section("AHBSRAM0"),aligned)) char LargeBuffer[1024]; 
 EthernetInterface eth;
+Watchdog wdt;
 
 void thread1(void const *args)
 {
@@ -129,13 +134,22 @@
     eth.connect();
     //printf("IP Address is %s\n", EthernetIf::get_IpAddress());
     printf("IP Address is NEW %s\n", eth.getIPAddress());
-
 }
 
 int main() {
-    PmedLog::WriteEntry(PMEDLOG_INITIALIZING);
+    //DigitalOut myled3(LED3); //The pushbutton or power on caused a reset
+    //DigitalOut myled4(LED4); //The watchdog timer caused a reset
+    
+    if ((LPC_WDT->WDMOD >> 2) & 1){
+        //myled4 = 1; 
+        PmedLog::WriteEntry(PMEDLOG_INITIALIZINGWDT);
+    }
+    else{        
+        //myled3 = 1;
+        PmedLog::WriteEntry(PMEDLOG_INITIALIZING);
+    }
 
-    printf("\r\nNova versao 60 ( 20150327.1 )...\r\n");
+    printf("\r\nNova versao 70 ( 20151028.1 )... Com WhatchDog\r\n");
     FILE *f;
     //Set Highest Priority
     //osThreadSetPriority(osThreadGetId(),osPriorityHigh);
@@ -179,15 +193,56 @@
         printf("SEN%d = %f, COS%d = %f\n",i,sen[i],i,cos[i]);
     }
     */
-    printf("Protegemed Limpo teste ( with logs ) \n\n");
+    printf(PMEDLOG_INITIALIZINGWDT);
+    printf("\n\n");
     
     //printf("0x%lx\n",  LargeBuffer);
     
     PmedLog::WriteEntry(PMEDLOG_STARTED);
     
+    /* Teste com WhatchDog
     //Jump to the capture routine(will run on this thread)  
     thread1(NULL);
-   
+    */
+    
+    /* start test WahtchDog */
+    DigitalOut led1(LED1);
+    int n = 0;
+    //int tatual, tnovo;
+    float rms[NUMBER_OF_CHANNELS], mv2[NUMBER_OF_CHANNELS];
+    int under[NUMBER_OF_CHANNELS], over[NUMBER_OF_CHANNELS];
+    
+    wdt.kick(10.0);  
+    
+    Capture::Initialize();
+       
+    while(1)
+    {
+        Capture::Wait();
+        
+        // Calcula o RMS dos 6 canais
+        SignalProcessor::CalculateRMSBulk(rms, mv2, under, over);
+                
+        for(int i=0;i<6;i++){
+            EventDetector::get_Detector(i).ProcessEvent(rms[i], mv2[i], under[i], over[i]);
+        }
+
+        n++;
+        if(n==60)
+        {
+            printf("%.2f %.0f %.2f %.0f\t%.2f %.0f %.2f %.0f\t%.2f %.0f %.2f %.0f\n",rms[0], mv2[0],rms[1],mv2[1],rms[2],mv2[2],rms[3],mv2[3],rms[4],mv2[4],rms[5],mv2[5]);
+            led1 = !led1;            
+            n=0;    
+            
+            PmedLog::Mark();            
+        }
+        
+        // End of main loop so "kick" to reset watchdog timer and avoid a reset
+        wdt.kick();
+        
+    }    
+    /* end test WahtchDog */
+    
     while(1){//never reaches here  
         PmedLog::WriteEntry(PMEDLOG_WRONGCODE);
         printf("Reset\n");