Versão sem FFT e aquisição por DMA. 256 amostras.
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
Diff: main.cpp
- Revision:
- 0:e57bc370d339
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 05 11:45:44 2016 +0000 @@ -0,0 +1,142 @@ +/* + Projeto teste de Enviar dados coletados sem calcular a FFT. + +*/ + +#define MSGWINDOW "Version 2" + +#include <stdio.h> + +#include "mbed.h" +#include "rtos.h" +#include "cmsis_os.h" +#include "EthernetInterface.h" +#include "Settings.h" +#include "Capture.h" +#include "Http_post.h" +#include "SignalProcessor.h" +#include "EventDetector.h" +#include "limites.h" + +#include "TelnetServer.h" + +#include "tftpsrv.h" +#include "ntpc.h" + +#include "PmedLog.h" + +#include "NTPClient.h" + +#include "whatchdog.h" + +EthernetInterface eth; +Watchdog wdt; + +void InitializeEthernetLink() +{ + if(Settings::get_Dhcp()) + //EthernetIf::Initialize(); //Use DHCP + eth.init(); //Use DHCP + else + //EthernetIf::Initialize(Settings::get_IpAddress(),Settings::get_Netmask(),Settings::get_Gateway()); + eth.init(Settings::get_IpAddress(),Settings::get_Netmask(),Settings::get_Gateway()); + + //EthernetIf::Connect(); + eth.connect(); + //printf("IP Address is %s\n", EthernetIf::get_IpAddress()); + printf("IP Address is NEW %s\n", eth.getIPAddress()); +} + +int main() { + //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\n %s \r\n", MSGWINDOW); + FILE *f; + + Settings::ReadFile(); + + InitializeEthernetLink(); + printf("Inicializou link Ethernet\n"); + + //Start HTTP POST service + Thread http_post(HttpPost::HttpPost_Thread); + + //Start Telnet Service + //Thread telnetserver(TelnetServer::TelnetServer_Thread); + + //Start TFTP Service + //Thread tftpsrv(tftpsrv::tftpsrv_Thread); + + //Start NTP Client for refresh time + //Thread ntpc(ntpc::ntpc_Thread); + time_t tempo = time(NULL); + if ((tempo+60) < 1420077600) set_time(1420077600); + + // ntpClient.setTime("192.168.103.101"); + + DisplayRAMBanks(); + + printf(PMEDLOG_INITIALIZINGWDT); + printf("\n\n"); + + + PmedLog::WriteEntry(PMEDLOG_STARTED); + + /* 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(); + } + + while(1){//never reaches here + PmedLog::WriteEntry(PMEDLOG_WRONGCODE); + printf("Reset\n"); + f = fopen(FILENAMERESET, "a"); + if (f == NULL) + f = fopen(FILENAMERESET, "w"); + fprintf(f, "Laco Errado\n"); + fclose(f); + Thread::yield(); + } +} +