📄 periph.lst
字号:
C51 COMPILER V7.02a PERIPH 03/31/2005 21:39:17 PAGE 1
C51 COMPILER V7.02a, COMPILATION OF MODULE PERIPH
OBJECT MODULE PLACED IN periph.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE periph.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #pragma NOIV // Do not generate interrupt vectors
2 //-----------------------------------------------------------------------------
3 // File: periph.c
4 // Contents: Hooks required to implement USB peripheral function.
5 //
6 // Copyright (c) 1997 AnchorChips, Inc. All rights reserved
7 //-----------------------------------------------------------------------------
8 #include "fx2.h"
9 #include "fx2regs.h"
10 #include "fx2sdly.h"
11 #include "io.h"
12 #include "serial.h"
13
14 extern BOOL GotSUD; // Received setup data flag
15 extern BOOL Sleep;
16 extern BOOL Rwuen;
17 extern BOOL Selfpwr;
18
19 BYTE Configuration; // Current configuration
20 BYTE AlternateSetting; // Alternate settings
21 WORD EndPoint6_MaxInLength;
22
23
24 //-----------------------------------------------------------------------------
25 // Task Dispatcher hooks
26 // The following hooks are called by the task dispatcher.
27 //-----------------------------------------------------------------------------
28
29 void TD_Init(void) // Called once at startup
30 {
31 1 BREAKPT &= ~bmBPEN; // to see BKPT LED go out TGE
32 1 Rwuen = TRUE; // Enable remote-wakeup
33 1 REVCTL = 0x03;
34 1
35 1 // EP2 512 BULK OUT 4x
36 1 SYNCDELAY; // see TRM section 15.14
37 1 EP2CFG = 0xA0; //512PACKET; // BUF[1:0]=00 for 4x buffering
38 1
39 1 // EP4 and EP6 and EP8 are not used in this implementation...
40 1 SYNCDELAY; //
41 1 EP4CFG = 0x20; // clear valid bit
42 1 SYNCDELAY; //
43 1 EP6CFG = 0xE0;
44 1 SYNCDELAY; //
45 1 EP8CFG = 0x60; // clear valid bit
46 1
47 1 // 8-bit bus (WORDWIDE=1)...
48 1 EP2FIFOCFG = 0x00;//manual OUT 8-BIT BUS
49 1 SYNCDELAY;
50 1 EP6FIFOCFG = 0x00;//manual IN 8-BIT BUS
51 1 SYNCDELAY;
52 1
53 1 SYNCDELAY; //
54 1 FIFORESET = 0x80; // activate NAK-ALL to avoid race conditions
55 1 SYNCDELAY; //
C51 COMPILER V7.02a PERIPH 03/31/2005 21:39:17 PAGE 2
56 1 FIFORESET = 0x02; // reset, FIFO 2
57 1 SYNCDELAY; //
58 1 FIFORESET = 0x04; // reset, FIFO 4
59 1 SYNCDELAY; //
60 1 FIFORESET = 0x06; // reset, FIFO 6
61 1 SYNCDELAY; //
62 1 FIFORESET = 0x08; // reset, FIFO 8
63 1 SYNCDELAY; //
64 1 FIFORESET = 0x00; // deactivate NAK-ALL
65 1 SYNCDELAY;
66 1
67 1
68 1
69 1 EPIRQ = 0xFF;
70 1 SYNCDELAY;
71 1 EPIE |= 0x50; //enable the ep2 inout interrupt*/
72 1
73 1 SYNCDELAY;
74 1
75 1 /*when REVCTL.0 = 1 do this*/
76 1 OUTPKTEND = 0x82;
77 1 SYNCDELAY;
78 1 OUTPKTEND = 0x82;
79 1 SYNCDELAY;
80 1 OUTPKTEND = 0x82;
81 1 SYNCDELAY;
82 1 OUTPKTEND = 0x82;
83 1 SYNCDELAY;
84 1
85 1 /*when REVCTL.0 = 0 do this*/
86 1 /* EP2BCL = 0x80; //arm first buffer skip = 1
87 1 SYNCDELAY;
88 1 EP2BCL = 0x80; //arm second buffer skip = 1
89 1 SYNCDELAY;
90 1 EP2BCL = 0x80; //arm third buffer skip = 1
91 1 SYNCDELAY;
92 1 EP2BCL = 0x80; //arm third buffer skip = 1
93 1 SYNCDELAY;*/
94 1 }
95
96 void TD_Poll(void) // Called repeatedly while the device is idle
97 {
98 1 }
99
100 BOOL TD_Suspend(void) // Called before the device goes into suspend mode
101 {
102 1 return(TRUE);
103 1 }
104
105 BOOL TD_Resume(void) // Called after the device resumes
106 {
107 1 return(TRUE);
108 1 }
109
110 //-----------------------------------------------------------------------------
111 // Device Request hooks
112 // The following hooks are called by the end point 0 device request parser.
113 //-----------------------------------------------------------------------------
114
115 BOOL DR_GetDescriptor(void)
116 {
117 1 return(TRUE);
C51 COMPILER V7.02a PERIPH 03/31/2005 21:39:17 PAGE 3
118 1 }
119
120 BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received
121 {
122 1 Configuration = SETUPDAT[2];
123 1 return(TRUE); // Handled by user code
124 1 }
125
126 BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received
127 {
128 1 EP0BUF[0] = Configuration;
129 1 EP0BCH = 0;
130 1 EP0BCL = 1;
131 1 return(TRUE); // Handled by user code
132 1 }
133
134 BOOL DR_SetInterface(void) // Called when a Set Interface command is received
135 {
136 1 AlternateSetting = SETUPDAT[2];
137 1 return(TRUE); // Handled by user code
138 1 }
139
140 BOOL DR_GetInterface(void) // Called when a Set Interface command is received
141 {
142 1 EP0BUF[0] = AlternateSetting;
143 1 EP0BCH = 0;
144 1 EP0BCL = 1;
145 1 return(TRUE); // Handled by user code
146 1 }
147
148 BOOL DR_GetStatus(void)
149 {
150 1 return(TRUE);
151 1 }
152
153 BOOL DR_ClearFeature(void)
154 {
155 1 return(TRUE);
156 1 }
157
158 BOOL DR_SetFeature(void)
159 {
160 1 return(TRUE);
161 1 }
162
163 BOOL DR_VendorCmnd(void)
164 {
165 1 return(TRUE);
166 1 }
167
168 //-----------------------------------------------------------------------------
169 // USB Interrupt Handlers
170 // The following functions are called by the USB interrupt jump table.
171 //-----------------------------------------------------------------------------
172
173 // Setup Data Available Interrupt Handler
174 void ISR_Sudav(void) interrupt 0
175 {
176 1 GotSUD = TRUE; // Set flag
177 1 EZUSB_IRQ_CLEAR();
178 1 USBIRQ = bmSUDAV; // Clear SUDAV IRQ
179 1 }
C51 COMPILER V7.02a PERIPH 03/31/2005 21:39:17 PAGE 4
180
181 // Setup Token Interrupt Handler
182 void ISR_Sutok(void) interrupt 0
183 {
184 1 EZUSB_IRQ_CLEAR();
185 1 USBIRQ = bmSUTOK; // Clear SUTOK IRQ
186 1 }
187
188 void ISR_Sof(void) interrupt 0
189 {
190 1 EZUSB_IRQ_CLEAR();
191 1 USBIRQ = bmSOF; // Clear SOF IRQ
192 1 }
193
194 void ISR_Ures(void) interrupt 0
195 {
196 1 // whenever we get a USB reset, we should revert to full speed mode
197 1 pConfigDscr = pFullSpeedConfigDscr;
198 1 ((CONFIGDSCR xdata *) pConfigDscr)->type = CONFIG_DSCR;
199 1 pOtherConfigDscr = pHighSpeedConfigDscr;
200 1 ((CONFIGDSCR xdata *) pOtherConfigDscr)->type = OTHERSPEED_DSCR;
201 1 EndPoint6_MaxInLength = 64;
202 1
203 1 EZUSB_IRQ_CLEAR();
204 1 USBIRQ = bmURES; // Clear URES IRQ
205 1 }
206
207 void ISR_Susp(void) interrupt 0
208 {
209 1 Sleep = TRUE;
210 1 EZUSB_IRQ_CLEAR();
211 1 USBIRQ = bmSUSP;
212 1 }
213
214 void ISR_Highspeed(void) interrupt 0
215 {
216 1 if (EZUSB_HIGHSPEED())
217 1 {
218 2 pConfigDscr = pHighSpeedConfigDscr;
219 2 ((CONFIGDSCR xdata *) pConfigDscr)->type = CONFIG_DSCR;
220 2 pOtherConfigDscr = pFullSpeedConfigDscr;
221 2 ((CONFIGDSCR xdata *) pOtherConfigDscr)->type = OTHERSPEED_DSCR;
222 2 EndPoint6_MaxInLength = 512;
223 2 }
224 1
225 1 EZUSB_IRQ_CLEAR();
226 1 USBIRQ = bmHSGRANT;
227 1 }
228 void ISR_Ep0ack(void) interrupt 0
229 {
230 1 }
231 void ISR_Stub(void) interrupt 0
232 {
233 1 }
234 void ISR_Ep0in(void) interrupt 0
235 {
236 1 }
237 void ISR_Ep0out(void) interrupt 0
238 {
239 1 }
240 void ISR_Ep1in(void) interrupt 0
241 {
C51 COMPILER V7.02a PERIPH 03/31/2005 21:39:17 PAGE 5
242 1 }
243 void ISR_Ep1out(void) interrupt 0
244 {
245 1 }
246 void ISR_Ep2inout(void) interrupt 0
247 {
248 1 Serial_SendString(EP2FIFOBUF,(EP2BCH<<8)|EP2BCL,0);
249 1 /*when REVCTL.0 = 0 do this*/
250 1 // EP2BCH = 0;
251 1 // EP2BCL = 0x80; //不启动外部逻辑(gpif ,slave fifo)
252 1
253 1 /*when REVCTL.0 = 1 do this*/
254 1 OUTPKTEND = 0x82; //不启动外部逻辑(gpif ,slave fifo)
255 1 EZUSB_IRQ_CLEAR();
256 1 EPIRQ = 0x10;
257 1 }
258 void ISR_Ep4inout(void) interrupt 0
259 {
260 1 }
261 void ISR_Ep6inout(void) interrupt 0
262 {
263 1 EZUSB_IRQ_CLEAR();
264 1 EPIRQ = 0x40;
265 1 }
266 void ISR_Ep8inout(void) interrupt 0
267 {
268 1 }
269 void ISR_Ibn(void) interrupt 0
270 {
271 1 }
272 void ISR_Ep0pingnak(void) interrupt 0
273 {
274 1 }
275 void ISR_Ep1pingnak(void) interrupt 0
276 {
277 1 }
278 void ISR_Ep2pingnak(void) interrupt 0
279 {
280 1 }
281 void ISR_Ep4pingnak(void) interrupt 0
282 {
283 1 }
284 void ISR_Ep6pingnak(void) interrupt 0
285 {
286 1 }
287 void ISR_Ep8pingnak(void) interrupt 0
288 {
289 1 }
290 void ISR_Errorlimit(void) interrupt 0
291 {
292 1 }
293 void ISR_Ep2piderror(void) interrupt 0
294 {
295 1 }
296 void ISR_Ep4piderror(void) interrupt 0
297 {
298 1 }
299 void ISR_Ep6piderror(void) interrupt 0
300 {
301 1 }
302 void ISR_Ep8piderror(void) interrupt 0
303 {
C51 COMPILER V7.02a PERIPH 03/31/2005 21:39:17 PAGE 6
304 1 }
305 void ISR_Ep2pflag(void) interrupt 0
306 {
307 1 }
308 void ISR_Ep4pflag(void) interrupt 0
309 {
310 1 }
311 void ISR_Ep6pflag(void) interrupt 0
312 {
313 1 }
314 void ISR_Ep8pflag(void) interrupt 0
315 {
316 1 }
317 void ISR_Ep2eflag(void) interrupt 0
318 {
319 1 }
320 void ISR_Ep4eflag(void) interrupt 0
321 {
322 1 }
323 void ISR_Ep6eflag(void) interrupt 0
324 {
325 1 }
326 void ISR_Ep8eflag(void) interrupt 0
327 {
328 1 }
329 void ISR_Ep2fflag(void) interrupt 0
330 {
331 1 }
332 void ISR_Ep4fflag(void) interrupt 0
333 {
334 1 }
335 void ISR_Ep6fflag(void) interrupt 0
336 {
337 1 }
338 void ISR_Ep8fflag(void) interrupt 0
339 {
340 1 }
341 void ISR_GpifComplete(void) interrupt 0
342 {
343 1
344 1 }
345 void ISR_GpifWaveform(void) interrupt 0
346 {
347 1
348 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 590 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 4 ----
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 + -