ct_test/Keil_C/List/Uart1.lst

839 lines
36 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 1
C51 COMPILER V9.59.0.0, COMPILATION OF MODULE UART1
OBJECT MODULE PLACED IN ..\Output\Uart1.obj
COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE ..\Apps\Uart1.c LARGE OBJECTADVANCED OPTIMIZE(8,SIZE) BROWSE INCDIR(..\F
-WLib\SC92F_Lib\inc;..\User;..\Apps;..\Apps;..\User) DEFINE(SC92F836xB) DEBUG PRINT(..\List\Uart1.lst) OBJECT(..\Output\U
-art1.obj)
line level source
1 /********************************Copyright (c)**********************************\
2 **
3 ** (c) Copyright 2019, China, JS.
4 ** All Rights Reserved
5 **
6 **
7 **----------------------------------文件信息------------------------------------
8 ** 文件名称: ttl_usart.c
9 ** 创建日期: 2022-05-11
10 ** 文档描述: ttl_usart
11 **
12 **----------------------------------版本信息------------------------------------
13 ** 版本代号: V0.1
14 ** 版本说明: 初始版本
15 **
16 ********************************End of Head************************************/
17
18 /* Includes ------------------------------------------------------------------*/
19
20 /**
21 * @file uart.c
22 * @author Nations
23 * @version v1.0.0
24 *
25 * @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
26 */
27
28 #include <stdio.h>
29
30
31 #include "SC_Init.h" //MCU Init headerInclude all IC resource headers
32 #include "SC_it.h"
33 #include "..\Drivers\SCDriver_list.h"
34 #include "HeadFiles\SysFunVarDefine.h"
35
36 #include "Uart1.h"
37 #include "Motor.h"
38
39 //微秒延时
40 void DelayUs(unsigned int delay)
41 {
42 1 unsigned int i = 0, j = 0;
43 1 for(i = 0; i < delay; i++)
44 1 {
45 2 for(j = 0; j < 125; j++);
46 2 }
47 1 }
48
49 //毫秒延时
50 void DelayMs(unsigned int delay)
51 {
52 1 unsigned int i = 0;
53 1 for(i = 0; i < delay; i++)
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 2
54 1 {
55 2 DelayUs(1000);
56 2 }
57 1 }
58
59 #define HD_VER 0001 //硬件版本
60 #define SW_VER 0001 //软件版本
61
62 #define TTL_SEND_BUFF_LEN 60 //发送数据长度
63 #define TTL_RECEIVE_BUFF_LEN 60 //接收数据长度
64
65 //----------------------------------------------------------------
66 //uart1用于接收usb转ttl的串口
67 //----------------------------------------------------------------
68
69 //存放发送的数据内容
70 uint8_t xdata motor_data[10];
71
72 //发送buff
73 uint8_t xdata ttl_send_len = 0;
74 uint8_t xdata ttl_send_buff[TTL_SEND_BUFF_LEN] = {0};
75
76 //接收buff
77 uint8_t xdata ttl_receive_len = 0;
78 uint8_t xdata ttl_receive_buff[TTL_RECEIVE_BUFF_LEN] = {0};
79
80 //接收超时
81 uint8_t xdata ttl_receive_flag = 0;
82 uint8_t xdata ttl_receive_cnt = 0;
83 uint8_t xdata ttl_receive_interval = 0;
84
85 #define DATA_LEN TTL_RECEIVE_BUFF_LEN //一般数据长度
86 #define UART_ORDER_SOF 0x05 //起始字
87 #define UART_ORDER_END 0x1B //结束字
88 #define FIXED_LEN 0x0B //固定长度 //取消RW
89
90 uint16_t xdata SUR_DEVICE_ADDR = 0x00A1; //PC //0x00A1; //设备
91 uint16_t xdata OBJ_DEVICE_ADDR = 0x00B1; //主板 //0x00B1; //PC群发 FFFF 0000
92
93 uint8_t xdata order_flag = 0;
94 unsigned int xdata checksum = 0, re_status = 0, rec_len = 0, data_len = 0, shouldaccept = 0;
95
96 //单独发送
97 void UART1_SendData(uint8_t dat)
98 {
99 1 SSI_UART1_SendData8(dat);
100 1 }
101
102 //发送数据
103 void UART1_Send_Char(uint8_t dat)
104 {
105 1 SSI_UART1_SendData8(dat);
106 1 }
107
108 //初始化
109 void InitUart_Data(void)
110 {
111 1 order_flag = 0;
112 1 rec_len = 0;
113 1 re_status = 0;
114 1 shouldaccept = 0;
115 1
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 3
116 1 ttl_receive_flag = 0;
117 1 ttl_receive_cnt = 0;
118 1
119 1 checksum = 0;
120 1
121 1 for(data_len = 0; data_len < DATA_LEN; data_len++)
122 1 {
123 2 ttl_receive_buff[data_len] = 0;
124 2 }
125 1
126 1 data_len = 0;
127 1
128 1 // UART_Send_Char(0xdd);
129 1 }
130
131
132
133 /* Private function prototypes -----------------------------------------------*/
134 /* Private functions ---------------------------------------------------------*/
135 //----------------------------------------------------------------
136 //接收串口1
137 //----------------------------------------------------------------
138 /****************************************************************************************************
139 * @brief Download a file via serial port
140 * @param None
141 * @retval None
142 **************************************************************************************************/
143 void start_ttl_receive_timer(uint32_t ms)
144 {
145 1 if(ms == 0)
146 1 {
147 2 return;
148 2 }
149 1
150 1 ttl_receive_flag = 1;
151 1 ttl_receive_cnt = 0;
152 1 ttl_receive_interval = ms;
153 1 }
154
155 /****************************************************************************************************
156 * @brief Upload a file via serial port.
157 * @param None
158 * @retval None
159 **************************************************************************************************/
160 void over_ttl_receive_timer(void)
161 {
162 1 ttl_receive_flag = 0;
163 1 ttl_receive_cnt = 0;
164 1 ttl_receive_interval = 0;
165 1
166 1 InitUart_Data();
167 1
168 1 // UART2_Send_Char(0xed);
169 1 }
170
171 /****************************************************************************************************
172 * @brief Display the Main Menu on HyperTerminal
173 * @param None
174 * @retval None
175 **************************************************************************************************/
176 void clear_ttl_receive_timer(void)
177 {
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 4
178 1 uint16_t i = 0;
179 1 ttl_receive_len = 0;
180 1 ttl_receive_flag = 0;
181 1 ttl_receive_cnt = 0;
182 1 ttl_receive_interval = 0;
183 1
184 1 for(i = 0; i < TTL_RECEIVE_BUFF_LEN; i++)
185 1 {
186 2 ttl_receive_buff[i] = 0;
187 2 }
188 1 }
189
190 //返回串口屏应答是否接收完成的结果
191 //0没超时 1超时
192 uint8_t judge_ttl_receive_timer(void)
193 {
194 1 if(ttl_receive_flag == 2)
195 1 {
196 2 return 1;
197 2 }
198 1 else
199 1 {
200 2 return 0;
201 2 }
202 1 }
203
204 /****************************************************************************************************
205 * @brief Display the Main Menu on HyperTerminal
206 * @param None
207 * @retval None
208 **************************************************************************************************/
209 //放在大循环中的计时器里
210 void process_ttl_receive_timer(void)
211 {
212 1 if(ttl_receive_flag == 1)
213 1 {
214 2 ttl_receive_cnt++;
215 2 }
216 1
217 1 if((ttl_receive_interval > 0) && (ttl_receive_cnt >= ttl_receive_interval))
218 1 {
219 2 over_ttl_receive_timer();
220 2 }
221 1 }
222
223 #define TTL_OVER_TIME 10
224 /****************************************************************************************************
225 * @brief Display the Main Menu on HyperTerminal
226 * @param None
227 * @retval None
228 **************************************************************************************************/
229 //放串口中断内,接收数据
230 void receive_ttl_data(uint8_t rx_data)
231 {
232 1 //不能超过数组的最大长度
233 1 if(ttl_receive_len < TTL_RECEIVE_BUFF_LEN)
234 1 {
235 2 //开始计时
236 2 start_ttl_receive_timer(TTL_OVER_TIME);
237 2
238 2 //串口接收数据分析
239 2 Do_Receive_Uart_For_Module(rx_data);
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 5
240 2 }
241 1 else //超过上限则抛弃后面的数据
242 1 {
243 2 //超时处理
244 2 over_ttl_receive_timer();
245 2
246 2 InitUart_Data();
247 2
248 2 //UART_Send_Char(0xcc);
249 2 }
250 1 }
251
252 #define CRC_PRESET 0xFFFF
253 #define CRC_POLYNOM 0x4204
254 /*---------------------------------------------------------------------------
255 调用方式unsigned int ModbusCRC16(unsigned char *data_value, unsigned char length)
256 函数说明CRC校验
257 ---------------------------------------------------------------------------*/
258 unsigned int ModbusCRC16(unsigned char *data_value, unsigned char length)
259 {
260 1 unsigned int crc_value = CRC_PRESET;
261 1 unsigned char i;
262 1 data_value++;
263 1 while(length-- != 0)
264 1 {//ModbusCRC16(PData, Num + FIXED_LEN - 3);
265 2 for(i = 0x01; i != 0; i <<= 1)
266 2 {
267 3 if((crc_value & 0x0001) != 0)
268 3 {
269 4 crc_value >>= 1;
270 4 crc_value ^= CRC_POLYNOM;
271 4 }
272 3 else
273 3 {
274 4 crc_value >>= 1;
275 4 }
276 3
277 3 if((*data_value & i) != 0)
278 3 {
279 4 crc_value ^= CRC_POLYNOM;
280 4 }
281 3 }
282 2 data_value++;
283 2 }
284 1 return(crc_value);
285 1 }
286
287 /*---------------------------------------------------------------------------
288 调用方式unsigned int VerfiyRC(unsigned char *data_value, unsigned char length)
289 函数说明:异或校验
290 除了头尾固定,不校验外,其他的校验
291 -----------------------------------------------------------------------------*/
292 unsigned char VerfiyRC(unsigned char data_value[], unsigned char length) //不用异或校验用crc校验
293 {
294 1 unsigned char i;
295 1 unsigned char V_b = data_value[1];
296 1
297 1 for(i = 0x00; i < length; i++)
298 1 {
299 2 //异或校验
300 2 V_b ^= data_value[i];
301 2 }
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 6
302 1
303 1 return(V_b);
304 1 }
305
306 //发送延时
307 void Uart_Send_Delay(unsigned int delay)
308 {
309 1 unsigned int i = 0, j = 0;
310 1
311 1 for(i = 0; i < delay; i++)
312 1 {
313 2 for(j = 0; j < 125; j++);
314 2 }
315 1 }
316
317 //校验 + 0X1B
318 #define VERFIY_TYPE 0
319
320 /*
321 SOF 1个字节 0x05 起始字节
322 Len 2个字节 长度
323 Fou_adr 2个字节 源地址
324 Com_adr 2个字节 目标地址0ff为广播地址
325 Cmd16 2个字节 命令字
326 Request-data N字节 数据
327 XOR 2个字节 校验
328 END 0x1B 结束字节
329 */
330
331 //发送数据
332 void send_set_resp(unsigned int OrderNum, unsigned int addr, unsigned char Num, unsigned char sData[])
333 {
334 1 unsigned int xdata xor_data = 0;
335 1 unsigned char xdata PData[TTL_SEND_BUFF_LEN];
336 1 unsigned char xdata i = 0;
337 1
338 1 PData[0] = UART_ORDER_SOF; //第一个字节
339 1 PData[1] = (Num + FIXED_LEN) / 0x100; //长度 高8位
340 1 PData[2] = (Num + FIXED_LEN) % 0x100; //长度 低8位
341 1 PData[3] = (addr >> 8) & 0xff; //源地址
342 1 PData[4] = addr & 0xff; //源地址
343 1 PData[5] = (SUR_DEVICE_ADDR >> 8) & 0xff; //目标地址
344 1 PData[6] = SUR_DEVICE_ADDR & 0xff; //目标地址
345 1 PData[7] = (OrderNum >> 8) & 0xff; //命令字 -1
346 1 PData[8] = OrderNum & 0xff; //命令字 -2
347 1
348 1 // PData[6] = RW_Flag; //读写标志
349 1
350 1 for(i = 0; i < Num; i++) //发送数据
351 1 {
352 2 PData[FIXED_LEN - 2 + i] = sData[i]; //数据
353 2 }
354 1
355 1 //校验
356 1 if(VERFIY_TYPE) //异或校验 + 末尾字节 2字节
357 1 {
358 2 xor_data = VerfiyRC(PData, Num + FIXED_LEN - 2);
359 2 PData[FIXED_LEN + Num - 2] = xor_data;
360 2 PData[FIXED_LEN + Num - 1] = 00;
361 2 }
362 1 else //CRC校验 2字节
363 1 {
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 7
364 2 xor_data = ModbusCRC16(PData, Num + FIXED_LEN - 3);
365 2 PData[FIXED_LEN + Num - 2] = (xor_data) & 0xff;
366 2 PData[FIXED_LEN + Num - 1] = (xor_data >> 8) & 0xff;
367 2 }
368 1
369 1 PData[FIXED_LEN + Num] = UART_ORDER_END; // 末尾字节
370 1
371 1 //全部发送
372 1 for(i = 0; i < (Num + FIXED_LEN + 1); i++) //一次性发送所有数据
373 1 {
374 2 UART1_Send_Char(PData[i]);
375 2 //增加延时
376 2 Uart_Send_Delay(50);
377 2 }
378 1 }
379
380
381
382 //分析地址是否为本地址
383 uint8_t Check_Resive_Addr(uint16_t addr)
384 {
385 1 //确定是否为接收地址
386 1 if((OBJ_DEVICE_ADDR == addr) || (0xFFFF == addr) || (0x0000 == addr) || (0x00B1 == addr))
387 1 {
388 2 return 1;
389 2 }
390 1 else
391 1 {
392 2 InitUart_Data(); //2清数据
393 2 return 0;
394 2 }
395 1 }
396
397
398 //接收数据判断(放置串口接收数据内)
399 void Do_Receive_Uart_For_Module(unsigned char ch)
400 {
401 1 switch(re_status)
402 1 {
403 2 case 0 : //0x05 1字节 起始字
404 2 {
405 3 if(ch == UART_ORDER_SOF)
406 3 {
407 4 rec_len = 0;
408 4 ttl_receive_buff[rec_len] = ch;
409 4 re_status = 1;
410 4 shouldaccept = 0;
411 4 // UART2_Send_Char(0xaa);
412 4 }
413 3 }
414 2 break;
415 2 case 1: //长度 2字节
416 2 {
417 3 rec_len++;
418 3 ttl_receive_buff[rec_len] = ch;
419 3
420 3 if(rec_len >= 2)
421 3 {
422 4 re_status = 2;
423 4 shouldaccept = ttl_receive_buff[1] * 0x100 + ttl_receive_buff[2];
424 4
425 4 if(shouldaccept >= TTL_RECEIVE_BUFF_LEN - 1)
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 8
426 4 {
427 5 InitUart_Data();
428 5 return;
429 5 }
430 4 }
431 3 }
432 2 break;
433 2 case 2: //命令字 2个字节 05 00 0B 00 C1 00 A1 F0 01 87 1B
434 2 {
435 3 rec_len++;
436 3
437 3 if(rec_len >= TTL_RECEIVE_BUFF_LEN - 1)
438 3 {
439 4 InitUart_Data();
440 4 return;
441 4 }
442 3
443 3 ttl_receive_buff[rec_len] = ch; //接收
444 3
445 3 if(rec_len >= shouldaccept) //判断是否接收完成
446 3 {
447 4 // uint8_t i = 0;
448 4 // UART2_Send_Char(0x30);
449 4 // UART2_Send_Char(rec_len);
450 4 // UART2_Send_Char(shouldaccept);
451 4 // UART2_Send_Char(FIXED_LEN - 1);
452 4
453 4 // UART2_Send_Char(rec_len);
454 4 // for( i = 0;i < shouldaccept;i++) UART2_Send_Char(ttl_receive_buff[i]);
455 4
456 4 //等待处理分析,至少要大于固定长度
457 4 // if(rec_len >= FIXED_LEN - 1)
458 4 // {
459 4 //判断接收目标地址是否是自己
460 4 // int adr = ttl_receive_buff[3];
461 4 // adr = adr << 8;
462 4 // adr |= ttl_receive_buff[4];
463 4 int adr = ttl_receive_buff[5];
464 4 adr = adr << 8;
465 4 adr |= ttl_receive_buff[6];
466 4
467 4 //UART2_TxByte(0xAA);
468 4 //UART2_TxByte(ttl_receive_buff[3]);
469 4 //UART2_TxByte(ttl_receive_buff[4]);
470 4 //
471 4 if(Check_Resive_Addr(adr))
472 4 {
473 5 //命令字
474 5 unsigned int order = 0;
475 5 order = ttl_receive_buff[7];
476 5 order = order << 8;
477 5 order += ttl_receive_buff[8];
478 5
479 5 // //目标地址
480 5 // OBJ_DEVICE_ADDR = ttl_receive_buff[3];
481 5 // OBJ_DEVICE_ADDR <<= 8;
482 5 // OBJ_DEVICE_ADDR += ttl_receive_buff[4];
483 5
484 5 //UART2_Send_Char(order / 0x100);
485 5 //UART2_Send_Char(order % 0x100);
486 5 //UART2_TxByte(0xBB);
487 5 //UART2_TxByte(ttl_receive_buff[7]);
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 9
488 5 //UART2_TxByte(ttl_receive_buff[8]);
489 5
490 5 switch(order)
491 5 {
492 6 //=================== ===================================================
493 6 //设备接收数据
494 6 //======================================================================
495 6 case 0xF001 : //解析数据
496 6 {
497 7 order_flag = 1;
498 7 }
499 6 break;
500 6
501 6 case 0xF0C1 : //设置设备加密信息
502 6 {
503 7 order_flag = 2;
504 7 }
505 6 break;
506 6
507 6 //======================================================================
508 6 //设备信息
509 6 //======================================================================
510 6 case 0xF111 : //控制参数
511 6 {
512 7 order_flag = 3;
513 7 // UART2_Send_Char(0x33);
514 7 }
515 6 break;
516 6
517 6 //======================================================================
518 6 //设备信息
519 6 //======================================================================
520 6 case 0xF112 : //读 状态与温度
521 6 {
522 7 order_flag = 4;
523 7 }
524 6 break;
525 6 case 0xF102 : //读 状态与温度
526 6 {
527 7 order_flag = 4;
528 7 }
529 6 break;
530 6
531 6 //======================================================================
532 6 //
533 6 //======================================================================
534 6 default :
535 6 {
536 7 InitUart_Data();
537 7 }
538 6 break;
539 6 }
540 5 }
541 4 else
542 4 {
543 5 InitUart_Data();
544 5 return;
545 5 }
546 4 }
547 3 // }
548 3 }
549 2 break;
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 10
550 2
551 2 default :
552 2 InitUart_Data();
553 2 break;
554 2 }
555 1 }
556
557 //数据长度
558 uint8_t Get_Data_Len(void)
559 {
560 1 uint16_t Re_Len = 0;
561 1 Re_Len = (ttl_receive_buff[1] * 0x100 + ttl_receive_buff[2]) - FIXED_LEN;
562 1 return Re_Len;
563 1 }
564
565 //检查校验
566 unsigned char Check_VerfiyData(void)
567 {
568 1 return 1; //调试期间,不用验证
569 1
570 1 if(VERFIY_TYPE) //异或校验 + 末尾字节
571 1 {
572 2 unsigned char v_A = 0;
573 2 unsigned char v_B = 0;
574 2 v_A = ttl_receive_buff[shouldaccept];
575 2 v_B = VerfiyRC(ttl_receive_buff, shouldaccept - 2);
576 2
577 2 if(v_A == v_B) //数据的完整性
578 2 {
579 3 //结尾数据相同
580 3 if(ttl_receive_buff[shouldaccept + 1] == UART_ORDER_END)
581 3 {
582 4
583 4 }
584 3 else
585 3 {
586 4 return 0;
587 4 }
588 3 }
589 2 else
590 2 {
591 3 return 0;
592 3 }
593 2 }
594 1 else //判断CRC校验
595 1 {
596 2 unsigned int CRC16 = 0;
597 2 unsigned int Get_CRC16 = 0;
598 2 CRC16 = ttl_receive_buff[shouldaccept];
599 2 CRC16 = CRC16 << 8;
600 2 CRC16 += ttl_receive_buff[shouldaccept - 1];
601 2
602 2 Get_CRC16 = ModbusCRC16(ttl_receive_buff, shouldaccept - 2);
603 2
604 2 if(CRC16 == Get_CRC16) //数据的完整性
605 2 {
606 3
607 3 }
608 2 else
609 2 {
610 3 InitUart_Data();
611 3 return 0;
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 11
612 3 }
613 2 }
614 1
615 1 return 1;
616 1 }
617
618
619 //数据接收分析(放置大循环内)
620 void Deal_Uart_Data_For_Module(void)
621 {
622 1 if(order_flag) //有接收的指令
623 1 {
624 2 //校验
625 2 if(Check_VerfiyData() == 1) //测试
626 2 {
627 3 switch(order_flag)
628 3 {
629 4 //--------------------------------------------------------------------
630 4 //
631 4 //--------------------------------------------------------------------
632 4 case 1 : //数据解析
633 4 {
634 5 uint8_t xdata i = 0; //临时变量
635 5 uint8_t xdata len = 0; //长度
636 5 uint8_t xdata temp[DATA_LEN];
637 5
638 5 //发送标志
639 5 send_flag = 0;
640 5
641 5 //数据长度
642 5 len = Get_Data_Len();
643 5
644 5 //解析数据
645 5 for(i = 0; i < len; i++)
646 5 {
647 6 temp[i] = ttl_receive_buff[i + FIXED_LEN - 2];
648 6 }
649 5
650 5 //角行程 、直行程
651 5 Travle_Flag = temp[0]; //0 直 1 角
652 5 Motor_Run = temp[1]; //0 停止 1 运行 2 运行到起始点 3 运行到结束点
653 5 Run_Mode = temp[2]; //0 点动 1 方案一 2 方案二
654 5
655 5 Run_Step = temp[3]; //电机运行多少圈为一个步长
656 5 Run_Step <<= 8;
657 5 Run_Step += temp[4];
658 5
659 5 Run_Inter = temp[5]; //电机运行间隔时长
660 5 Run_Inter <<= 8;
661 5 Run_Inter += temp[6];
662 5
663 5 Run_Stop = temp[7]; //到“结束点”后,停止时间
664 5 Run_Stop <<= 8;
665 5 Run_Stop += temp[8];
666 5
667 5 ClrRunmotorStep();//清除电机标记
668 5
669 5 }
670 4 break;
671 4
672 4 case 2 : //
673 4 {
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 12
674 5 uint8_t i = 0;
675 5 uint8_t len = 0;
676 5 uint8_t temp[DATA_LEN];
677 5
678 5 send_set_resp(0xF0C1, OBJ_DEVICE_ADDR, len, temp);
679 5
680 5 }
681 4 break;
682 4
683 4 //--------------------------------------------------------------------
684 4 //LED 控制
685 4 //--------------------------------------------------------------------
686 4 case 3 : //F111 05 00 0C 00 A1 00 C1 F1 01 05 03 50 87 1B
687 4 {
688 5 u8 addr = 0;
689 5 addr = ttl_receive_buff[FIXED_LEN - 2];
690 5 if(addr == ((SUR_DEVICE_ADDR & 0xf0) == 0xC0))
691 5 {
692 6
693 6 }
694 5 }
695 4 break;
696 4
697 4 //======================================================================
698 4 //
699 4 //======================================================================
700 4 case 4 : //
701 4 {
702 5
703 5
704 5 }
705 4 break;
706 4
707 4 //--------------------------------------------------------------------
708 4 //实时信息
709 4 //--------------------------------------------------------------------
710 4 case 5 : //
711 4 {
712 5 uint8_t len = 0;
713 5 uint8_t temp[DATA_LEN];
714 5
715 5
716 5
717 5 temp[0] = (SUR_DEVICE_ADDR >> 8) & 0xff;
718 5 temp[1] = (SUR_DEVICE_ADDR >> 0) & 0xff;
719 5
720 5 // //版本号 4
721 5 temp[2] = HD_VER >> 8; //HD_VER 0101 //硬件版本号
722 5 temp[3] = HD_VER & 0xff;
723 5
724 5 temp[4] = SW_VER >> 8; //SW_VER 0101 //软件版本号
725 5 temp[5] = SW_VER & 0xff;
726 5
727 5 len = 6;
728 5 send_set_resp(0xF113, OBJ_DEVICE_ADDR, len, temp);
729 5 }
730 4 break;
731 4 case 6 : // 设置 地址 + 版本号 F1D3 05 00 0D 00 A1 00 00 F1 D3 00 C1 07 A9 1B
732 4 {
733 5
734 5 uint8_t i = 0;
735 5 uint8_t len = 0;
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 13
736 5 uint8_t temp[DATA_LEN];
737 5
738 5 //数据长度
739 5 len = Get_Data_Len();
740 5
741 5 for(i = 0; i < len; i++)
742 5 {
743 6 temp[i] = ttl_receive_buff[i + FIXED_LEN - 2];
744 6 }
745 5
746 5
747 5 send_set_resp(0xF1C3, OBJ_DEVICE_ADDR, len, temp);
748 5 }
749 4 break;
750 4 case 7 : //更新程序
751 4 {
752 5
753 5 }
754 4 break;
755 4
756 4 //--------------------------------------------------------------------
757 4 //设备信息
758 4 //--------------------------------------------------------------------
759 4 case 10 : //F115 05 00 0A 00 C1 00 A1 F1 05 50 87 1B
760 4 {
761 5
762 5
763 5 }
764 4 break;
765 4
766 4
767 4 default :
768 4 {
769 5
770 5 }
771 4 break;
772 4 }
773 3 }
774 2
775 2 //清空数据
776 2 InitUart_Data();
777 2 }
778 1 }
779
780
*** WARNING C294 IN LINE 358 OF ..\Apps\Uart1.c: unreachable code
*** WARNING C294 IN LINE 572 OF ..\Apps\Uart1.c: unreachable code
*** WARNING C294 IN LINE 596 OF ..\Apps\Uart1.c: unreachable code
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1870 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 150 154
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
C51 COMPILER V9.59.0.0 UART1 01/18/2024 10:03:11 PAGE 14
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 3 WARNING(S), 0 ERROR(S)