1 /** |
1 /** |
2 * Yagarto specific code |
2 * Yagarto specific code |
3 **/ |
3 **/ |
4 |
4 |
5 //#include <stdio.h> |
5 #include <app_glue.h> |
6 |
6 |
7 /* provided by POUS.C */ |
7 /* provided by POUS.C */ |
8 extern int common_ticktime__; |
8 extern unsigned long long common_ticktime__; |
9 |
9 void LPC_GetTime(IEC_TIME*); |
10 void Target_GetTime(IEC_TIME*); |
10 void LPC_SetTimer(unsigned long long next, unsigned long long period); |
11 |
11 |
12 long AtomicCompareExchange(long* atomicvar,long compared, long exchange) |
12 long AtomicCompareExchange(long* atomicvar,long compared, long exchange) |
13 { |
13 { |
14 return 0; |
14 /* No need for real atomic op on LPC, |
|
15 * no possible preemption between debug and PLC */ |
|
16 long res = *atomicvar; |
|
17 if(res == compared){ |
|
18 *atomicvar = exchange; |
|
19 } |
|
20 return res; |
15 } |
21 } |
16 |
22 |
17 void PLC_GetTime(IEC_TIME *CURRENT_TIME) |
23 void PLC_GetTime(IEC_TIME *CURRENT_TIME) |
18 { |
24 { |
19 /* Call target GetTime function */ |
25 /* Call target GetTime function */ |
20 Target_GetTime(CURRENT_TIME); |
26 LPC_GetTime(CURRENT_TIME); |
21 } |
27 } |
22 |
28 |
23 void PLC_SetTimer(long long next, long long period) |
29 void PLC_SetTimer(unsigned long long next, unsigned long long period) |
24 { |
30 { |
|
31 LPC_SetTimer(next, period); |
25 } |
32 } |
26 |
33 |
27 int startPLC(int argc,char **argv) |
34 int startPLC(int argc,char **argv) |
28 { |
35 { |
29 if(__init(argc,argv) == 0) |
36 if(__init(argc,argv) == 0){ |
|
37 PLC_SetTimer(0, common_ticktime__); |
30 return 0; |
38 return 0; |
31 else |
39 }else{ |
32 return 1; |
40 return 1; |
|
41 } |
33 } |
42 } |
34 |
43 |
35 int TryEnterDebugSection(void) |
44 int TryEnterDebugSection(void) |
36 { |
45 { |
37 return __DEBUG; |
46 return __DEBUG; |