Versão limpa em 04/09/2014. Telnet funcionando.
Dependencies: EthernetInterface mbed-rtos mbed NTPClient
Revision 38:132e83a591d0, committed 2016-01-07
- Comitter:
- rebonatto
- Date:
- Thu Jan 07 18:44:44 2016 +0000
- Parent:
- 37:51fed2a3e009
- Child:
- 39:9fd8397cbef9
- Child:
- 41:a413c26109c2
- Commit message:
- Vers?o est?vel com DMA e FFT.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Functions/whatchdog.h Thu Jan 07 18:44:44 2016 +0000 @@ -0,0 +1,19 @@ +// Simon's Watchdog code from +// http://mbed.org/forum/mbed/topic/508/ +class Watchdog { +public: +// Load timeout value in watchdog timer and enable + void kick(float s) { + LPC_WDT->WDCLKSEL = 0x1; // Set CLK src to PCLK + uint32_t clk = SystemCoreClock / 16; // WD has a fixed /4 prescaler, PCLK default is /4 + LPC_WDT->WDTC = s * (float)clk; + LPC_WDT->WDMOD = 0x3; // Enabled and Reset + kick(); + } +// "kick" or "feed" the dog - reset the watchdog timer +// by writing this required bit pattern + void kick() { + LPC_WDT->WDFEED = 0xAA; + LPC_WDT->WDFEED = 0x55; + } +}; \ No newline at end of file
--- a/Headers/PmedLog.h Thu Jul 30 21:42:06 2015 +0000 +++ b/Headers/PmedLog.h Thu Jan 07 18:44:44 2016 +0000 @@ -16,6 +16,7 @@ //define as constant some log entries static const char *PMEDLOG_INITIALIZING = " Initializing Protegemed ... "; +static const char *PMEDLOG_INITIALIZINGWDT = " Initializing Protegemed by WhatchDog Timer... "; static const char *PMEDLOG_STARTED = " Started Protegemed ! "; static const char *PMEDLOG_WRONGCODE = " Oops... wrong code, a reset may be expected "; static const char *PMEDLOG_RESET = " No reason given ";
--- 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");