pcc.lst
来自「STC51系列的源码」· LST 代码 · 共 229 行
LST
229 行
C51 COMPILER V8.02 PCC 09/25/2008 20:18:48 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE PCC
OBJECT MODULE PLACED IN .\PCC.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\PCC\PCC.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\PCC.lst) OBJECT(.\PCC.
-obj)
line level source
1 /********************************************************************************/
2 /* filename : PCC.c */
3 /* created : xillinx */
4 /* descript : 与计算机通讯的定义和处理 */
5 /********************************************************************************/
6 #include "../CPU/CPU.h"
7 #include "../CFG/CFG.h"
8 #include "../UART/UART.h"
9 #include "../PCC/PCC.h"
10
11
12 pcc_hook_function pcc_hook_process=PCC_hook_null;
13 unsigned char pcc_mdata[0x20];
14 unsigned char pcc_len;
15
16 /********************************************************************************/
17 /* function : PCC_send_mdata() */
18 /* created : hw-chen */
19 /* descript : 通过UART向计算机方式数据 */
20 /********************************************************************************/
21 void PCC_hook_null(unsigned char * mdata, unsigned char length)
22 { mdata =mdata;
23 1 length=length;
24 1 }
25
26 /********************************************************************************/
27 /* function : PCC_send_mdata() */
28 /* created : hw-chen */
29 /* descript : 通过UART向计算机方式数据 */
30 /********************************************************************************/
31 unsigned char PCC_send_mdata(unsigned char type, unsigned char * mdata, unsigned char length)
32 { unsigned char i;
33 1 ES=0x0;
34 1
35 1 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd) //* 缓冲区已经满了
36 1 { goto out_proc;
37 2 }
38 1 UART_send_buffer[uart_xmit_wr]=0xFE;
39 1 uart_xmit_wr++;
40 1 uart_xmit_wr&=UART_SEND_BUF_MSK;
41 1
42 1 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd) //* 缓冲区已经满了
43 1 { goto out_proc;
44 2 }
45 1 UART_send_buffer[uart_xmit_wr]=type;
46 1 uart_xmit_wr++;
47 1 uart_xmit_wr&=UART_SEND_BUF_MSK;
48 1
49 1 for(i=0x0;i<length;i++)
50 1 { switch(mdata[i])
51 2 {
52 3 case 0xFF:
53 3 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd) //* 缓冲区已经满了
54 3 { goto out_proc;
C51 COMPILER V8.02 PCC 09/25/2008 20:18:48 PAGE 2
55 4 }
56 3 UART_send_buffer[uart_xmit_wr]=0xFD;
57 3 uart_xmit_wr++;
58 3 uart_xmit_wr&=UART_SEND_BUF_MSK;
59 3
60 3 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd)
61 3 { goto out_proc;
62 4 }
63 3 UART_send_buffer[uart_xmit_wr]=0x2;
64 3 uart_xmit_wr++;
65 3 uart_xmit_wr&=UART_SEND_BUF_MSK;
66 3 break;
67 3 case 0xFE:
68 3 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd)
69 3 { goto out_proc;
70 4 }
71 3 UART_send_buffer[uart_xmit_wr]=0xFD;
72 3 uart_xmit_wr++;
73 3 uart_xmit_wr&=UART_SEND_BUF_MSK;
74 3
75 3 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd)
76 3 { goto out_proc;
77 4 }
78 3 UART_send_buffer[uart_xmit_wr]=0x1;
79 3 uart_xmit_wr++;
80 3 uart_xmit_wr&=UART_SEND_BUF_MSK;
81 3 break;
82 3 case 0xFD:
83 3 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd)
84 3 { goto out_proc;
85 4 }
86 3 UART_send_buffer[uart_xmit_wr]=0xFD;
87 3 uart_xmit_wr++;
88 3 uart_xmit_wr&=UART_SEND_BUF_MSK;
89 3
90 3 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd)
91 3 { goto out_proc;
92 4 }
93 3 UART_send_buffer[uart_xmit_wr]=0x0;
94 3 uart_xmit_wr++;
95 3 uart_xmit_wr&=UART_SEND_BUF_MSK;
96 3 break;
97 3 default:
98 3 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd)
99 3 { goto out_proc;
100 4 }
101 3 UART_send_buffer[uart_xmit_wr]=mdata[i];
102 3 uart_xmit_wr++;
103 3 uart_xmit_wr&=UART_SEND_BUF_MSK;
104 3 break;
105 3 }
106 2 }
107 1 if(((uart_xmit_wr+0x1)&UART_SEND_BUF_MSK)==uart_xmit_rd) //* 缓冲区已经满了
108 1 { goto out_proc;
109 2 }
110 1 UART_send_buffer[uart_xmit_wr]=0xFF;
111 1 uart_xmit_wr++;
112 1 uart_xmit_wr&=UART_SEND_BUF_MSK;
113 1 out_proc:
114 1 if(uart_xmit_start==0x0) //* 如果需要启动发生,就启动
115 1 { uart_xmit_start=0x1;
116 2 TI=1;
C51 COMPILER V8.02 PCC 09/25/2008 20:18:48 PAGE 3
117 2 ES=0x1;
118 2 }
119 1 else
120 1 { ES=0x1;
121 2 }
122 1 return i;
123 1 }
124
125
126 /********************************************************************************/
127 /* function : PCC_recv_mdata() */
128 /* created : hw-chen */
129 /* descript : 接收处理计算机发送过来的数据 */
130 /********************************************************************************/
131 void PCC_recv_mdata(void)
132 { unsigned char find=0x0;
133 1 unsigned char rd_2;
134 1 if(uart_recv_start==0x0)
135 1 { return;
136 2 }
137 1 if(uart_recv_rd==uart_recv_wr)
138 1 { uart_recv_start=0x0;
139 2 return;
140 2 }
141 1
142 1 //* 处理头部,如果第一字节不为0xFE头,丢弃数据,直到找到头部或者数据完毕
143 1 while(uart_recv_rd!=uart_recv_wr)
144 1 { if(UART_recv_buffer[uart_recv_rd]==0xFE)
145 2 { break;
146 3 }
147 2 uart_recv_rd++;
148 2 uart_recv_rd&=UART_RECV_BUF_MSK;
149 2 }
150 1 //* 已经没有数据了
151 1 if(uart_recv_rd==uart_recv_wr)
152 1 { uart_recv_start=0x0;
153 2 return;
154 2 }
155 1 //* 找尾部
156 1 rd_2=uart_recv_rd;
157 1 while(rd_2!=uart_recv_wr)
158 1 { if(UART_recv_buffer[rd_2]==0xFF)
159 2 { find=0x1;
160 3 break;
161 3 }
162 2 rd_2++;
163 2 rd_2&=UART_RECV_BUF_MSK;
164 2 }
165 1 //* 如果缓冲区已经满了,还没有找到尾部
166 1 if((((uart_recv_wr+0x1)&UART_RECV_BUF_MSK)==uart_recv_rd)&&(find==0x0))
167 1 { uart_recv_start=0x0;
168 2 uart_recv_wr=0x0;
169 2 uart_recv_rd=0x0;
170 2 return;
171 2 }
172 1 if(find==0x0)
173 1 { return;
174 2 }
175 1 //* 丢弃头部
176 1 uart_recv_rd++;
177 1 uart_recv_rd&=UART_RECV_BUF_MSK;
178 1
C51 COMPILER V8.02 PCC 09/25/2008 20:18:48 PAGE 4
179 1 //* 读取数据
180 1 pcc_len=0x0;
181 1 while(uart_recv_rd!=uart_recv_wr)
182 1 { if(UART_recv_buffer[uart_recv_rd]==0xFF)
183 2 { break;
184 3 }
185 2 pcc_mdata[pcc_len++]=UART_recv_buffer[uart_recv_rd];
186 2 uart_recv_rd++;
187 2 uart_recv_rd&=UART_RECV_BUF_MSK;
188 2 }
189 1
190 1 //* 丢弃尾部
191 1 uart_recv_rd++;
192 1 uart_recv_rd&=UART_RECV_BUF_MSK;
193 1
194 1 //* 调用HOOK函数
195 1 pcc_hook_process(&pcc_mdata[0x0],pcc_len);
196 1
197 1 return;
198 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1022 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 36 6
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?