
//串口元件

unit uart
{
	public const uint16 ID = 0;

	public link unit TXD {}
	public link unit RXD {}
	
	//[i] linkconst_int32_9600 baud;
	public const int32 baud = 9600;
	
	//---------------------
	//[i] var_uint8 OS_time;
	public uint8 OS_time;
	
	uint8 tick;
	
	//---------------------
	//[i] var_bool ok;
	public bool ok;
	//---------------------
	//[i] var_bool notok;
	public bool notok;
	
	//[i] var_uint8 OS_EventFlag;
	//[i] event receive_event;
	
	//[i] var_Cstring Ebuffer;
	[uint8*12] Ebuffer;
	//[i] var_Cstring Nbuffer;
	[uint8*12] Nbuffer;
	
	
	//[i] var_int32 E;
	int32 E;
	//[i] var_int32 N;
	int32 N;
	
	//[i] var_int32 Year;
	int32 Year;
	//[i] var_int32 Mouth;
	int32 Mouth;
	//[i] var_int32 Day;
	int32 Day;
	//[i] var_int32 Hour;
	int32 Hour;
	//[i] var_int32 Minute;
	int32 Minute;
	//[i] var_int32 Second;
	int32 Second;
	
	public const int8 max_length = 100;
	public [uint8*max_length] buffer;
	public int8 length;
	public uint8 OS_EventFlag;
	
	public const int32 XTAL = $freq$;

	#include "$run$.txt"
	
	//----------------------------------------------------
	//[i] function_void OS_init;
	public void OS_init()
	{
		OS_EventFlag = 0;
		
		RXD.D0_DIR = 1;
		RXD.D0_OUT = 1;
		
		//TXD.D0_DIR = 0;
		//TXD.D0_OUT = 1;
		
		//设置默认波特率
		set_baud( baud );
		
		length = 0;
		
		OS_time = 100;
		tick = 0;

		ok = false;
		notok = true;
	}
	//---------------------------------------------------
	//[i] function_void OS_run;
	//public void OS_run()
}













