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