📄 fw.lst
字号:
208 5 EZUSB_Susp(); // Place processor in idle mode.
209 5 }
210 4 while(!Rwuen && EZUSB_EXTWAKEUP());
211 4 // Must continue to go back into suspend if the host has disabled remote wakeup
212 4 // *and* the wakeup was caused by the external wakeup pin.
213 4
214 4 // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
215 4 EZUSB_Resume(); // If source is the Wakeup# pin, signal the host to Resume.
216 4 TD_Resume();
217 4 }
218 3 }
219 2 TD_Poll();
220 2 }
221 1 }
222
223 // Device request parser
224 void SetupCommand(void)
225 {
226 1
227 1 unsigned int i, j,ReportLength;
228 1
229 1 switch(SETUPDAT[1])
230 1 {
231 2 case SC_GET_DESCRIPTOR: // *** Get Descriptor
232 2 if(DR_GetDescriptor())
233 2 switch(SETUPDAT[3])
234 2 {
235 3 case GD_DEVICE: // Device
236 3 SUDPTRH = MSB(pDeviceDscr);
237 3 SUDPTRL = LSB(pDeviceDscr);
238 3 break;
239 3 // case GD_DEVICE_QUALIFIER: // Device Qualifier
240 3 // SUDPTRH = MSB(pDeviceQualDscr);
C51 COMPILER V7.50 FW 05/27/2006 13:40:48 PAGE 5
241 3 // SUDPTRL = LSB(pDeviceQualDscr);
242 3 // break;
243 3 case GD_CONFIGURATION: // Configuration
244 3 SUDPTRH = MSB(pConfigDscr);
245 3 SUDPTRL = LSB(pConfigDscr);
246 3 break;
247 3 // case GD_OTHER_SPEED_CONFIGURATION: // Other Speed Configuration
248 3 // SUDPTRH = MSB(pOtherConfigDscr);
249 3 // SUDPTRL = LSB(pOtherConfigDscr);
250 3 // break;
251 3 case GD_STRING: // String
252 3 switch(SETUPDAT[2]) // switch on wValueL
253 3 {
254 4 case 0: // String index 1
255 4 SUDPTRH = MSB(&StringDscr0);
256 4 SUDPTRL = LSB(&StringDscr0);
257 4 break;
258 4 case 1: // String index 1
259 4 SUDPTRH = MSB(&StringDscr1);
260 4 SUDPTRL = LSB(&StringDscr1);
261 4 break;
262 4 case 2: // String index 2
263 4 SUDPTRH = MSB(&StringDscr2);
264 4 SUDPTRL = LSB(&StringDscr2);
265 4 break;
266 4
267 4 default: // Invalid string index requested
268 4 EZUSB_STALL_EP0();
269 4 }
270 3
271 3 break;
272 3 case GD_HID: // Get-Descriptor: HID
273 3 SUDPTRH = MSB(&HIDDscr);
274 3 SUDPTRL = LSB(&HIDDscr);
275 3 break;
276 3 case GD_REPORT: // Get-Descriptor: Report
277 3
278 3 //A HID report does not have a length field which the SIE can read
279 3 //to determine how many bytes to send using the Setup Data Pointer.
280 3 //Hence we need to 'manually' send the data.
281 3
282 3 ReportLength = (WORD)&ReportDscrEnd - (WORD)&ReportDscr;
283 3 AUTOPTR1H = MSB(&ReportDscr);
284 3 AUTOPTR1L = LSB(&ReportDscr);
285 3 while(ReportLength)
286 3 {
287 4 j = min(ReportLength,64); // smaller of ReportSize or IN0 Buffer (64 bytes)
288 4 for(i=0;i<j;i++)
289 4 EP0BUF[i]=XAUTODAT1;
290 4 EP0BCH = 0;
291 4 SYNCDELAY;
292 4 EP0BCL = j; // arm the IN transfer
293 4 SYNCDELAY;
294 4 ReportLength = ReportLength-j;
295 4 while(EP0CS & bmBIT1); // wait for it to go out and get ACK'd
296 4 }
297 3
298 3 break;
299 3 default: // Invalid request
300 3 EZUSB_STALL_EP0(); // Stall End Point 0
301 3 }
302 2 break;
C51 COMPILER V7.50 FW 05/27/2006 13:40:48 PAGE 6
303 2 case SC_GET_INTERFACE: // *** Get Interface
304 2 DR_GetInterface();
305 2 break;
306 2 case SC_SET_INTERFACE: // *** Set Interface
307 2 DR_SetInterface();
308 2 break;
309 2 case SC_SET_CONFIGURATION: // *** Set Configuration
310 2 DR_SetConfiguration();
311 2 break;
312 2 case SC_GET_CONFIGURATION: // *** Get Configuration
313 2 DR_GetConfiguration();
314 2 break;
315 2 case SC_GET_STATUS: // *** Get Status
316 2 if(DR_GetStatus())
317 2 switch(SETUPDAT[0])
318 2 {
319 3 case GS_DEVICE: // Device
320 3 EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
321 3 EP0BUF[1] = 0;
322 3 EP0BCH = 0;
323 3 EP0BCL = 2;
324 3 break;
325 3 case GS_INTERFACE: // Interface
326 3 EP0BUF[0] = 0;
327 3 EP0BUF[1] = 0;
328 3 EP0BCH = 0;
329 3 EP0BCL = 2;
330 3 break;
331 3 case GS_ENDPOINT: // End Point
332 3 EP0BUF[0] = *(BYTE xdata *) epcs(SETUPDAT[4]) & bmEPSTALL;
333 3 EP0BUF[1] = 0;
334 3 EP0BCH = 0;
335 3 EP0BCL = 2;
336 3 break;
337 3 default: // Invalid Command
338 3 EZUSB_STALL_EP0(); // Stall End Point 0
339 3 }
340 2 break;
341 2 case SC_CLEAR_FEATURE: // *** Clear Feature
342 2 if(DR_ClearFeature())
343 2 switch(SETUPDAT[0])
344 2 {
345 3 case FT_DEVICE: // Device
346 3 if(SETUPDAT[2] == 1)
347 3 Rwuen = FALSE; // Disable Remote Wakeup
348 3 else
349 3 EZUSB_STALL_EP0(); // Stall End Point 0
350 3 break;
351 3 case FT_ENDPOINT: // End Point
352 3
353 3 switch (SETUPDAT[2])
354 3 {
355 4 case 0x00: //EP0
356 4 *(BYTE xdata *) epcs(SETUPDAT[4]) &= ~bmEPSTALL;
357 4 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
358 4 break;
359 4 case 0x80: //EP0 In
360 4 EP0CS &= ~bmEPSTALL;
361 4 break;
362 4 case 0x81: //EP1 In
363 4 EP1INCS &= ~bmEPSTALL;
364 4 break;
C51 COMPILER V7.50 FW 05/27/2006 13:40:48 PAGE 7
365 4 default:
366 4 EZUSB_STALL_EP0(); // Stall End Point 0
367 4 }
368 3 break;
369 3 }
370 2 break;
371 2 case SC_SET_FEATURE: // *** Set Feature
372 2 if(DR_SetFeature())
373 2 switch(SETUPDAT[0])
374 2 {
375 3 case FT_DEVICE: // Device
376 3 if(SETUPDAT[2] == 1)
377 3 Rwuen = TRUE; // Enable Remote Wakeup
378 3 else if(SETUPDAT[2] == 2)
379 3 // Set Feature Test Mode. The core handles this request. However, it is
380 3 // necessary for the firmware to complete the handshake phase of the
381 3 // control transfer before the chip will enter test mode. It is also
382 3 // necessary for FX2 to be physically disconnected (D+ and D-)
383 3 // from the host before it will enter test mode.
384 3 break;
385 3 else
386 3 EZUSB_STALL_EP0(); // Stall End Point 0
387 3 break;
388 3 case FT_ENDPOINT: // End Point
389 3 *(BYTE xdata *) epcs(SETUPDAT[4]) |= bmEPSTALL;
390 3 break;
391 3 }
392 2 break;
393 2 default: // *** Invalid Command
394 2 if(DR_VendorCmnd())
395 2 EZUSB_STALL_EP0(); // Stall End Point 0
396 2 }
397 1
398 1 // Acknowledge handshake phase of device request
399 1 EP0CS |= bmHSNAK;
400 1 }
401
402 // Wake-up interrupt handler
403 void resume_isr(void) interrupt WKUP_VECT
404 {
405 1 EZUSB_CLEAR_RSMIRQ();
406 1 }
407
408
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1091 ----
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 6 18
IDATA SIZE = ---- ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -