📄 f3xx_usb0_standard_requests.lst
字号:
482 1 if ((USB0_STATE == DEV_DEFAULT) ||
483 1 // and request recipient must be the device
484 1 (SETUP.bmRequestType != IN_DEVICE) ||
485 1 // the index and length words must be zero
486 1 SETUP.wIndex.c[MSB] || SETUP.wIndex.c[LSB]||
487 1 SETUP.wLength.c[MSB] || SETUP.wLength.c[LSB] ||
488 1 SETUP.wValue.c[MSB] || (SETUP.wValue.c[LSB] > 1))
489 1 // This software only supports config = 0,1
C51 COMPILER V8.17 F3XX_USB0_STANDARD_REQUESTS 03/18/2009 09:55:18 PAGE 9
490 1 {
491 2 Force_Stall (); // Send stall if SETUP data is invalid
492 2 }
493 1
494 1 else
495 1 {
496 2 if (SETUP.wValue.c[LSB] > 0) // Any positive configuration request
497 2 { // results in configuration being set
498 3 // to 1
499 3 USB0_STATE = DEV_CONFIGURED;
500 3 EP_STATUS[1] = EP_IDLE; // Set endpoint status to idle (enabled)
501 3
502 3 POLL_WRITE_BYTE (INDEX, 2); // Change index to endpoint 1
503 3 // Set DIRSEL to indicate endpoint 1 is IN/OUT
504 3 POLL_WRITE_BYTE (EINCSR2, rbInSPLIT);
505 3 // Enable double buffering on out endpoint
506 3 POLL_WRITE_BYTE (EOUTCSR2, rbOutDBOEN);
507 3 POLL_WRITE_BYTE (INDEX, 0); // Set index back to endpoint 0
508 3
509 3 Handle_In2();
510 3 }
511 2 else
512 2 {
513 3 USB0_STATE = DEV_ADDRESS; // Unconfigures device by setting state
514 3 EP_STATUS[2] = EP_HALT; // to address, and changing endpoint
515 3 // 1 and 2
516 3 }
517 2 }
518 1 if (EP_STATUS[0] != EP_STALL)
519 1 {
520 2 POLL_WRITE_BYTE (E0CSR, (rbSOPRDY | rbDATAEND));
521 2 // Indicate SETUP packet has been
522 2 // serviced
523 2 }
524 1 }
525
526 //-----------------------------------------------------------------------------
527 // Get_Interface
528 //-----------------------------------------------------------------------------
529 //
530 // Return Value - None
531 // Parameters - Non
532 //
533 // Standard request that should not change in custom HID designs.
534 //
535 //-----------------------------------------------------------------------------
536 void Get_Interface (void) // This routine returns 0x00, since
537 { // only one interface is supported by
538 1 // this firmware
539 1
540 1 // If device is not configured
541 1 if ((USB0_STATE != DEV_CONFIGURED) ||
542 1 // or recipient is not an interface
543 1 (SETUP.bmRequestType != OUT_INTERFACE) ||
544 1 // or non-zero value or index fields
545 1 SETUP.wValue.c[MSB] ||SETUP.wValue.c[LSB] ||
546 1 // or data length not equal to one
547 1 SETUP.wIndex.c[MSB] ||SETUP.wIndex.c[LSB] ||
548 1 SETUP.wLength.c[MSB] ||(SETUP.wLength.c[LSB] != 1))
549 1 {
550 2 Force_Stall (); // Then return stall due to invalid
551 2 // request
C51 COMPILER V8.17 F3XX_USB0_STANDARD_REQUESTS 03/18/2009 09:55:18 PAGE 10
552 2 }
553 1
554 1 else
555 1 {
556 2 // Otherwise, return 0x00 to host
557 2 DATAPTR = (unsigned char*)&ZERO_PACKET;
558 2 DATASIZE = 1;
559 2 }
560 1 if (EP_STATUS[0] != EP_STALL)
561 1 {
562 2 // Set Serviced SETUP packet, put endpoint in transmit mode and reset
563 2 // Data sent counter
564 2 POLL_WRITE_BYTE (E0CSR, rbSOPRDY);
565 2 EP_STATUS[0] = EP_TX;
566 2 DATASENT = 0;
567 2 }
568 1 }
569
570 //-----------------------------------------------------------------------------
571 // Set_Interface
572 //-----------------------------------------------------------------------------
573 //
574 // Return Value - None
575 // Parameters - None
576 //
577 // Standard request that should not change in custom HID designs.
578 //
579 //-----------------------------------------------------------------------------
580 void Set_Interface (void)
581 {
582 1 // Make sure request is directed at interface
583 1 if ((SETUP.bmRequestType != IN_INTERFACE) ||
584 1 // and all other packet values are set to zero
585 1 SETUP.wLength.c[MSB] ||SETUP.wLength.c[LSB]||
586 1 SETUP.wValue.c[MSB] ||SETUP.wValue.c[LSB] ||
587 1 SETUP.wIndex.c[MSB] ||SETUP.wIndex.c[LSB])
588 1 {
589 2 Force_Stall (); // Othewise send a stall to host
590 2 }
591 1 if (EP_STATUS[0] != EP_STALL)
592 1 {
593 2 POLL_WRITE_BYTE (E0CSR, (rbSOPRDY | rbDATAEND));
594 2 // Indicate SETUP packet has been
595 2 // serviced
596 2 }
597 1 }
598
599 //-----------------------------------------------------------------------------
600 // Get_Idle
601 //-----------------------------------------------------------------------------
602 // Not supported.
603 //
604 //-----------------------------------------------------------------------------
605 void Get_Idle(void) {
606 1 }
607
608 //-----------------------------------------------------------------------------
609
610 //-----------------------------------------------------------------------------
611 // Get_Protocol
612 //-----------------------------------------------------------------------------
613 // Not supported.
C51 COMPILER V8.17 F3XX_USB0_STANDARD_REQUESTS 03/18/2009 09:55:18 PAGE 11
614 //
615 //-----------------------------------------------------------------------------
616 void Get_Protocol(void) { }
617
618 //-----------------------------------------------------------------------------
619 // Set_Protocol
620 //-----------------------------------------------------------------------------
621 // Not supported.
622 //
623 //-----------------------------------------------------------------------------
624 void Set_Protocol (void) { }
625
626
627
628 //-----------------------------------------------------------------------------
629 // Set_Idle()
630 //-----------------------------------------------------------------------------
631 //
632 // Return Value - None
633 // Parameters - None
634 //
635 // Description: Sets the idle feature on interrupt in endpoint.
636 //-----------------------------------------------------------------------------
637 void Set_Idle (void)
638 {
639 1
640 1 if (EP_STATUS[0] != EP_STALL)
641 1 {
642 2 // Set serviced SETUP Packet
643 2 POLL_WRITE_BYTE (E0CSR, (rbSOPRDY | rbDATAEND));
644 2 }
645 1
646 1 }
647
648
649
650 //-----------------------------------------------------------------------------
651 // Get_Report()
652 //-----------------------------------------------------------------------------
653 //
654 // Return Value - None
655 // Parameters - None
656 //
657 // Description: Sends a given report type to the host.
658 //
659 //-----------------------------------------------------------------------------
660 void Get_Report (void)
661 {
662 1 // call appropriate handler to prepare buffer
663 1 ReportHandler_IN_ISR(SETUP.wValue.c[LSB]);
664 1 // set DATAPTR to buffer used inside Control Endpoint
665 1 DATAPTR = IN_BUFFER.Ptr;
666 1 DATASIZE = IN_BUFFER.Length;
667 1
668 1 if (EP_STATUS[0] != EP_STALL)
669 1 {
670 2 // Set serviced SETUP Packet
671 2 POLL_WRITE_BYTE (E0CSR, rbSOPRDY);
672 2 EP_STATUS[0] = EP_TX; // Endpoint 0 in transmit mode
673 2 DATASENT = 0; // Reset DATASENT counter
674 2 }
675 1 }
C51 COMPILER V8.17 F3XX_USB0_STANDARD_REQUESTS 03/18/2009 09:55:18 PAGE 12
676
677
678
679 //-----------------------------------------------------------------------------
680 // Set_Report()
681 //-----------------------------------------------------------------------------
682 //
683 // Return Value - None
684 // Parameters - None
685 //
686 // Description: Receives a report sent from the host.
687 //
688 //-----------------------------------------------------------------------------
689 void Set_Report (void)
690 {
691 1 // prepare buffer for OUT packet
692 1 Setup_OUT_BUFFER ();
693 1
694 1 // set DATAPTR to buffer
695 1 DATAPTR = OUT_BUFFER.Ptr;
696 1 DATASIZE = SETUP.wLength.i;
697 1
698 1 if (EP_STATUS[0] != EP_STALL)
699 1 {
700 2 // Set serviced SETUP Packet
701 2 POLL_WRITE_BYTE (E0CSR, rbSOPRDY);
702 2 EP_STATUS[0] = EP_RX; // Endpoint 0 in transmit mode
703 2 DATASENT = 0; // Reset DATASENT counter
704 2 }
705 1 }
706
707
708
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1218 ----
CONSTANT SIZE = 4 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
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 + -