# HG changeset patch # User edouard # Date 1260887702 -3600 # Node ID 8e61b00668590e8c9502c74d7a0f70f3dc6be5ae # Parent 6da1617a7645b13713f636a12204d4f49c4267e1 Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support diff -r 6da1617a7645 -r 8e61b0066859 targets/LPC/plc_LPC_main.c --- a/targets/LPC/plc_LPC_main.c Tue Dec 15 14:40:45 2009 +0100 +++ b/targets/LPC/plc_LPC_main.c Tue Dec 15 15:35:02 2009 +0100 @@ -2,34 +2,43 @@ * Yagarto specific code **/ -//#include +#include /* provided by POUS.C */ -extern int common_ticktime__; - -void Target_GetTime(IEC_TIME*); +extern unsigned long long common_ticktime__; +void LPC_GetTime(IEC_TIME*); +void LPC_SetTimer(unsigned long long next, unsigned long long period); long AtomicCompareExchange(long* atomicvar,long compared, long exchange) { - return 0; + /* No need for real atomic op on LPC, + * no possible preemption between debug and PLC */ + long res = *atomicvar; + if(res == compared){ + *atomicvar = exchange; + } + return res; } void PLC_GetTime(IEC_TIME *CURRENT_TIME) { /* Call target GetTime function */ - Target_GetTime(CURRENT_TIME); + LPC_GetTime(CURRENT_TIME); } -void PLC_SetTimer(long long next, long long period) +void PLC_SetTimer(unsigned long long next, unsigned long long period) { + LPC_SetTimer(next, period); } int startPLC(int argc,char **argv) { - if(__init(argc,argv) == 0) + if(__init(argc,argv) == 0){ + PLC_SetTimer(0, common_ticktime__); return 0; - else + }else{ return 1; + } } int TryEnterDebugSection(void) diff -r 6da1617a7645 -r 8e61b0066859 targets/Linux/plc_Linux_main.c --- a/targets/Linux/plc_Linux_main.c Tue Dec 15 14:40:45 2009 +0100 +++ b/targets/Linux/plc_Linux_main.c Tue Dec 15 15:35:02 2009 +0100 @@ -10,7 +10,7 @@ #include /* provided by POUS.C */ -extern int common_ticktime__; +extern unsigned long long common_ticktime__; long AtomicCompareExchange(long* atomicvar,long compared, long exchange) { @@ -30,7 +30,7 @@ timer_t PLC_timer; -void PLC_SetTimer(long long next, long long period) +void PLC_SetTimer(unsigned long long next, unsigned long long period) { struct itimerspec timerValues; /* diff -r 6da1617a7645 -r 8e61b0066859 targets/Win32/plc_Win32_main.c --- a/targets/Win32/plc_Win32_main.c Tue Dec 15 14:40:45 2009 +0100 +++ b/targets/Win32/plc_Win32_main.c Tue Dec 15 15:35:02 2009 +0100 @@ -8,7 +8,7 @@ #include /* provided by POUS.C */ -extern unsigned long common_ticktime__; +extern unsigned long long common_ticktime__; long AtomicCompareExchange(long* atomicvar, long compared, long exchange) { @@ -31,7 +31,7 @@ } HANDLE PLC_timer = NULL; -void PLC_SetTimer(long long next, long long period) +void PLC_SetTimer(unsigned long long next, unsigned long long period) { LARGE_INTEGER liDueTime; /* arg 2 of SetWaitableTimer take 100 ns interval*/ diff -r 6da1617a7645 -r 8e61b0066859 targets/plc_common_main.c --- a/targets/plc_common_main.c Tue Dec 15 14:40:45 2009 +0100 +++ b/targets/plc_common_main.c Tue Dec 15 15:35:02 2009 +0100 @@ -84,7 +84,7 @@ void PLC_GetTime(IEC_TIME *CURRENT_TIME); -void PLC_SetTimer(long long next, long long period); +void PLC_SetTimer(unsigned long long next, unsigned long long period); #define CALIBRATED -2 #define NOT_CALIBRATED -1