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

📄 subp.lst

📁 SL811HST与51单片机组成usb从机的程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
 288   7                                                                                                         len_req = (len_req>=ProdString[0]) ? ProdString[0]:len_req;
 289   7                                                                                                         break;               
 290   7                                                                              }
 291   6                                                                              break;  
 292   6                                                              }       
 293   5      
 294   5                                                              if (len_req == WordSwap(dReq.wLength))                                  // if requested length is equal to the
 295   5                                                                      IN_EXACT = TRUE;                                                                        // exact length of descriptor, set IN_EXACT
 296   5                                                                                                                                                                              // is use during IN-NULL pkt trasnmission
 297   5                                                              len_xfr = (len_req>=EP0_LEN) ? EP0_LEN:( unsigned char)len_req; // get current IN transfer length
 298   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,len_xfr,1);                                  // Arm IN response, start with DATA1 seq
 299   5                                                              in_buffer_idx += len_xfr;                                                               // update to next muliple buffer location
 300   5                                                              len_req -= len_xfr;                                         // update data length for current transfer
 301   5                                                          
 302   5                                                              break;
 303   5      
C51 COMPILER V7.20   SUBP                                                                  06/11/2004 19:40:15 PAGE 6   

 304   5                                              case GET_CONFIG:
 305   5                                                              SL811Write(EP0A_Slave_Buf,Slave_ConfigVal);                             // load current configuration value
 306   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,1,1);                                                // send 1  unsigned char data back to host
 307   5                                                              len_req = 0;
 308   5                                                              break;
 309   5      
 310   5                                              case GET_INTERFACE:
 311   5                                                              SL811Write(EP0A_Slave_Buf,Slave_IfcAlt[dReq.wIndex>>8]);// load current alternate setting
 312   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,1,1);                                                // send 1  unsigned char data back to host
 313   5                                                              len_req = 0;
 314   5                                                              break;
 315   5      
 316   5                                              case GET_STATUS:
 317   5                                                              switch(dReq.bmRequest&0x03)                                                             // check for recipients
 318   5                                                              {
 319   6                                                                      case RECIPIENT_DEV:                                                                     // load current device status
 320   6                                                                              SL811Write(EP0A_Slave_Buf,(Slave_RemoteWU<<1)|BUS_POWERED);     
 321   6                                                                              break;
 322   6                                                                      case RECIPIENT_IFC:                                                     
 323   6                                                                              SL811Write(EP0A_Slave_Buf,0);                                   // first  unsigned char = 0
 324   6                                                                              break;
 325   6                                                                      case RECIPIENT_ENP:                                                     
 326   6                                                                              if((dReq.wIndex>>8) & 0x80)                                             // for IN direction endpoint
 327   6                                                                              {
 328   7                                                                                      if(Slave_inEPstall & (0x01<<((dReq.wIndex>>8)&0x0F)))   
 329   7                                                                                              SL811Write(EP0A_Slave_Buf,1);                   // first  unsigned char = 1 (IN endpoint stall)         
 330   7                                                                                      else
 331   7                                                                                              SL811Write(EP0A_Slave_Buf,0);                   // first  unsigned char = 0 (IN endpoint not stall)             
 332   7                                                                              }
 333   6                                                                              else                                                                                    // for OUT direction endpoint
 334   6                                                                              {
 335   7                                                                                      if(Slave_outEPstall & (0x01<<((dReq.wIndex>>8)&0x0F)))  
 336   7                                                                                              SL811Write(EP0A_Slave_Buf,1);                   // first  unsigned char = 1 (OUT endpoint stall)                
 337   7                                                                                      else
 338   7                                                                                              SL811Write(EP0A_Slave_Buf,0);                   // first  unsigned char = 0 (OUT endpoint not stall)            
 339   7                                                                              }
 340   6                                                                              break;
 341   6                                                              }
 342   5                                                              SL811Write(EP0A_Slave_Buf+1,0);                                                 // second  unsigned char = 0
 343   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,2,1);                                                // send 2  unsigned chars data back to host
 344   5                                                              len_req = 0;                                                                                    // reset request length to zero
 345   5                                                              break;                                                  
 346   5      
 347   5                                              case SET_FEATURE:
 348   5                                              case CLEAR_FEATURE:
 349   5                                                              switch(dReq.bmRequest&0x03)                                                             // check for recipients
 350   5                                                              {
 351   6                                                                      case RECIPIENT_DEV:
 352   6                                                                              if((dReq.wValue>>8) == 1)                                               // feature selector = 1 (remote wakeup)
 353   6                                                                              {
 354   7                                                                                      if(dReq.bRequest==SET_FEATURE)                          // set remote wake up status    
 355   7                                                                                              Slave_RemoteWU = 1;                                             
 356   7                                                                                      if(dReq.bRequest==CLEAR_FEATURE)                        // clear remote wake up status          
 357   7                                                                                              Slave_RemoteWU = 0;                                             
 358   7                                                                                      EP0A_IN_Arm(0,0,1);                                                     // IN status stage
 359   7                                                                              }
 360   6                                                                              else
 361   6                                                                                      SL811Write(EP0AControl,SEND_STALL);                     // Stall unsupported requests                                           
 362   6                                                                              break;
 363   6      
 364   6                                                                      case RECIPIENT_ENP:
 365   6                                                                              if((dReq.wValue>>8) == 0)                                               // feature selector = 0 (endpoint stall)
C51 COMPILER V7.20   SUBP                                                                  06/11/2004 19:40:15 PAGE 7   

 366   6                                                                              {
 367   7                                                                                      if((dReq.wIndex>>8) & 0x80)                                     // for IN direction endpoint
 368   7                                                                                      {
 369   8                                                                                              if(dReq.bRequest==SET_FEATURE)                  // set endpoint stall (limit to 7 IN's data endpoint)
 370   8                                                                                                      Slave_inEPstall |=  (0x01<<((dReq.wIndex>>8)&0x0F)); 
 371   8                                                                                              if(dReq.bRequest==CLEAR_FEATURE)                // clear endpoint stall (limit to 7 IN's data endpoint)
 372   8                                                                                                      Slave_inEPstall &=  ~(0x01<<((dReq.wIndex>>8)&0x0F)); 
 373   8                                                                                      }
 374   7                                                                                      else                                                                            // for OUT direction endpoint
 375   7                                                                                      {
 376   8                                                                                              if(dReq.bRequest==SET_FEATURE)                  // set endpoint stall (limit to 7 OUT's data endpoint)
 377   8                                                                                                      Slave_outEPstall |=  (0x01<<((dReq.wIndex>>8)&0x0F)); 
 378   8                                                                                              if(dReq.bRequest==CLEAR_FEATURE)                // clear endpoint stall (limit to 7 OUT's data endpoint)
 379   8                                                                                                      Slave_outEPstall &=  ~(0x01<<((dReq.wIndex>>8)&0x0F)); 
 380   8                                                                                      }
 381   7                                                                                      EP0A_IN_Arm(0,0,1);                                                     // IN status stage
 382   7                                                                              }               
 383   6                                                                              else
 384   6                                                                                      SL811Write(EP0AControl,SEND_STALL);                     // Stall unsupported requests                                           
 385   6                                                                              break;
 386   6      
 387   6                                                                      default: 
 388   6                                                                              SL811Write(EP0AControl,SEND_STALL);                             // Stall all unsupported requests
 389   6                                                                              break;
 390   6                                                              }
 391   5                                                              break;
 392   5      
 393   5                                              case SET_ADDRESS:
 394   5                                                              Slave_USBaddr = dReq.wValue>>8;                                                 // update new USB address assigned by host
 395   5                                                              EP0A_IN_Arm(0,0,1);                                         // IN status stage
 396   5                                                          
 397   5                                                              break;
 398   5                                              case SET_CONFIG:
 399   5                                                              Slave_ConfigVal = dReq.wValue>>8;                                               // update configuration value
 400   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 401   5                                                              if(Slave_ConfigVal)     
 402   5                                                                      SL811Write(EP1AControl,DATA0_IN_ENABLE);                        // Enable EP1 (reponse with NAK)
 403   5                                                              else
 404   5                                                                      SL811Write(EP1AControl,DATA0_IN_DISABLE);                       // Disable EP1
 405   5                                                              break;
 406   5      
 407   5                                              case SET_INTERFACE:                                                                                     // update alternate setting for                                 
 408   5                                                              Slave_IfcAlt[dReq.wIndex>>8] = dReq.wValue>>8;                  // selected interface number
 409   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 410   5                                                              break;
 411   5      
 412   5                                                      default: 
 413   5                                                              SL811Write(EP0AControl,SEND_STALL);                                             // Stall all unsupported requests
 414   5                                                         // EP0A_IN_Arm(0,0,1);       
 415   5                                                              break;
 416   5                                              }
 417   4                                      
 418   4                                              break;
 419   4      
 420   4                                      //---------------------------------------------------------------------
 421   4                                      // Specific Class Requests (HID)
 422   4                                      //---------------------------------------------------------------------
 423   4                                      case CLASS_REQUEST:
 424   4                                          switch (dReq.bRequest)                                                                                      // Parse bRequest
 425   4                                      {   
 426   5                                                  case SET_REPORT:
 427   5                                                            switch(( unsigned char)dReq.wValue)
C51 COMPILER V7.20   SUBP                                                                  06/11/2004 19:40:15 PAGE 8   

 428   5                                                                { 
 429   6                                                                  case INPUT:
 430   6                                                                                   SL811Write(EP0AControl,SEND_STALL);        
 431   6                                                                        break;
 432   6                                          case OUTPUT:
 433   6                                               bReport=1;

⌨️ 快捷键说明

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