📄 main.lst
字号:
C51 COMPILER V9.00 MAIN 02/08/2010 20:58:31 PAGE 1
C51 COMPILER V9.00, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c LARGE BROWSE INCDIR(..\uip1.0\apps;..\uip1.0\uip;..\cp2200;..\cp2200
-;..\uip1.0\apps\dhcpc;..\uip1.0\apps\httpd) DEBUG OBJECTEXTEND
line level source
1 /******************************************************************************
2 ** Copyright(C) jerkoh
3 ** CPU:C8051F020
4 ** MAC+PHY:CP2200
5 ** RAM:256+4096 byte
6 ** Flash:64k byte
7 ** OSC:22.118400Mhz
8 ** Tcp/ip protocol stack: Adam Dunkels uip1.0
9 ** Written for Keil C51 V9.00
10 ** compiler Model:large Level:8
11 ** Email:jerkoh@163.com
12 ******************************************************************************/
13 /******************************************************************************
14 ** log:
15 ** 10-02-06 创建工程c8051f020_uip1.0 搭建编译环境
16 ******************************************************************************/
17 #include "main.h"
18 extern void app1_init(void);
19 extern u8_t xdata my_hwaddr[6];
20 #define BUF ((struct uip_eth_hdr *)&uip_buf[0])
21
22 #define USE_STATIC_IP //dhcp 不使能
23 u8_t code cdbuf[34]={0xc0,0xa8,0x02,0xEA, /*192.168.2.234*/
24 0xff,0xff,0xff,0x00, /*255.255.255.0*/
25 0xc0,0xa8,0x02,0x01, /*192.168.2.1*/
26 0x0f,0xa1, /*4001*/
27 0xce,0xb4,0xc9,0xe8,0xd6,0xc3,0xc9,0xe8,0xb1,0xb8, /*未设置设备名称*/
28 0xc3,0xfb,0xb3,0xc6,0x00,0x00,0x00,0x00,0x00,0x00};
29
30 unsigned int Count1msInc;
31 unsigned char Count1ms,Count10ms,Count1s;
32 unsigned char TimeSecond,TimeMinute;
33 clock_time_t tick_cnt;
34
35
36 clock_time_t clock_time(void)
37 {
38 1 return tick_cnt;
39 1 }
40
41
42
43
44 void main(void)
45 {
46 1 u8_t i;
47 1 uip_ipaddr_t ipaddr;
48 1 struct timer periodic_timer, arp_timer;
49 1 static struct uip_eth_addr sTempAddr;
50 1
51 1 WDTCN = 0xDE; /* Disable watchdog timer*/
52 1 WDTCN = 0xAD;
53 1
54 1 SYSCLK_Init(); /* initialize oscillator*/
C51 COMPILER V9.00 MAIN 02/08/2010 20:58:31 PAGE 2
55 1
56 1 PORT_Init();
57 1 //UART0_Init();
58 1
59 1 Timer0_Init();
60 1 Timer2_Init();
61 1
62 1
63 1 timer_set(&periodic_timer, CLOCK_CONF_SECOND / 2);
64 1 timer_set(&arp_timer, CLOCK_CONF_SECOND * 10);
65 1 EA=1;
66 1 // init_Timer();
67 1 uip_init();
68 1 app1_init();
69 1 etherdev_init();
70 1 uip_arp_init();
71 1
72 1
73 1
74 1 #ifdef USE_STATIC_IP
75 1 uip_ipaddr(ipaddr, 192,168,0,100);
76 1 uip_sethostaddr(ipaddr);
77 1 uip_ipaddr(ipaddr, 192,168,0,1);
78 1 uip_setdraddr(ipaddr);
79 1 uip_ipaddr(ipaddr, 255,255,255,0);
80 1 uip_setnetmask(ipaddr);
81 1
82 1 #endif
83 1
84 1
85 1 httpd_init();
86 1
87 1 sTempAddr.addr[0] = my_hwaddr[0];
88 1 sTempAddr.addr[1] = my_hwaddr[1];
89 1 sTempAddr.addr[2] = my_hwaddr[2];
90 1 sTempAddr.addr[3] = my_hwaddr[3];
91 1 sTempAddr.addr[4] = my_hwaddr[4];
92 1 sTempAddr.addr[5] = my_hwaddr[5];
93 1 #ifndef USE_STATIC_IP
//
// Initialize the DHCP Client Application.
//
dhcpc_init(&sTempAddr.addr[0], 6);
dhcpc_request();
#endif
100 1
101 1
102 1
103 1 /* by gjk read flash128byte ip,subnet,gateway,port*/
104 1
105 1 flash_Pageerase(0x0000,1);
106 1
107 1 Delay1ms(100);
108 1
109 1 flash_write(0x0000,cdbuf,1);
110 1
111 1 Delay1ms(100);
112 1
113 1 Delay1ms(100);
114 1 flash_read(0x0000,cdbuf,1);
115 1
116 1 while(1)
C51 COMPILER V9.00 MAIN 02/08/2010 20:58:31 PAGE 3
117 1 {
118 2 uip_len = etherdev_read();
119 2 if(uip_len > 0)
120 2 {
121 3 if(BUF->type == htons(UIP_ETHTYPE_IP))
122 3 {
123 4 uip_arp_ipin();
124 4 uip_input();
125 4 /* If the above function invocation resulted in data that
126 4 should be sent out on the network, the global variable
127 4 uip_len is set to a value > 0. */
128 4 if(uip_len > 0)
129 4 {
130 5 uip_arp_out();
131 5 etherdev_send();
132 5 }
133 4 }
134 3 else if(BUF->type == htons(UIP_ETHTYPE_ARP)) {
135 4 uip_arp_arpin();
136 4 /* If the above function invocation resulted in data that
137 4 should be sent out on the network, the global variable
138 4 uip_len is set to a value > 0. */
139 4 if(uip_len > 0)
140 4 {
141 5 etherdev_send();
142 5 }
143 4 }
144 3 }
145 2 else if(timer_expired(&periodic_timer))
146 2 {
147 3 timer_reset(&periodic_timer);
148 3 for(i = 0; i < UIP_CONNS; i++)
149 3 {
150 4 uip_periodic(i);
151 4 /* If the above function invocation resulted in data that
152 4 should be sent out on the network, the global variable
153 4 uip_len is set to a value > 0. */
154 4 if(uip_len > 0)
155 4 {
156 5 uip_arp_out();
157 5 etherdev_send();
158 5 }
159 4 }
160 3
161 3 #if UIP_UDP
162 3 for(i = 0; i < UIP_UDP_CONNS; i++)
163 3 {
164 4 uip_udp_periodic(i);
165 4 /* If the above function invocation resulted in data that
166 4 should be sent out on the network, the global variable
167 4 uip_len is set to a value > 0. */
168 4 if(uip_len > 0)
169 4 {
170 5 uip_arp_out();
171 5 etherdev_send();
172 5 }
173 4 }
174 3 #endif /* UIP_UDP */
175 3
176 3 /* Call the ARP timer function every 10 seconds. */
177 3 if(timer_expired(&arp_timer))
178 3 {
C51 COMPILER V9.00 MAIN 02/08/2010 20:58:31 PAGE 4
179 4 timer_reset(&arp_timer);
180 4 uip_arp_timer();
181 4 }
182 3 }
183 2 }
184 1 return;
185 1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -