author | Lolitech |
Fri, 04 Jun 2010 14:59:11 +0200 | |
changeset 556 | 1ad4e7f1e89e |
parent 521 | 02cb9e5fb6f6 |
child 577 | 04baf6607a44 |
permissions | -rwxr-xr-x |
425 | 1 |
/** |
2 |
* Yagarto specific code |
|
3 |
**/ |
|
4 |
||
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
5 |
#include <app_glue.h> |
425 | 6 |
|
7 |
/* provided by POUS.C */ |
|
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
8 |
extern unsigned long long common_ticktime__; |
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
9 |
void LPC_GetTime(IEC_TIME*); |
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
10 |
void LPC_SetTimer(unsigned long long next, unsigned long long period); |
425 | 11 |
|
12 |
long AtomicCompareExchange(long* atomicvar,long compared, long exchange) |
|
13 |
{ |
|
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
14 |
/* No need for real atomic op on LPC, |
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
15 |
* no possible preemption between debug and PLC */ |
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
16 |
long res = *atomicvar; |
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
17 |
if(res == compared){ |
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
18 |
*atomicvar = exchange; |
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
19 |
} |
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
20 |
return res; |
425 | 21 |
} |
22 |
||
23 |
void PLC_GetTime(IEC_TIME *CURRENT_TIME) |
|
24 |
{ |
|
25 |
/* Call target GetTime function */ |
|
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
26 |
LPC_GetTime(CURRENT_TIME); |
425 | 27 |
} |
28 |
||
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
29 |
void PLC_SetTimer(unsigned long long next, unsigned long long period) |
425 | 30 |
{ |
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
31 |
LPC_SetTimer(next, period); |
425 | 32 |
} |
33 |
||
34 |
int startPLC(int argc,char **argv) |
|
35 |
{ |
|
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
36 |
if(__init(argc,argv) == 0){ |
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
37 |
PLC_SetTimer(0, common_ticktime__); |
425 | 38 |
return 0; |
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
39 |
}else{ |
425 | 40 |
return 1; |
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
502
diff
changeset
|
41 |
} |
425 | 42 |
} |
43 |
||
44 |
int TryEnterDebugSection(void) |
|
45 |
{ |
|
502 | 46 |
return __DEBUG; |
425 | 47 |
} |
48 |
||
49 |
void LeaveDebugSection(void) |
|
50 |
{ |
|
51 |
} |
|
52 |
||
53 |
int stopPLC(void) |
|
54 |
{ |
|
55 |
__cleanup(); |
|
56 |
return 0; |
|
57 |
} |
|
58 |
||
59 |
extern unsigned long __tick; |
|
502 | 60 |
int _DebugDataAvailable = 0; |
425 | 61 |
/* from plc_debugger.c */ |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
425
diff
changeset
|
62 |
int WaitDebugData(unsigned long *tick) |
425 | 63 |
{ |
452
2d0718a05cc7
Reflect changes in iec type definitions in matiec/lib
edouard
parents:
425
diff
changeset
|
64 |
*tick = __tick; |
502 | 65 |
return _DebugDataAvailable; |
425 | 66 |
} |
67 |
||
68 |
/* Called by PLC thread when debug_publish finished |
|
69 |
* This is supposed to unlock debugger thread in WaitDebugData*/ |
|
70 |
void InitiateDebugTransfer(void) |
|
71 |
{ |
|
502 | 72 |
_DebugDataAvailable = 1; |
425 | 73 |
} |
74 |
||
502 | 75 |
void suspendDebug(int disable) |
425 | 76 |
{ |
502 | 77 |
__DEBUG = !disable; |
425 | 78 |
} |
79 |
||
80 |
void resumeDebug(void) |
|
81 |
{ |
|
502 | 82 |
__DEBUG = 1; |
425 | 83 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
478
diff
changeset
|
84 |
|
521
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
85 |
int CheckRetainBuffer(void) |
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
86 |
{ |
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
87 |
/* TODO : compare RETAIN buffer start with MD5 */ |
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
88 |
return 0; |
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
89 |
} |
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
90 |
|
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
478
diff
changeset
|
91 |
void Retain(unsigned int offset, unsigned int count, void *p) |
497 | 92 |
{ |
521
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
93 |
/* TODO : write in RETAIN buffer at offset*/ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
478
diff
changeset
|
94 |
} |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
478
diff
changeset
|
95 |
|
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
478
diff
changeset
|
96 |
void Remind(unsigned int offset, unsigned int count, void *p) |
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
478
diff
changeset
|
97 |
{ |
521
02cb9e5fb6f6
LPC transfer tested, added PLCInfo along MD5 checksum while invoking makefile
edouard
parents:
518
diff
changeset
|
98 |
/* TODO : read at offset in RETAIN buffer */ |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
478
diff
changeset
|
99 |
} |