--- 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 <stdio.h>
+#include <app_glue.h>
/* 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)
--- 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 <pthread.h>
/* 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;
/*
--- 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 <windows.h>
/* 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*/
--- 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