targets/LPC/plc_LPC_main.c
author edouard
Mon, 14 Dec 2009 21:05:10 +0100
changeset 512 36aeab46f27d
parent 502 5343ae43f6d0
child 518 8e61b0066859
permissions -rwxr-xr-x
Improved CanFEstival support for LPC - now build and link plugin generated files
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     1
/**
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     2
 * Yagarto specific code
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     3
 **/
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     4
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     5
//#include <stdio.h>
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     6
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     7
/* provided by POUS.C */
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     8
extern int common_ticktime__;
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
     9
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    10
void Target_GetTime(IEC_TIME*);
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    11
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    12
long AtomicCompareExchange(long* atomicvar,long compared, long exchange)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    13
{
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    14
	return 0;
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    15
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    16
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    17
void PLC_GetTime(IEC_TIME *CURRENT_TIME)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    18
{
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    19
	/* Call target GetTime function */
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    20
	Target_GetTime(CURRENT_TIME);
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    21
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    22
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    23
void PLC_SetTimer(long long next, long long period)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    24
{
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    25
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    26
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    27
int startPLC(int argc,char **argv)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    28
{
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    29
	if(__init(argc,argv) == 0)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    30
		return 0;
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    31
	else
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    32
		return 1;
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    33
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    34
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    35
int TryEnterDebugSection(void)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    36
{
502
5343ae43f6d0 LPC connector - one step further
edouard
parents: 497
diff changeset
    37
    return __DEBUG;
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    38
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    39
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    40
void LeaveDebugSection(void)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    41
{
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    42
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    43
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    44
int stopPLC(void)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    45
{
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    46
    __cleanup();
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    47
    return 0;
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    48
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    49
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    50
extern unsigned long __tick;
502
5343ae43f6d0 LPC connector - one step further
edouard
parents: 497
diff changeset
    51
int _DebugDataAvailable = 0;
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    52
/* from plc_debugger.c */
452
2d0718a05cc7 Reflect changes in iec type definitions in matiec/lib
edouard
parents: 425
diff changeset
    53
int WaitDebugData(unsigned long *tick)
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    54
{
452
2d0718a05cc7 Reflect changes in iec type definitions in matiec/lib
edouard
parents: 425
diff changeset
    55
    *tick = __tick;
502
5343ae43f6d0 LPC connector - one step further
edouard
parents: 497
diff changeset
    56
    return _DebugDataAvailable;
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    57
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    58
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    59
/* Called by PLC thread when debug_publish finished
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    60
 * This is supposed to unlock debugger thread in WaitDebugData*/
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    61
void InitiateDebugTransfer(void)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    62
{
502
5343ae43f6d0 LPC connector - one step further
edouard
parents: 497
diff changeset
    63
    _DebugDataAvailable = 1;
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    64
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    65
502
5343ae43f6d0 LPC connector - one step further
edouard
parents: 497
diff changeset
    66
void suspendDebug(int disable)
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    67
{
502
5343ae43f6d0 LPC connector - one step further
edouard
parents: 497
diff changeset
    68
    __DEBUG = !disable;
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    69
}
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    70
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    71
void resumeDebug(void)
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    72
{
502
5343ae43f6d0 LPC connector - one step further
edouard
parents: 497
diff changeset
    73
    __DEBUG = 1;
425
f390e9fdd2cf Add new target (Makefile)
greg
parents:
diff changeset
    74
}
483
bc26c42d2eec fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents: 478
diff changeset
    75
bc26c42d2eec fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents: 478
diff changeset
    76
void Retain(unsigned int offset, unsigned int count, void *p)
497
ed7f72fc785f Typo in LPC
edouard
parents: 483
diff changeset
    77
{
483
bc26c42d2eec fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents: 478
diff changeset
    78
}
bc26c42d2eec fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents: 478
diff changeset
    79
bc26c42d2eec fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents: 478
diff changeset
    80
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
    81
{
bc26c42d2eec fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents: 478
diff changeset
    82
}