targets/LPC/plc_LPC_main.c
author Lolitech
Fri, 04 Jun 2010 14:59:11 +0200
changeset 556 1ad4e7f1e89e
parent 521 02cb9e5fb6f6
child 577 04baf6607a44
permissions -rwxr-xr-x
LPC Composer don't send comma at the end of serial port name.
/**
 * Yagarto specific code
 **/

#include <app_glue.h>

/* provided by POUS.C */
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)
{
	/* 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 */
	LPC_GetTime(CURRENT_TIME);
}

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){
		PLC_SetTimer(0, common_ticktime__);
		return 0;
	}else{
		return 1;
	}
}

int TryEnterDebugSection(void)
{
    return __DEBUG;
}

void LeaveDebugSection(void)
{
}

int stopPLC(void)
{
    __cleanup();
    return 0;
}

extern unsigned long __tick;
int _DebugDataAvailable = 0;
/* from plc_debugger.c */
int WaitDebugData(unsigned long *tick)
{
    *tick = __tick;
    return _DebugDataAvailable;
}

/* Called by PLC thread when debug_publish finished
 * This is supposed to unlock debugger thread in WaitDebugData*/
void InitiateDebugTransfer(void)
{
    _DebugDataAvailable = 1;
}

void suspendDebug(int disable)
{
    __DEBUG = !disable;
}

void resumeDebug(void)
{
    __DEBUG = 1;
}

int CheckRetainBuffer(void)
{
	/* TODO : compare RETAIN buffer start with MD5 */
	return 0;
}

void Retain(unsigned int offset, unsigned int count, void *p)
{
	/* TODO : write in RETAIN buffer at offset*/
}

void Remind(unsigned int offset, unsigned int count, void *p)
{
	/* TODO : read at offset in RETAIN buffer */
}