📄 usb_rs232.lst
字号:
C51 COMPILER V6.14 USB_RS232 04/03/2003 10:41:10 PAGE 1
C51 COMPILER V6.14, COMPILATION OF MODULE USB_RS232
OBJECT MODULE PLACED IN .\USB_RS232.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\USB_RS232.C DEBUG OBJECTEXTEND
stmt level source
1 #pragma NOIV
2
3 #include <ezusb.h>
4 #include <ezregs.h>
5 #include <fx.h>
6
7 extern BOOL GotSUD; // Received setup data flag
8 extern BOOL Sleep;
9 extern BOOL Rwuen;
10 extern BOOL Selfpwr;
11 //+++++++++++++++++
12
13 #define P2 OUTC
14
15 //+++++++++++++++++
16
17
18 BYTE Configuration; // Current configuration
19 BYTE AlternateSetting; // Alternate settings
20 BYTE suspCount;
21 BYTE uartflag=1;
22
23
24
25
26
27 BYTE InReportBytes;
28 void *dscr_ptr;
29
30
31 void TD_Init(void) // Called once at startup
32 {
33 1
34 1
35 1
36 1 PORTCCFG = 0x03; // OUTPUT
37 1 OEC = 0x00;
38 1 PORTCCFG |= 0x03; // using SIO-0, TxD0 & RxD0 pins
39 1 RCAP2H = TH2 = 0xFF; // auto-reload for 9600 baud
40 1 RCAP2L = TL2 = 0xB2; // auto-reload for 9600 baud
41 1 T2CON = 0x34; // clk overflow, start timer2 ticks
42 1 SCON0 |= 0x52; // mode1, rx enable, set TI0
43 1
44 1
45 1 IN07VAL |= bmEP2 ;
46 1 OUT07VAL |= bmEP2;
47 1
48 1
49 1 OUT07IEN |= bmEP2;
50 1
51 1 IN07IEN |= bmEP2;
52 1
53 1
54 1
55 1 suspCount = 1;
C51 COMPILER V6.14 USB_RS232 04/03/2003 10:41:10 PAGE 2
56 1
57 1
58 1
59 1 Rwuen = TRUE; // Enable remote-wakeup
60 1 }
61
62 void TD_Poll(void) // Called repeatedly while the device is idle
63 {
64 1
65 1 }
66
67 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
68 {
69 1 return(TRUE);
70 1 }
71
72 BOOL TD_Resume(void) // Called after the device resumes
73 {
74 1 return(TRUE);
75 1 }
76
77 //-----------------------------------------------------------------------------
78 // Device Request hooks
79 // The following hooks are called by the end point 0 device request parser.
80 //-----------------------------------------------------------------------------
81
82 BOOL DR_GetDescriptor(void)
83 {
84 1 return(TRUE);
85 1 }
86
87 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
88 {
89 1 Configuration = SETUPDAT[2];
90 1 return(TRUE); // Handled by user code
91 1 }
92
93 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
94 {
95 1 IN0BUF[0] = Configuration;
96 1 EZUSB_SET_EP_BYTES(IN0BUF_ID,1);
97 1 return(TRUE); // Handled by user code
98 1 }
99
100 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
101 {
102 1 AlternateSetting = SETUPDAT[2];
103 1 return(TRUE); // Handled by user code
104 1 }
105
106 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
107 {
108 1 IN0BUF[0] = AlternateSetting;
109 1 EZUSB_SET_EP_BYTES(IN0BUF_ID,1);
110 1 return(TRUE); // Handled by user code
111 1 }
112
113 BOOL DR_GetStatus(void)
114 {
115 1 return(TRUE);
116 1 }
117
C51 COMPILER V6.14 USB_RS232 04/03/2003 10:41:10 PAGE 3
118 BOOL DR_ClearFeature(void)
119 {
120 1 return(TRUE);
121 1 }
122
123 BOOL DR_SetFeature(void)
124 {
125 1 return(TRUE);
126 1 }
127
128 #define EZUSB_UNARM_EP(ep_id) EPIO[ep_id].cntrl = bmEPBUSY
129
130 BOOL DR_VendorCmnd(void)
131 {
132 1 return(TRUE);
133 1 }
134
135 //-----------------------------------------------------------------------------
136 // USB Interrupt Handlers
137 // The following functions are called by the USB interrupt jump table.
138 //-----------------------------------------------------------------------------
139
140
141 void ISR_Sudav(void) interrupt 0
142 {
143 1 GotSUD = TRUE; // Set flag
144 1
145 1
146 1 EZUSB_IRQ_CLEAR();
147 1 USBIRQ = bmSUDAV; // Clear SUDAV IRQ
148 1 }
149
150 void ISR_Sutok(void) interrupt 0
151 {
152 1 EZUSB_IRQ_CLEAR();
153 1 USBIRQ = bmSUTOK; // Clear SUTOK IRQ
154 1 }
155
156 void ISR_Sof(void) interrupt 0
157 {
158 1 EZUSB_IRQ_CLEAR();
159 1 USBIRQ = bmSOF; // Clear SOF IRQ
160 1 }
161
162 void ISR_Ures(void) interrupt 0
163 {
164 1
165 1 REPORTDSCR *rdp;
166 1 dscr_ptr = (REPORTDSCR xdata *) pReportDscr;
167 1 rdp = dscr_ptr;
168 1 InReportBytes = rdp -> Report_Count_In_Value;
169 1 EPIO[IN2BUF_ID].bytes = InReportBytes;
170 1
171 1 EPIO[OUT2BUF_ID].bytes = 64;
172 1
173 1
174 1
175 1 EZUSB_IRQ_CLEAR();
176 1 USBIRQ = bmURES; // Clear URES IRQ
177 1 }
178
179 void ISR_IBN(void) interrupt 0
C51 COMPILER V6.14 USB_RS232 04/03/2003 10:41:10 PAGE 4
180 {
181 1
182 1 }
183
184 void ISR_Susp(void) interrupt 0
185 {
186 1 Sleep = TRUE;
187 1
188 1 EZUSB_IRQ_CLEAR();
189 1 USBIRQ = bmSUSP;
190 1 }
191
192 void ISR_Ep0in(void) interrupt 0
193 {
194 1 }
195
196 void ISR_Ep0out(void) interrupt 0
197 {
198 1 }
199
200 void ISR_Ep1in(void) interrupt 0
201 {
202 1
203 1 }
204
205 void ISR_Ep1out(void) interrupt 0
206 {
207 1 }
208
209 void ISR_Ep2in(void) interrupt 0
210 {
211 1
212 1 IN2BC = InReportBytes;
213 1
214 1 EZUSB_IRQ_CLEAR();
215 1 IN07IRQ = bmEP2;
216 1
217 1 }
218
219 void ISR_Ep2out(void) interrupt 0
220
221 {
222 1
223 1 if (EPIO[IN2BUF_ID].cntrl & bmEPBUSY)
224 1 {
225 2 TOGCTL = 0x08 | IN2BUF_ID;
226 2 WRITEDELAY();
227 2 if (TOGCTL & 0x80)
228 2 TOGCTL |= 0x20;
229 2 else
230 2 TOGCTL |= 0x40;
231 2 }
232 1
233 1
234 1 while(RI==1)
235 1 {
236 2 IN2BUF[0]=SBUF0;
237 2 RI=0;
238 2 }
239 1 SBUF0=OUT2BUF[0];
240 1 while(TI!=1);
241 1 TI=0;
C51 COMPILER V6.14 USB_RS232 04/03/2003 10:41:10 PAGE 5
242 1
243 1
244 1
245 1
246 1 OUT2BC = 0;
247 1
248 1
249 1 EZUSB_IRQ_CLEAR();
250 1 OUT07IRQ = bmEP2;
251 1 }
252
253 void ISR_Ep3in(void) interrupt 0
254 {
255 1 }
256
257 void ISR_Ep3out(void) interrupt 0
258 {
259 1
260 1 }
261
262 void ISR_Ep4in(void) interrupt 0
263 {
264 1 }
265
266 void ISR_Ep4out(void) interrupt 0
267 {
268 1
269 1 }
270
271 void ISR_Ep5in(void) interrupt 0
272 {
273 1 }
274
275 void ISR_Ep5out(void) interrupt 0
276 {
277 1
278 1
279 1 }
280
281 void ISR_Ep6in(void) interrupt 0
282 {
283 1 }
284
285 void ISR_Ep6out(void) interrupt 0
286 {
287 1
288 1 }
289
290 void ISR_Ep7in(void) interrupt 0
291 {
292 1 }
293
294 void ISR_Ep7out(void) interrupt 0
295 {
296 1
297 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 426 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
C51 COMPILER V6.14 USB_RS232 04/03/2003 10:41:10 PAGE 6
PDATA SIZE = ---- ----
DATA SIZE = 8 1
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -