⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 f326_usb0_standard_requests.lst

📁 基于F326单片机的RS232转USB程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
 468   1         SETUP.wIndex.c[MSB]  || SETUP.wIndex.c[LSB]||
 469   1         SETUP.wLength.c[MSB] || SETUP.wLength.c[LSB] ||
 470   1         SETUP.wValue.c[MSB]  || (SETUP.wValue.c[LSB] > 1))
 471   1         // This software only supports config = 0,1
 472   1         {
 473   2            Force_Stall ();                  // Send stall if SETUP data is invalid
 474   2         }
 475   1      
 476   1         else
 477   1         {
 478   2            if (SETUP.wValue.c[LSB] > 0)     // Any positive configuration request
 479   2            {                                // results in configuration being set
 480   3                                                                         // to 1
 481   3               USB0_STATE = DEV_CONFIGURED;
 482   3               EP_STATUS[1] = EP_IDLE;       // Set endpoint status to idle (enabled)
 483   3      
 484   3               POLL_WRITE_BYTE (INDEX, 1);   // Change index to endpoint 1
 485   3               // Set DIRSEL to indicate endpoint 1 is IN/OUT
 486   3               POLL_WRITE_BYTE (EINCSR2, rbInSPLIT);
 487   3               POLL_WRITE_BYTE (INDEX, 0);   // Set index back to endpoint 0
 488   3      
 489   3               Handle_In1();
C51 COMPILER V7.50   F326_USB0_STANDARD_REQUESTS                                           12/29/2007 16:03:24 PAGE 9   

 490   3            }
 491   2            else
 492   2            {
 493   3               USB0_STATE = DEV_ADDRESS;     // Unconfigures device by setting state
 494   3               EP_STATUS[1] = EP_HALT;       // to address, and changing endpoint
 495   3                                             // 1 and 2
 496   3            }
 497   2         }
 498   1         if (EP_STATUS[0] != EP_STALL)
 499   1         {
 500   2            POLL_WRITE_BYTE (E0CSR, (rbSOPRDY | rbDATAEND));
 501   2                                             // Indicate SETUP packet has been
 502   2                                             // serviced
 503   2         }
 504   1      }
 505          
 506          //-----------------------------------------------------------------------------
 507          // Get_Interface
 508          //-----------------------------------------------------------------------------
 509          //
 510          // Return Value - None
 511          // Parameters - Non
 512          //
 513          // Standard request that should not change in custom HID designs.
 514          //
 515          //-----------------------------------------------------------------------------
 516          void Get_Interface (void)              // This routine returns 0x00, since
 517          {                                      // only one interface is supported by
 518   1                                                 // this firmware
 519   1      
 520   1         // If device is not configured
 521   1         if ((USB0_STATE != DEV_CONFIGURED) ||
 522   1         // or recipient is not an interface
 523   1         (SETUP.bmRequestType != OUT_INTERFACE) ||
 524   1         // or non-zero value or index fields
 525   1         SETUP.wValue.c[MSB]  ||SETUP.wValue.c[LSB] ||
 526   1         // or data length not equal to one
 527   1         SETUP.wIndex.c[MSB]  ||SETUP.wIndex.c[LSB] ||
 528   1         SETUP.wLength.c[MSB] ||(SETUP.wLength.c[LSB] != 1))
 529   1         {
 530   2            Force_Stall ();                  // Then return stall due to invalid
 531   2                                                                         // request
 532   2         }
 533   1      
 534   1         else
 535   1         {
 536   2                // Otherwise, return 0x00 to host
 537   2            DATAPTR = (unsigned char*)&ZERO_PACKET;
 538   2            DATASIZE = 1;
 539   2         }
 540   1         if (EP_STATUS[0] != EP_STALL)
 541   1         {
 542   2                // Set Serviced SETUP packet, put endpoint in transmit mode and reset
 543   2                // Data sent counter
 544   2            POLL_WRITE_BYTE (E0CSR, rbSOPRDY);
 545   2            EP_STATUS[0] = EP_TX;
 546   2            DATASENT = 0;
 547   2         }
 548   1      }
 549          
 550          //-----------------------------------------------------------------------------
 551          // Set_Interface
C51 COMPILER V7.50   F326_USB0_STANDARD_REQUESTS                                           12/29/2007 16:03:24 PAGE 10  

 552          //-----------------------------------------------------------------------------
 553          //
 554          // Return Value - None
 555          // Parameters - None
 556          //
 557          // Standard request that should not change in custom HID designs.
 558          //
 559          //-----------------------------------------------------------------------------
 560          void Set_Interface (void)
 561          {
 562   1         // Make sure request is directed at interface
 563   1         if ((SETUP.bmRequestType != IN_INTERFACE)  ||
 564   1         // and all other packet values are set to zero
 565   1         SETUP.wLength.c[MSB] ||SETUP.wLength.c[LSB]||
 566   1         SETUP.wValue.c[MSB]  ||SETUP.wValue.c[LSB] ||
 567   1         SETUP.wIndex.c[MSB]  ||SETUP.wIndex.c[LSB])
 568   1         {
 569   2            Force_Stall ();                  // Othewise send a stall to host
 570   2         }
 571   1         if (EP_STATUS[0] != EP_STALL)
 572   1         {
 573   2            POLL_WRITE_BYTE (E0CSR, (rbSOPRDY | rbDATAEND));
 574   2                                             // Indicate SETUP packet has been
 575   2                                             // serviced
 576   2         }
 577   1      }
 578          
 579          //-----------------------------------------------------------------------------
 580          // Get_Idle
 581          //-----------------------------------------------------------------------------
 582          // Not supported.
 583          //
 584          //-----------------------------------------------------------------------------
 585          void Get_Idle(void) {
 586   1      }
 587          
 588          //-----------------------------------------------------------------------------
 589          
 590          //-----------------------------------------------------------------------------
 591          // Get_Protocol
 592          //-----------------------------------------------------------------------------
 593          // Not supported.
 594          //
 595          //-----------------------------------------------------------------------------
 596          void Get_Protocol(void) { }
 597          
 598          //-----------------------------------------------------------------------------
 599          // Set_Protocol
 600          //-----------------------------------------------------------------------------
 601          // Not supported.
 602          //
 603          //-----------------------------------------------------------------------------
 604          void Set_Protocol (void) { }
 605          
 606          
 607          
 608          //-----------------------------------------------------------------------------
 609          // Set_Idle()
 610          //-----------------------------------------------------------------------------
 611          //
 612          // Return Value - None
 613          // Parameters - None
C51 COMPILER V7.50   F326_USB0_STANDARD_REQUESTS                                           12/29/2007 16:03:24 PAGE 11  

 614          //
 615          // Description: Sets the idle feature on interrupt in endpoint.
 616          //-----------------------------------------------------------------------------
 617          void Set_Idle (void)
 618          {
 619   1      
 620   1         if (EP_STATUS[0] != EP_STALL)
 621   1         {
 622   2            // Set serviced SETUP Packet
 623   2            POLL_WRITE_BYTE (E0CSR, (rbSOPRDY | rbDATAEND));
 624   2         }
 625   1      
 626   1      }
 627          
 628          
 629          
 630          //-----------------------------------------------------------------------------
 631          // Get_Report()
 632          //-----------------------------------------------------------------------------
 633          //
 634          // Return Value - None
 635          // Parameters - None
 636          //
 637          // Description: Sends a given report type to the host.
 638          //
 639          //-----------------------------------------------------------------------------
 640          void Get_Report (void)
 641          {
 642   1         // call appropriate handler to prepare buffer
 643   1         ReportHandler_IN_ISR(SETUP.wValue.c[LSB]);
 644   1         // set DATAPTR to buffer used inside Control Endpoint
 645   1         DATAPTR = IN_BUFFER.Ptr;
 646   1         DATASIZE = IN_BUFFER.Length;
 647   1      
 648   1         if (EP_STATUS[0] != EP_STALL)
 649   1         {
 650   2                // Set serviced SETUP Packet
 651   2            POLL_WRITE_BYTE (E0CSR, rbSOPRDY);
 652   2            EP_STATUS[0] = EP_TX;            // Endpoint 0 in transmit mode
 653   2            DATASENT = 0;                    // Reset DATASENT counter
 654   2         }
 655   1      }
 656          
 657          
 658          
 659          //-----------------------------------------------------------------------------
 660          // Set_Report()
 661          //-----------------------------------------------------------------------------
 662          //
 663          // Return Value - None
 664          // Parameters - None
 665          //
 666          // Description: Receives a report sent from the host.
 667          //
 668          //-----------------------------------------------------------------------------
 669          void Set_Report (void)
 670          {
 671   1         // prepare buffer for OUT packet
 672   1         Setup_OUT_BUFFER ();
 673   1      
 674   1         // set DATAPTR to buffer
 675   1         DATAPTR = OUT_BUFFER.Ptr;
C51 COMPILER V7.50   F326_USB0_STANDARD_REQUESTS                                           12/29/2007 16:03:24 PAGE 12  

 676   1         DATASIZE = SETUP.wLength.i;
 677   1      
 678   1         if (EP_STATUS[0] != EP_STALL)
 679   1         {
 680   2                // Set serviced SETUP Packet
 681   2            POLL_WRITE_BYTE (E0CSR, rbSOPRDY);
 682   2            EP_STATUS[0] = EP_RX;            // Endpoint 0 in transmit mode
 683   2            DATASENT = 0;                    // Reset DATASENT counter
 684   2         }
 685   1      }
 686          
 687          
 688          


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 + -