📄 main.lst
字号:
C51 COMPILER V8.08 MAIN 08/22/2008 14:32:51 PAGE 1
C51 COMPILER V8.08, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /*
2 TITLE: Keil C51 v7.00 port of Adam Dunkels' uIP v0.9
3
4
5 */
6
7
8 #include "main.h"
9 #define IP_addr0 192 //远程主机的IP地址
10 #define IP_addr1 168
11 #define IP_addr2 1
12 #define IP_addr3 4
13 #define RO_port 1280
14
15 unsigned char tick_count;
16 sbit P10 = P1^0;
17 sbit P11 = P1^1; //add1
18 sbit P12 = P1^2; //add1
19 #define TURNON 1
20 #define TURNOFF 0
21 #define DATANUM 200
22 #define OK 1
23 #define NOT 0
24 unsigned char connect_state; //add8
25 extern unsigned int temp_len; //串口接收数据长度
26 extern unsigned char *ptr_tx;
27 extern u8_t xdata count_rx[DATANUM];
28 static unsigned int ipptr[2];
29 static unsigned int tport;
30 //extern u16_t idata uip_hostaddr[2];
31 //extern u16_t idata uip_arp_draddr[2];
32 //extern u16_t idata uip_arp_netmask[2];
33
34 static unsigned char state_ip;
35 void main(void)
36 {
37 1 u8_t i;
38 1
39 1 uip_ipaddr(ipptr, IP_addr0,IP_addr1,IP_addr2,IP_addr3);
40 1 tport=htons(RO_port);
41 1 connect_state=TURNOFF;
42 1
43 1 // uip_ipaddr(uip_hostaddr,192,168,1,5); //设置暂时IP
44 1 // uip_ipaddr(uip_arp_draddr,192,168,1,8);
45 1 //uip_ipaddr(uip_arp_netmask,255,255,255,0);
46 1 state_ip=NOT;
47 1 uip_init(); //初始化uIP TCP/IP堆栈
48 1
49 1 datatrans_init(); //初始化app
50 1
51 1 encInit(); //设备驱动的初始化
52 1
53 1 // Timer_Init();
54 1
55 1 uip_arp_init(); //初始化ARP缓存
C51 COMPILER V8.08 MAIN 08/22/2008 14:32:51 PAGE 2
56 1
57 1 tick_count=0;
58 1
59 1 while(1)
60 1 { /* if((RI==0)&&(temp_len!=0)&&(temp_len>=15))
61 2 { if((count_rx[0]==0x47)&&(count_rx[1]==0x45)&&(count_rx[2]==0x54)&&(state_ip==NOT))
62 2 {
63 2 uip_ipaddr(uip_hostaddr,count_rx[3],count_rx[4],count_rx[5],count_rx[6]);
64 2 uip_ipaddr(uip_arp_draddr,count_rx[7],count_rx[8],count_rx[9],count_rx[10]);
65 2 uip_ipaddr(uip_arp_netmask,count_rx[11],count_rx[12],count_rx[13],count_rx[14]);
66 2 state_ip=OK;
67 2 }
68 2 temp_len=0; //串口接收到的数据已经发送出去,串口接收指针复位
69 2 ptr_tx = &count_rx[0];
70 2 } */
71 2 uip_len = EthdevSPI_read();
72 2 if(uip_len!=0)/* (uip_len != 0) Process incoming */
73 2 {
74 3 if(BUF->type == htons(UIP_ETHTYPE_IP)) //IP包
75 3 {
76 4 uip_arp_ipin();
77 4 uip_input(); //#define uip_input() uip_process(UIP_DATA)
78 4 /* If the above function invocation resulted in data that
79 4 should be sent out on the network, the global variable
80 4 uip_len is set to a value > 0.为什么带外回应数据 */
81 4 if(uip_len > 0) //syn 重启包
82 4 {
83 5 uip_arp_out();
84 5 EthdevSPI_Sendpack();
85 5 }
86 4 }
87 3 else if(BUF->type == htons(UIP_ETHTYPE_ARP)) //ARP包
88 3 {
89 4 uip_arp_arpin();
90 4
91 4 /* If the above function invocation resulted in data that
92 4 should be sent out on the network, the global variable
93 4 uip_len is set to a value > 0. */
94 4 if(uip_len > 0)
95 4 {
96 5 EthdevSPI_Sendpack();
97 5 }
98 4 }
99 3 }
100 2 else
101 2 {
102 3
103 3 for(i = 0; i < UIP_CONNS; i++) //UIP_CONNS=5
104 3 {
105 4 uip_periodic(i); //uip_conn = &uip_conns[conn]; uip_process(UIP_TIMER)
106 4 /* If the above function invocation 请求resulted in data that
107 4 should be sent out on the network, the global variable
108 4 uip_len is set to a value > 0.
109 4 由于函数的调用,使得有数据输入的话,从而uip_len>0而要求发送数据*/
110 4 if(uip_len > 0) //如果重新装载了数据
111 4 {
112 5 uip_arp_out();
113 5 EthdevSPI_Sendpack();
114 5 }
115 4 }
116 3
117 3 #if UIP_UDP
C51 COMPILER V8.08 MAIN 08/22/2008 14:32:51 PAGE 3
for(i = 0; i < UIP_UDP_CONNS; i++)
{
uip_udp_periodic(i);
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0)
{
uip_arp_out();
EthdevSPI_Sendpack();
}
}
#endif /* UIP_UDP */
131 3
132 3 // Call the ARP timer function every 10 seconds.
133 3 //可以定义一时间0.5ms的中断计数
134 3 // if(connect_state==TURNOFF) {Timer1on();}
135 3 if(connect_state==TURNOFF) //无连接,并且串口缓冲有数据
136 3 { if(temp_len!=0)
137 4 {
138 5 #if UIP_ACTIVE_OPEN
139 5 uip_connect(ipptr, tport);
140 5 connect_state=TURNON;
141 5 P10=~P10;
142 5 #endif/* UIP_ACTIVE_OPEN UIP_ACTIVE_OPEN */
143 5 }
144 4 }
145 3
146 3 if(tick_count >= 10) //add6
147 3 {
148 4 uip_arp_timer();
149 4 tick_count = 0;
150 4 }
151 3 }
152 2 }
153 1
154 1 return;
155 1 }
156
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 242 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 9 1
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -