📄 isr.lst
字号:
C51 COMPILER V7.09 ISR 10/13/2004 19:54:16 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE ISR
OBJECT MODULE PLACED IN Isr.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE Isr.c OMF2 OPTIMIZE(2,SPEED) DEBUG
line level source
1 /*
2 //*************************************************************************
3 //
4 // ZLGMCU
5 // www.zlgmcu.com
6 // File Name: isr.C
7 // Revision: 0.4(2002-07-08)
8 // Author: Liu Ying Bin
9 // Use library: USB51S.LIB
10 // Note: USB51S.LIB不带DMA控制功能
11 //*************************************************************************
12 */
13
14
15 #include <stdio.h>
16 #include <string.h>
17 #include <reg51.h> /* special function register declarations */
18 #include "isr.h"
19 #include "mainloop.h"
20 #include "protozlg.h"
21
22 #define uchar unsigned char
23 #define uint unsigned int
24 sbit POWER=P1^0;
25 sbit RAMCS=P1^4;
26 sbit A15=P2^7;
27 sbit PCS=P3^4;
28 sbit JCS=P3^5;
29 sbit A0=P3^0;
30 sbit A1=P3^1;
31 sbit P31=P3^1;
32 sbit P32=P3^2;
33 sbit P33=P3^3;
34 sbit P34=P3^4;
35 sbit P35=P3^5;
36 sbit WRITE=P3^6;
37 sbit READ=P3^7;
38
39 #define MAX_ORDER 5
40
41 /*
42 //*************************************************************************
43 // Public static data
44 //*************************************************************************
45 */
46
47 EPPFLAGS bEPPflags;
48 CONTROL_XFER ControlData;
49 unsigned int data d12_addr;
50 extern byte_count byte_cnt;
51 unsigned int data D12_DATA;
52 unsigned int data D12_COMMAND;
53
54
55 /* ISR static vars */
C51 COMPILER V7.09 ISR 10/13/2004 19:54:16 PAGE 2
56 unsigned char idata GenEpBuf[EP1_PACKET_SIZE];
57 unsigned char idata EpBuf[EP2_PACKET_SIZE];
58 IO_REQUEST idata ioRequest;
59
60 rem_cs();
61 rev_cs();
62
63 //厂商请求入口地址
64 code void (*VendorDeviceRequest[])(void) =
65 {
66 reserved,
67 reserved,
68 reserved,
69 reserved,
70 reserved,
71 reserved,
72 reserved,
73 reserved,
74 reserved,
75 reserved,
76 reserved,
77 reserved,
78 read_write_register,
79 reserved,
80 reserved,
81 reserved
82 };
83
84 //USB总线重新连接(先断开,再连接)子程序
85 void reconnect_USB(void)
86 {
87 1 unsigned long clk_cnt;
88 1
89 1 // D12SUSPD = 0;
90 1 disconnect_USB();
91 1 for (clk_cnt=0;clk_cnt<=0x9000;clk_cnt++) {}
92 1 connect_USB();
93 1 }
94
95 //断开USB总线连接
96 void disconnect_USB(void)
97 {
98 1 D12_SetMode(D12_NOLAZYCLOCK, D12_SETTOONE | D12_CLOCK_12M);
99 1 }
100
101 //连接到USB总线
102 void connect_USB(void)
103 {
104 1 DISABLE;
105 1 bEPPflags.value = 0;
106 1 ENABLE;
107 1 D12_SetDMA(0x0);//设置D12工作模式
108 1 D12_SetMode(D12_NOLAZYCLOCK|D12_SOFTCONNECT, D12_SETTOONE | D12_CLOCK_12M);
109 1 }
110
111 //总线复位服务子程序
112 void D12_busreset(void)
113 {
114 1 //可添加用户代码(进行检测到总线复位的操作)
115 1 }
116
117 //DMA操作结束中断服务子程序
C51 COMPILER V7.09 ISR 10/13/2004 19:54:16 PAGE 3
118 void dma_eot(void)
119 {
120 1 //可添加用户代码(进行检测DMA操作结束的操作)
121 1 }
122
123 //D12挂起服务子程序
124 void d12_suspend(void)
125 {
126 1 //可添加用户代码
127 1 }
128
129 //端点1输出中断操作
130 void ep1_txdone(void)
131 {
132 1 unsigned char c0,c1;
133 1
134 1 if (RAMCS == 0)
135 1 c0 = 0;
136 1 else
137 1 c0 = 1;
138 1 if (MCU_D12CS == 0)
139 1 c1 = 0;
140 1 else
141 1 c1 = 1;
142 1 RAMCS = 1;
143 1 MCU_D12CS = 0;
144 1 D12_ReadLastTransactionStatus(3);//复位中断寄存器
145 1 if (c0 == 1)
146 1 RAMCS = 1;
147 1 if (c1 == 1)
148 1 MCU_D12CS = 1;
149 1 if (c0 == 0)
150 1 RAMCS = 0;
151 1 if (c1 == 0)
152 1 MCU_D12CS = 0;
153 1 }
154
155 //端点1输入中断操作
156 void ep1_rxdone(void)
157 {
158 1 unsigned char len;
159 1 unsigned char c0,c1;
160 1
161 1 if (RAMCS == 0)
162 1 c0 = 0;
163 1 else
164 1 c0 = 1;
165 1 if (MCU_D12CS == 0)
166 1 c1 = 0;
167 1 else
168 1 c1 = 1;
169 1 RAMCS = 1;
170 1 MCU_D12CS = 0;
171 1 D12_ReadLastTransactionStatus(2);//复位中断寄存器
172 1 len = D12_ReadEndpoint(2, sizeof(GenEpBuf), GenEpBuf);//读取端点1接收数据
173 1 if (len != 0)
174 1 bEPPflags.bits.ep1_rxdone = 1;//标志端点1接收到数据
175 1 if (c0 == 1)
176 1 RAMCS = 1;
177 1 if (c1 == 1)
178 1 MCU_D12CS = 1;
179 1 if (c0 == 0)
C51 COMPILER V7.09 ISR 10/13/2004 19:54:16 PAGE 4
180 1 RAMCS = 0;
181 1 if (c1 == 0)
182 1 MCU_D12CS = 0;
183 1
184 1 }
185
186 //端点2输出中断操作
187 void ep2_txdone(void)
188 {
189 1 unsigned char c0,c1;
190 1
191 1 if (RAMCS == 0)
192 1 c0 = 0;
193 1 else
194 1 c0 = 1;
195 1 if (MCU_D12CS == 0)
196 1 c1 = 0;
197 1 else
198 1 c1 = 1;
199 1 RAMCS = 1;
200 1 MCU_D12CS = 0;
201 1 D12_ReadLastTransactionStatus(5);//复位中断寄存器
202 1 //可添加用户代码(进行检测端点号5IN令牌的操作)
203 1 if(byte_cnt.word>0)
204 1 {
205 2 if(byte_cnt.word<32)
206 2 {
207 3 D12_WriteEndpoint(5, byte_cnt.byte.low, EpBuf);
208 3 byte_cnt.word=0;
209 3 }
210 2 else
211 2 {
212 3 byte_cnt.word=byte_cnt.word-32;
213 3 D12_WriteEndpoint(5, 32, EpBuf);
214 3 }
215 2 }
216 1 if (c0 == 1)
217 1 RAMCS = 1;
218 1 if (c1 == 1)
219 1 MCU_D12CS = 1;
220 1 if (c0 == 0)
221 1 RAMCS = 0;
222 1 if (c1 == 0)
223 1 MCU_D12CS = 0;
224 1
225 1 }
226
227 //端点2输入中断操作
228 void ep2_rxdone(void)
229 {
230 1 unsigned char len;
231 1 unsigned char c0,c1;
232 1
233 1 if (RAMCS == 0)
234 1 c0 = 0;
235 1 else
236 1 c0 = 1;
237 1 if (MCU_D12CS == 0)
238 1 c1 = 0;
239 1 else
240 1 c1 = 1;
241 1 RAMCS = 1;
C51 COMPILER V7.09 ISR 10/13/2004 19:54:16 PAGE 5
242 1 MCU_D12CS = 0;
243 1 D12_ReadLastTransactionStatus(4);//复位中断寄存器
244 1 len = D12_ReadEndpoint(4, 32, EpBuf);//读取端点2接收数据
245 1 if (bEPPflags.bits.ep2buf_full)
246 1 len = D12_ReadEndpoint(4, 32, EpBuf);//读取端点2接收数据
247 1 if (len != 0)
248 1 bEPPflags.bits.ep2_rxdone = 1;//标志端点2接收到数据
249 1 if (c0 == 1)
250 1 RAMCS = 1;
251 1 if (c1 == 1)
252 1 MCU_D12CS = 1;
253 1 if (c0 == 0)
254 1 RAMCS = 0;
255 1 if (c1 == 0)
256 1 MCU_D12CS = 0;
257 1 }
258
259
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 488 ----
CONSTANT SIZE = 48 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 31 14
IDATA SIZE = 54 ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -