📄 f32x_usb_standard_requests.lst
字号:
412 3 Force_Stall();
413 3 }
414 2 break;
415 2
416 2 default:
417 2 Force_Stall(); // Send Stall if unsupported request
418 2 break;
419 2 }
420 1
421 1 if (Setup.wValue.c[MSB] == DSC_DEVICE || // Verify that the requested descriptor is
422 1 Setup.wValue.c[MSB] == DSC_CONFIG || // valid
423 1 Setup.wValue.c[MSB] == DSC_STRING ||
424 1 Setup.wValue.c[MSB] == DSC_INTERFACE ||
425 1 Setup.wValue.c[MSB] == DSC_ENDPOINT)
426 1 {
427 2 if ((Setup.wLength.c[LSB] < DataSize) &&
C51 COMPILER V7.50 F32X_USB_STANDARD_REQUESTS 08/23/2006 15:13:09 PAGE 8
428 2 (Setup.wLength.c[MSB] == 0))
429 2 {
430 3 DataSize = Setup.wLength.i; // Send only requested amount of data
431 3 }
432 2 }
433 1 if (Ep_Status[0] != EP_STALL) // Make sure endpoint not in stall mode
434 1 {
435 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY); // Service Setup Packet
436 2 Ep_Status[0] = EP_TX; // Put endpoint in transmit mode
437 2 DataSent = 0; // Reset Data Sent counter
438 2 }
439 1 }
440
441 //-----------------------------------------------------------------------------
442 // Get_Configuration
443 //-----------------------------------------------------------------------------
444 //
445 // Return Value : None
446 // Parameters : None
447 //
448 // This routine returns current configuration value
449 //
450 //-----------------------------------------------------------------------------
451
452 void Get_Configuration(void)
453 {
454 1 if ((Setup.bmRequestType != OUT_DEVICE) ||// This request must be directed to the device
455 1 Setup.wValue.c[MSB] || Setup.wValue.c[LSB]||// with value word set to zero
456 1 Setup.wIndex.c[MSB] || Setup.wIndex.c[LSB]||// and index set to zero
457 1 Setup.wLength.c[MSB] || (Setup.wLength.c[LSB] != 1))// and setup length set to one
458 1 {
459 2 Force_Stall(); // Otherwise send a stall to host
460 2 }
461 1
462 1 else
463 1 {
464 2 if (USB_State == DEV_CONFIGURED) // If the device is configured, then return value 0x01
465 2 { // since this software only supports one configuration
466 3 DataPtr = (BYTE*)&ONES_PACKET;
467 3 DataSize = 1;
468 3 }
469 2 if (USB_State == DEV_ADDRESS) // If the device is in address state, it is not
470 2 { // configured, so return 0x00
471 3 DataPtr = (BYTE*)&ZERO_PACKET;
472 3 DataSize = 1;
473 3 }
474 2 }
475 1 if (Ep_Status[0] != EP_STALL)
476 1 {
477 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY); // Set Serviced Out Packet bit
478 2 Ep_Status[0] = EP_TX; // Put endpoint into transmit mode
479 2 DataSent = 0; // Reset Data Sent counter to zero
480 2 }
481 1 }
482
483 //-----------------------------------------------------------------------------
484 // Set_Configuration
485 //-----------------------------------------------------------------------------
486 //
487 // Return Value : None
488 // Parameters : None
489 //
C51 COMPILER V7.50 F32X_USB_STANDARD_REQUESTS 08/23/2006 15:13:09 PAGE 9
490 // This routine allows host to change current device configuration value
491 //
492 //-----------------------------------------------------------------------------
493
494 void Set_Configuration(void)
495 {
496 1
497 1 if ((USB_State == DEV_DEFAULT) ||// Device must be addressed before configured
498 1 (Setup.bmRequestType != IN_DEVICE) ||// and request recipient must be the device
499 1 Setup.wIndex.c[MSB] || Setup.wIndex.c[LSB]||// the index and length words must be zero
500 1 Setup.wLength.c[MSB] || Setup.wLength.c[LSB] ||
501 1 Setup.wValue.c[MSB] || (Setup.wValue.c[LSB] > 1))// This software only supports config = 0,1
502 1 {
503 2 Force_Stall(); // Send stall if setup data is invalid
504 2 }
505 1
506 1 else
507 1 {
508 2 if (Setup.wValue.c[LSB] > 0) // Any positive configuration request
509 2 { // results in configuration being set to 1
510 3 USB_State = DEV_CONFIGURED;
511 3 Ep_Status[1] = EP_IDLE; // Set endpoint status to idle (enabled)
512 3 Ep_Status[2] = EP_IDLE;
513 3 POLL_WRITE_BYTE(INDEX, 1); // Change index to endpoint 1
514 3 POLL_WRITE_BYTE(EINCSR2, rbInDIRSEL); // Set DIRSEL to indicate endpoint 1 is IN
515 3 Handle_In1(); // Put first data packet on fifo
516 3 POLL_WRITE_BYTE(INDEX, 0); // Set index back to endpoint 0
517 3 }
518 2 else
519 2 {
520 3 USB_State = DEV_ADDRESS; // Unconfigures device by setting state to
521 3 Ep_Status[1] = EP_HALT; // address, and changing endpoint 1 and 2
522 3 Ep_Status[2] = EP_HALT; // status to halt
523 3 }
524 2 }
525 1 if (Ep_Status[0] != EP_STALL)
526 1 {
527 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY);
528 2 // Indicate setup packet has been serviced
529 2 }
530 1 }
531
532 //-----------------------------------------------------------------------------
533 // Get_Interface
534 //-----------------------------------------------------------------------------
535 //
536 // Return Value : None
537 // Parameters : None
538 //
539 // This routine returns 0x00, since only one interface is supported by
540 // this firmware
541 //
542 //-----------------------------------------------------------------------------
543
544 void Get_Interface(void)
545 {
546 1
547 1 if ((USB_State != DEV_CONFIGURED) || // If device is not configured
548 1 (Setup.bmRequestType != OUT_INTERFACE) || // or recipient is not an interface
549 1 Setup.wValue.c[MSB] ||Setup.wValue.c[LSB] ||// or non-zero value or index fields
550 1 Setup.wIndex.c[MSB] ||Setup.wIndex.c[LSB] ||// or data length not equal to one
551 1 Setup.wLength.c[MSB] ||(Setup.wLength.c[LSB] != 1))
C51 COMPILER V7.50 F32X_USB_STANDARD_REQUESTS 08/23/2006 15:13:09 PAGE 10
552 1 {
553 2 Force_Stall(); // Then return stall due to invalid request
554 2 }
555 1
556 1 else
557 1 {
558 2 DataPtr = (BYTE*)&ZERO_PACKET; // Otherwise, return 0x00 to host
559 2 DataSize = 1;
560 2 }
561 1 if (Ep_Status[0] != EP_STALL)
562 1 {
563 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY); // Set Serviced Setup packet, put endpoint in transmit
564 2 Ep_Status[0] = EP_TX; // mode and reset Data sent counter
565 2 DataSent = 0;
566 2 }
567 1 }
568
569 //-----------------------------------------------------------------------------
570 // Set_Interface
571 //-----------------------------------------------------------------------------
572 //
573 // Return Value : None
574 // Parameters : None
575 //
576 // This routine allows host to change current device configuration value
577 //
578 //-----------------------------------------------------------------------------
579
580 void Set_Interface(void)
581 {
582 1 // Make sure request is directed at interface and all other packet values
583 1 // are set to zero
584 1
585 1 if ((Setup.bmRequestType != IN_INTERFACE) ||
586 1 Setup.wLength.c[MSB] ||Setup.wLength.c[LSB]||
587 1 Setup.wValue.c[MSB] ||Setup.wValue.c[LSB] ||
588 1 Setup.wIndex.c[MSB] ||Setup.wIndex.c[LSB])
589 1 {
590 2 // Otherwise send a stall to host
591 2 Force_Stall();
592 2 }
593 1 if (Ep_Status[0] != EP_STALL)
594 1 {
595 2 // Indicate setup packet has been serviced
596 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY);
597 2 }
598 1 }
599
600 //-----------------------------------------------------------------------------
601 // End Of File
602 //-----------------------------------------------------------------------------
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1134 ----
CONSTANT SIZE = 4 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILER V7.50 F32X_USB_STANDARD_REQUESTS 08/23/2006 15:13:09 PAGE 11
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -