?? main.c
字號:
//----------------------------main.c------------------
#define DEBUG 1
#include "includes.h"
uchar volatile cmd;
//-----------------------------------
void init()
{
LED=0; //指示燈亮
init_t0();
Timer_Init();
init_uart(B115200);//B19200);//
init_arp();
init_tcp();
init_8019();
clean_buf(inbuf,MAXBUF);
LED=1; //指示燈滅
EA=1;
}
void OnEthernet(void)
{
uint data len;
len=frame_receive(inbuf);
KillTimer(QUERY_8019);
// TRACE("inbuf=",inbuf,20,0);
eth_process(inbuf);
clean_buf(inbuf,MAXBUF);
SetTimer(QUERY_8019,5);
}
void OnTimer(uchar id)
{
switch (id)
{
case ARP_RESEND:
arp_resend();
break;
case QUERY_8019:
if(query_8019())
{
OnEthernet();
}
break;
case ARP_AGE:
age_arp_cache();
break;
case TCP_RESEND:
tcp_resend();
break;
case TCP_ABORT:
tcp_inactivity();
break;
case LED_RAY:
LED=~LED;
break;
}
}
void main()
{
uchar data i;
init();
SetTimer(QUERY_8019,5);
SetTimer(ARP_AGE,60000);
SetTimer(TCP_RESEND,500);
SetTimer(LED_RAY,1000);
#ifdef OSCAR_DEBUG
TRACE("TCP/IP VER1.0",NULL,0,0);
TRACE("MYIP = ",CP &myipaddr,4,0);
#endif
while(1)
{
for(i=0; i<MAX_TIMER; i++)
{
if (Timer_GetEvent(i) & EVF_TIMERMATCH)
OnTimer(i);
}
switch (cmd)
{
case 0x55 :
// udp_send(outbuf,test,0xc0a801a7, 0x21ee, 1050);
cmd=0;
break;
case 0x56 :
TRACE("ARP_Cache = ",(uchar *)arp_cache,sizeof(arp_cache),0);
cmd=0;
break;
default:
break;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -