Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: main.cpp
- Revision:
- 18:55f1581f2ee4
- Parent:
- 17:4687bf932b8c
- Child:
- 19:74155d652c37
--- a/main.cpp Wed Sep 12 22:50:25 2012 +0000 +++ b/main.cpp Sat Sep 29 04:54:15 2012 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" -#define USE_RTOS_TIMER +//#define USE_RTOS_TIMER +//#define USE_ETH_INTERFACE //#define EVT_TIME_PROFILE //#define DEBUG @@ -11,8 +12,8 @@ #include "SDFileSystem.h" #ifdef USE_MODSERIAL #include "MODSERIAL.h" -#define MODSERIAL_RX_BUF_SIZE 2048 -#define MODSERIAL_TX_BUF_SIZE 2048 +#define MODSERIAL_RX_BUF_SIZE 512 +#define MODSERIAL_TX_BUF_SIZE 512 #endif #include "Watchdog.h" #include "SnConstants.h" @@ -23,7 +24,11 @@ #include "SnStatusFrame.h" #include "SnHeaderFrame.h" #include "SnCommWin.h" +#ifdef USE_ETH_INTERFACE #include "SnCommAfarTCP.h" +#else +#include "SnCommAfarNetIf.h" +#endif #include "SnCommUsb.h" #include "SnCommSBD.h" #include "SnBase64.h" @@ -358,12 +363,12 @@ #endif #ifdef USE_RTOS_TIMER -uint32_t resetTicker(rtos::RtosTimer* tik, const uint32_t timSec, - const uint32_t maxTimSec) { +float resetTicker(rtos::RtosTimer* tik, const float timSec, + const float maxTimSec) { if (tik!=0) { tik->stop(); if (timSec>0) { - uint32_t tp = timSec > maxTimSec ? maxTimSec : timSec; + float tp = timSec > maxTimSec ? maxTimSec : timSec; tp *= 1000u; // ms /* if (tik==gForceTicker) { @@ -378,11 +383,11 @@ return 0; } #else -uint32_t resetTicker(Ticker& tik, const uint32_t timSec, - const uint32_t maxTimSec, void (*fptr)(void)) { +float resetTicker(Ticker& tik, const float timSec, + const float maxTimSec, void (*fptr)(void)) { tik.detach(); if (timSec>0) { - const uint32_t tp = timSec > maxTimSec ? maxTimSec : timSec; + const float tp = timSec > maxTimSec ? maxTimSec : timSec; tik.attach(fptr, tp); return tp; } @@ -399,29 +404,29 @@ void ResetAllTickers() { #ifdef USE_RTOS_TIMER - const uint32_t ftp = resetTicker(gForceTicker, gConf.GetForceTrigPeriod(), - kAbsMaxTimer); - const uint32_t hbp = resetTicker(gHeartbeatTicker, gConf.GetHeartbeatPeriod(), - kAbsMaxTimer); - const uint32_t cwp = resetTicker(gCommWinTicker, gConf.GetCommWinPeriod(), - kCommWinLongPrdTk); - const uint32_t pcp = resetTicker(gPowerCheckTicker, gConf.GetVoltCheckPeriod(), - kAbsMaxTimer); + const float ftp = resetTicker(gForceTicker, gConf.GetForceTrigPeriod(), + kAbsMaxTimer); + const float hbp = resetTicker(gHeartbeatTicker, gConf.GetHeartbeatPeriod(), + kAbsMaxTimer); + const float cwp = resetTicker(gCommWinTicker, gConf.GetCommWinPeriod(), + kCommWinLongPrdTk); + const float pcp = resetTicker(gPowerCheckTicker, gConf.GetVoltCheckPeriod(), + kAbsMaxTimer); #else - const uint32_t ftp = resetTicker(gForceTicker, gConf.GetForceTrigPeriod(), - kAbsMaxTimer, &procForceTrigger); - const uint32_t hbp = resetTicker(gHeartbeatTicker, gConf.GetHeartbeatPeriod(), - kAbsMaxTimer, &procHeartbeat); - const uint32_t cwp = resetTicker(gCommWinTicker, gConf.GetCommWinPeriod(), - kCommWinLongPrdTk, &procCommWin); - const uint32_t pcp = resetTicker(gPowerCheckTicker, gConf.GetVoltCheckPeriod(), - kAbsMaxTimer, &procPowerCheck); + const float ftp = resetTicker(gForceTicker, gConf.GetForceTrigPeriod(), + kAbsMaxTimer, &procForceTrigger); + const float hbp = resetTicker(gHeartbeatTicker, gConf.GetHeartbeatPeriod(), + kAbsMaxTimer, &procHeartbeat); + const float cwp = resetTicker(gCommWinTicker, gConf.GetCommWinPeriod(), + kCommWinLongPrdTk, &procCommWin); + const float pcp = resetTicker(gPowerCheckTicker, gConf.GetVoltCheckPeriod(), + kAbsMaxTimer, &procPowerCheck); #endif #ifdef DEBUG - printf("attach force trig %u\r\n",ftp); - printf("attach heart beat %u\r\n",hbp); - printf("attach comm win %u\r\n",cwp); - printf("attach power chk %u\r\n",pcp); + printf("attach force trig %g\r\n",ftp); + printf("attach heart beat %g\r\n",hbp); + printf("attach comm win %g\r\n",cwp); + printf("attach power chk %g\r\n",pcp); #endif } @@ -442,8 +447,8 @@ int main() { { - //gCpu.baud(19200); -#ifdef SSNOTIFY + gCpu.baud(115200); +#if defined(SSNOTIFY) || defined(DEBUG) printf("main: start\r\n"); #endif led1=1; wait(0.2); @@ -452,11 +457,25 @@ led3=0; led4=1; wait(0.2); led4=0; } + +#ifdef DEBUG + printf("making comm objects\r\n"); +#endif // RTOS stuff must be made inside main for some reason - //gComms[0] = new SnCommAfarTCP(gConf); +/* +#ifdef USE_ETH_INTERFACE + gComms[0] = new SnCommAfarTCP(gConf); +#else + gComms[0] = new SnCommAfarNetIf(gConf); +#endif +*/ //gComms[0] = new SnCommSBD(&gSBDport, &gCpu); gComms[0] = new SnCommUsb(&gCpu); + +#ifdef DEBUG + printf("make comm objects\r\n"); +#endif #ifdef USE_RTOS_TIMER gForceTicker = new rtos::RtosTimer(&procForceTrigger);