void SetupTime(void) { InitTimerService(); // TBTC_TBIE=1; // TBTC_TBC1=1; // TBTC_TBC0=0; /* initialise reload timer 0 */ TMRLR0 = RELOAD_VALUE_0; /* set reload value*/ TMCSR0 = 0x81B; /* prescaler 2us at 16 MHz */ program.ms1counter=0; // TMRLR1 = RELOAD_VALUE_1; /* set reload value*/ // TMCSR1 = 0x81B; /* prescaler 2us at 16 MHz */ }
int main(int argc, char** argv) { SigInit(FurtherSignalHandling); if ( HandleCommandLine(argc, argv) != 0 ) return 10; if (CsfProcInit(true, true, NULL, INI_CORECONFIG, INI_STACKCONFIG, INIDEF_CORECONFIG, INIDEF_STACKCONFIG) != 0) CsErrx("main: could not initialise core/stack dump on error"); alarmInitialise(); clearAlarms(); if ( IpcInit() != 0 ) { CsErrx("IpcInit() failed"); return -1; } LoadIniFile(); CsMutexInit(&g_rxQueueLock , CSSYNC_THREAD); CsMutexInit(&g_queueLock , CSSYNC_THREAD); CsMutexInit(&g_heartbeatMapLock , CSSYNC_THREAD); CsMutexInit(&g_persistLock , CSSYNC_THREAD); CsMutexInit(&g_LANCommunicationTimerLock, CSSYNC_THREAD); CsMutexInit(&g_stateLock, CSSYNC_THREAD); appQueueId = IpcGetID(DC_TASK); wsQueueId = IpcGetID(WS_TASK); asQueueId = IpcGetID(AS_TASK); avlTaskId = IpcGetID(MYKI_AVL_TaskId); printerTaskId = IpcGetID(DC_PRINTER_TASK); if(InitialiseWebsocket()!=0) { return -1; } // Create Timer Service InitTimerService(); getNetworkSettings(); while(initCCE()!=0) { CsErrx("Cannot connect to CCE waiting 5 seconds"); CsSleep(5, 0); } // Execute application ProcessMessages(NULL); if (IpcClose() != 0) CsErrx("IpcClose: failed to close"); CsMutexDestroy(&g_rxQueueLock ); CsMutexDestroy(&g_queueLock ); CsMutexDestroy(&g_heartbeatMapLock ); CsMutexDestroy(&g_LANCommunicationTimerLock ); CsMutexDestroy(&g_persistLock ); CsMutexDestroy(&g_stateLock ); return 0; }