www.pudn.com > IEC104_codeamaterial.rar > sys.c, change:2011-03-23,size:2112b


/*------------------------------------------------------------------------ 
 Module:		sys.c 
 Author:		solar 
 Project:		 
 Creation Date: 2009-10-22 
 Description:	 
------------------------------------------------------------------------*/ 
/*------------------------------------------------------------------------ 
 $Log: $ 
------------------------------------------------------------------------*/ 
 
#include "syscfg.h" 
 
//#include "pcol.h" 
#include "sys.h" 
 
struct VSysInfo g_Sys; 
 
#ifdef INCLUDE_COMMTEST 
extern 	void ctsecinit(void); 
extern	void ctpriinit(void); 
#endif 
 
extern	void extio_high_Init(int tid);  
extern	void extio_low_Init(int tid); 
 
extern void ShellInit(void); 
extern void WachthDogInit(void); 
	 
 
/*void CheckMac(void) 
{ 
    BYTE lrccode; 
 
	if (g_Mac[MAC_LEN+1] != 0x5A)  
	{ 
		SetRunFlag(RUNF_MAC_NOCFG); 
		SetFault(FAULT_MAC); 
		return; 
	} 
	 
	lrccode = Lrc(g_Mac, MAC_LEN); 
	if (lrccode != g_Mac[MAC_LEN]) 
	{ 
	    SetRunFlag(RUNF_MAC_NOCFG);		 
		SetFault(FAULT_MAC); 
	}	 
}*/ 
 
void WriteWarnEvent(struct VCalClock *ptm, WORD errcode, const char *fmt, ... ) 
{ 
	/*VSysEventInfo event; 
    va_list varg; 
 
	va_start( varg, fmt ); 
	vsprintf(event.msg, fmt, varg ); 
	va_end( varg ); 
 
	if (ptm == NULL)  
		GetSysClock(&event.time, CALCLOCK); 
	else 
		event.time = *ptm;	 
	WriteSysEvent(g_Sys.pWarnEvent, SYSEV_FLAG_WARN, 1, &event);*/ 
	if (errcode) SysSetErr(errcode); 
} 
 
void SystemInit(void) 
{		 
    int ret; 
	DWORD baudrate; 
	 
#ifdef INCLUDE_TIMER 
	ClockInit(); 
#endif 
 
    tInit(); 
 
	WachthDogInit(); 
 
	memset(&g_Sys, 0, sizeof(g_Sys)); 
 
	/*CheckMac();*/ 
	ret = CheckAddr(); 
 
	SetRunFlag(RUNF_NOLOGIN|RUNF_CFGSYNC_MASK); 
 
	commInit(); 
 
	baudrate = 115200; 
	commCtrl(BUS_485_ID, CCC_BAUD_CTRL|BAUD_SET, &baudrate); 
	 
#ifdef INCLUDE_COMMTEST 
	ctsecinit(); 
#else	 
    if (ret == OK) 
    { 
		//extio_high_Init(BUS_CAN_ID); 
		//extio_low_Init(BUS_485_ID); 
    }	 
#endif 
 
	//ioInit(); 
	ShellInit(); 
 
#ifdef __DEBUG__ 
    myputs("\n\n\nI am rebooting...\n"); 
#endif 
 
    dtest(); 
 
	tRun(); 
}