📄 utility.lst
字号:
177 /* Function Name : poll_set_ip *
178 /* *
C51 COMPILER V7.50 UTILITY 10/12/2006 15:31:40 PAGE 4
179 /* Arguments : *
180 /* None *
181 /* *
182 /* Return : *
183 /* None. *
184 /* *
185 /* Comment : *
186 /* This function is the main routine for setting IP,Gateway, *
187 /* Net Mask and MAC by RS232 .It also handle I2C eeprom ISP *
188 /* if I2C_EERROM_WRITER is defined. *
189 /* *
190 /************************************************************************/
191 void poll_set_ip(void)
192 {
193 1 #ifdef RS232_H
194 1 /*Get char from RS232.*/
195 1 while (!RS232_rx_empty())
196 1 {
197 2 g_dc = RS232_rx_getchar();
198 2 #ifdef I2C_EERROM_WRITER
199 2 /*if g_dc not a ASCII char call EEPROM_writer.*/
200 2 if (g_dc&0x80)
201 2 {
202 3 EEPROM_writer(g_dc);
203 3 return ;
204 3 }
205 2 #endif
206 2 #else
/*Get char from RS232.*/
while (SCON&0x1)
{
g_dc = SBUF;
SCON&=0xFE;
#endif
213 2 /*ECHO.*/
214 2 tx_char(g_dc);
215 2
216 2 /*The linebuff have contained one line.*/
217 2 if (g_dc == 0x0d || g_dc==0x0a )
218 2 {
219 3 /*TX LF.*/
220 3 tx_char(0xa);
221 3 linebuf[linebuf_i] = 0;
222 3 linebuf_i = 0xff;
223 3 }
224 2 /*Handle backspace.*/
225 2 else if (g_dc==0x8)
226 2 {
227 3 linebuf_i=linebuf_i>0?linebuf_i-1:0;
228 3 tx_char(0x20);
229 3 tx_char(0x8);
230 3 continue;
231 3 }
232 2 /*Put RX char to linebuf.*/
233 2 else
234 2 {
235 3 linebuf[linebuf_i] = g_dc;
236 3 if (linebuf_i < 30)
237 3 linebuf_i=linebuf_i+1;
238 3 }
239 2 /*The linebuff have contained one line.*/
240 2 if (linebuf_i == 0xff)
C51 COMPILER V7.50 UTILITY 10/12/2006 15:31:40 PAGE 5
241 2 {
242 3 linebuf_i=0;
243 3 /*Parse numbers from linebuf.*/
244 3 g_di = getnumbers(&linebuf[0], &nums[0], 4);
245 3 switch (linebuf[0])
246 3 {
247 4 /*Change IP address command.*/
248 4 case 'i':
249 4 if (g_di == 4)
250 4 {
251 5 tx_char(0x0d);
252 5 tx_char(0x0a);
253 5 c256_bytewrite(I2C_IP_START_ADDR,(unsigned char)nums[0]);
254 5 c256_bytewrite(I2C_IP_START_ADDR+1,(unsigned char)nums[1]);
255 5 c256_bytewrite(I2C_IP_START_ADDR+2,(unsigned char)nums[2]);
256 5 c256_bytewrite(I2C_IP_START_ADDR+3,(unsigned char)nums[3]);
257 5 puts("\nPlease push RESET bottom again to active your IP address\r\n\n");
258 5 }
259 4 break;
260 4 /*Change Gateway IP address command.*/
261 4 case 'g':
262 4 if (g_di == 4)
263 4 {
264 5 tx_char(0x0d);
265 5 tx_char(0x0a);
266 5 c256_bytewrite(I2C_GATEWAY_START_ADDR,(unsigned char)nums[0]);
267 5 c256_bytewrite(I2C_GATEWAY_START_ADDR+1,(unsigned char)nums[1]);
268 5 c256_bytewrite(I2C_GATEWAY_START_ADDR+2,(unsigned char)nums[2]);
269 5 c256_bytewrite(I2C_GATEWAY_START_ADDR+3,(unsigned char)nums[3]);
270 5 puts("\nPlease push RESET bottom again to active your Gateway IP address\r\n\n");
271 5 }
272 4 break;
273 4 /*Change Net Mask command.*/
274 4 case 'n':
275 4 if (g_di == 4)
276 4 {
277 5 tx_char(0x0d);
278 5 tx_char(0x0a);
279 5 c256_bytewrite(I2C_NET_MASK_START_ADDR,(unsigned char)nums[0]);
280 5 c256_bytewrite(I2C_NET_MASK_START_ADDR+1,(unsigned char)nums[1]);
281 5 c256_bytewrite(I2C_NET_MASK_START_ADDR+2,(unsigned char)nums[2]);
282 5 c256_bytewrite(I2C_NET_MASK_START_ADDR+3,(unsigned char)nums[3]);
283 5 puts("\nPlease push RESET bottom again to active your Net Mask\r\n\n");
284 5 }
285 4 break;
286 4 /*Change MAC address command.*/
287 4 case 'M':
288 4 {
289 5 g_di=parse_mac_str(&linebuf[0],&nums[0]);
290 5 if (g_di == 6)
291 5 {
292 6 tx_char(0x0d);
293 6 tx_char(0x0a);
294 6 c256_bytewrite(I2C_MAC_START_ADDR,(unsigned char)nums[0]);
295 6 c256_bytewrite(I2C_MAC_START_ADDR+1,(unsigned char)nums[1]);
296 6 c256_bytewrite(I2C_MAC_START_ADDR+2,(unsigned char)nums[2]);
297 6 c256_bytewrite(I2C_MAC_START_ADDR+3,(unsigned char)nums[3]);
298 6 c256_bytewrite(I2C_MAC_START_ADDR+4,(unsigned char)nums[4]);
299 6 c256_bytewrite(I2C_MAC_START_ADDR+5,(unsigned char)nums[5]);
300 6 puts("\nPlease push RESET bottom again to active your MAC Address\r\n\n");
301 6 }
302 5 else
C51 COMPILER V7.50 UTILITY 10/12/2006 15:31:40 PAGE 6
303 5 puts(error_str);
304 5 }
305 4 break;
306 4 default:
307 4 break;
308 4 }
309 3 }
310 2 }
311 1 return ;
312 1 }
313 /************************************************************************
314 /* Function Name : tx_char *
315 /* *
316 /* Arguments : *
317 /* char c :char to transmit from RS232 *
318 /* *
319 /* Return : *
320 /* None. *
321 /* *
322 /* Comment : *
323 /* This function transmit one char by RS232 directly. *
324 /* *
325 /************************************************************************/
326 #ifndef RS232_H
void tx_char (char c)
{
while (!TI);
TI = 0;
SBUF = c;
}
#else
334 void tx_char (char c) {
335 1 while (!TXFLAG);
336 1 TXFLAG = 0;
337 1 SBUF = c;
338 1 }
339 #endif
340 /************************************************************************
341 /* Function Name : show_menu *
342 /* *
343 /* Arguments : *
344 /* NODE *n :point to NODE (locnode). *
345 /* char eeprom_flag : Set to show menu about setting Ethernet *
346 /* configuration. *
347 /* *
348 /* Return : *
349 /* None. *
350 /* *
351 /* Comment : *
352 /* This function show current settings of NODE *n. *
353 /* *
354 /************************************************************************/
355 void show_menu (NODE *n,char eeprom_flag)
356 {
357 1 //puts(menudata1);
358 1 printf(menudata2);
359 1 show_ip(n);//
360 1 printf(menudata3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -