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

📄 subp.lst

📁 51单片机与SL811HST做从机的鼠标程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
 449   5                                                            switch(( unsigned char)dReq.wValue)
 450   5                                                                { 
 451   6                                                                  case INPUT:
 452   6                                                                                   SL811Write(EP0AControl,SEND_STALL);        
 453   6                                                                        break;
 454   6                                          case OUTPUT:
 455   6                                               bReport=1;
 456   6                                                                                       EP0A_OUT_Arm(4);
 457   6                                              // SL811Write(EP1AControl,SEND_STALL);
 458   6                                                                       break;
 459   6                                                                  case FEATURE:
 460   6                                                                                   SL811Write(EP0AControl,SEND_STALL);        
 461   6                                                                       break;
 462   6                                                                      default:
 463   6                                                                                   SL811Write(EP0AControl,SEND_STALL);        
 464   6                                                                           break;
 465   6                                                                    }  
 466   5                                                           break;
 467   5                                                      case GET_REPORT:
 468   5                                                           break;
 469   5      
 470   5                                              case GET_IDLE:
 471   5                                                              SL811Write(EP0A_Slave_Buf,Slave_IdleRate);                              // load current idle rate value
 472   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,1,1);                                                // send 1  unsigned char data back to host
 473   5                                                              len_req = 0;
 474   5                                                              break;  
 475   5      
 476   5                                              case GET_PROTOCOL:
 477   5                                                              SL811Write(EP0A_Slave_Buf,Slave_Protocol);                              // load current protocol state
 478   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,1,1);                                                // send 1  unsigned char data back to host
 479   5                                                              len_req = 0;
 480   5                                                              break;  
 481   5      
 482   5                                              case SET_IDLE:
 483   5                                                              Slave_IdleRate = ( unsigned char)dReq.wValue;                                           // update Idle Rate (upper  unsigned char of wVa
             -lue)
 484   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 485   5                                                              break;
 486   5      
 487   5                                              case SET_PROTOCOL:
 488   5                                                              Slave_Protocol = dReq.wValue>>8;                                                // update protocol value, 0=Boot, 1=report
C51 COMPILER V7.20   SUBP                                                                  05/16/2004 23:08:35 PAGE 9   

 489   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 490   5                                                              break;
 491   5                                            
 492   5                                                      default: 
 493   5                                                              SL811Write(EP0AControl,SEND_STALL);                                             // Stall all unsupported requests
 494   5                                                              break;
 495   5                                              }
 496   4                                              break;
 497   4      
 498   4                                      //---------------------------------------------------------------------
 499   4                                      // Specific Vendor Requests
 500   4                                      //---------------------------------------------------------------------
 501   4                                      case VENDOR_REQUEST:
 502   4                                              SL811Write(EP0AControl,SEND_STALL);                                                             // Stall all unsupported requests
 503   4                                              break;
 504   4      
 505   4                                      //---------------------------------------------------------------------
 506   4                                      // Unsupported Requests
 507   4                                      //---------------------------------------------------------------------
 508   4                                      default: 
 509   4                                              SL811Write(EP0AControl,SEND_STALL);                                                             // Stall all unsupported requests
 510   4                                              break;
 511   4                              }
 512   3                
 513   3                      }            // if(statuse&EP_setup) 
 514   2      
 515   2                      //================================================================
 516   2                      // IN/OUT token received from host
 517   2                      //================================================================
 518   2                      
 519   2                      else
 520   2                      {       
 521   3                              //---------------------------------
 522   3                              // IN's ACKed
 523   3                              //---------------------------------
 524   3                              if(SL811Read(EP0AControl)&DIRECTION)
 525   3                              {
 526   4                                      if(dev_first==0)                                                                                // happens on the first get device descp
 527   4                                      {                                                                                                               // the host terminate IN transfer prematurely
 528   5                                                  len_req = 0;                                                                                // (if EP0 maxpktsize is only 8  unsigned chars)                        
 529   5                                              dev_first = 1;                                                                          // reset len_req, end with OUT status stage
 530   5                                      }       
 531   4      
 532   4                                      //--------------------------------------                                        
 533   4                                      // Continue with next IN if needed
 534   4                                      //--------------------------------------                                        
 535   4                                      if(len_req)                                                                                                                     
 536   4                                      {                                                               
 537   5                                              data_seq = (((SL811Read(EP0AControl)&DATAX)==0) ? 1:0);                 // toggle DATA sequence
 538   5                                              len_xfr = (len_req>=EP0_LEN) ? EP0_LEN:( unsigned char)len_req;                 // get transfer length for EP0
 539   5                                              
 540   5                                              if(!IN_NULL)                // point to correct buffer location
 541   5                                              {
 542   6                                      EP0A_IN_Arm(EP0A_Slave_Buf+in_buffer_idx, len_xfr, data_seq);
 543   6                                              }
 544   5                                              else
 545   5                                                 {EP0A_IN_Arm(0,0,data_seq);}                                                         // transfer zero Null packet    
 546   5      
 547   5                                              in_buffer_idx += len_xfr;                                                                               // update buffer location
 548   5                                              len_req -= len_xfr;                                                                                             // update remaining data length
 549   5      
 550   5                                              if(len_req==0 && len_xfr==EP0_LEN && !IN_EXACT)                                 // handles null packet of data length                                   
C51 COMPILER V7.20   SUBP                                                                  05/16/2004 23:08:35 PAGE 10  

 551   5                                              {                                                                                                                               // to host is multiple of EP0_LEN, and
 552   6                                                      len_req = 1;                                                                                            // only if host request more than this
 553   6                                                      IN_NULL = TRUE;                                                                                         // value of length, otherwise, the extra
 554   6                                              }                                                                                                                               // null pkt is not require.
 555   5                                      }
 556   4      
 557   4                                      //--------------------------------------                                        
 558   4                                      // Arm Status Stage OUT or new SETUP                                                            
 559   4                                      //--------------------------------------                                        
 560   4                                      else// Arm status OUT or next SETUP requests    
 561   4                                  {   
 562   5                                        EP0A_OUT_Arm(EP0_LEN);                // i.e. end of IN status stage.
 563   5                                      }
 564   4                              }
 565   3      
 566   3                              //---------------------------------
 567   3                              // OUT's ACKed
 568   3                              //---------------------------------
 569   3                              else 
 570   3                              {
 571   4                                      if( byte_rx==0)                                                                 // zero data packet received
 572   4                                      {  
 573   5                         // EP0A_OUT_Arm(byte_rx);
 574   5                                        // if(bReport==1)
 575   5                                        //  {
 576   5                         //  SL811BufRead(EP0A_Slave_Buf, ( unsigned char*)&dReq,  byte_rx);
 577   5                                           bReport=0; 
 578   5                          // EP0A_IN_Arm(0,0,1);
 579   5                                         //  }
 580   5                       // SL811Write(EP0AAddress,EP0A_Slave_Buf);     // ep0 address buffer start adress after 64 u
             -nsigned char
 581   5                       // SL811Write(EP0AXferLen,byte_rx);                            // max length of transfer allowed
 582   5                       // SL811Write(EP0AControl,DATA1_OUT);
 583   5                      EP0A_OUT_Arm(EP0_LEN);                                          // get ready for next SETUP token
 584   5                                              if((unsigned char)dReq.wValue == HID_REPORT)                    // end of a report descp, indicate
 585   5                                              {
 586   6                                                      enum_done = 1;                                                  // end of complete enumeration
 587   6                                                                                              // Turn on Active LED
 588   6                              TMOD=0x01;
 589   6                              TL0=0xd0;
 590   6                              TH0=0x07;
 591   6                              ET0=1;
 592   6                              TR0=1;  
 593   6                              EA = 1; 
 594   6                                              }
 595   5                                      }
 596   4                              // else 
 597   4                       //  EP0A_OUT_Arm(EP0_LEN);
 598   4                              }
 599   3      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -