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

📄 subp.lst

📁 51单片机与SL811HST做从机的音频控制程序
💻 LST
📖 第 1 页 / 共 4 页
字号:
 330   6                                                                              break;
 331   6      
 332   6                                                                      case RECIPIENT_ENP:
 333   6                                                                              if((dReq.wValue>>8) == 0)                                               // feature selector = 0 (endpoint stall)
 334   6                                                                              {
 335   7                                                                                      if((dReq.wIndex>>8) & 0x80)                                     // for IN direction endpoint
 336   7                                                                                      {
 337   8                                                                                              if(dReq.bRequest==SET_FEATURE)                  // set endpoint stall (limit to 7 IN's data endpoint)
 338   8                                                                                                      Slave_inEPstall |=  (0x01<<((dReq.wIndex>>8)&0x0F)); 
 339   8                                                                                              if(dReq.bRequest==CLEAR_FEATURE)                // clear endpoint stall (limit to 7 IN's data endpoint)
 340   8                                                                                                      Slave_inEPstall &=  ~(0x01<<((dReq.wIndex>>8)&0x0F)); 
 341   8                                                                                      }
 342   7                                                                                      else                                                                            // for OUT direction endpoint
 343   7                                                                                      {
 344   8                                                                                              if(dReq.bRequest==SET_FEATURE)                  // set endpoint stall (limit to 7 OUT's data endpoint)
 345   8                                                                                                      Slave_outEPstall |=  (0x01<<((dReq.wIndex>>8)&0x0F)); 
 346   8                                                                                              if(dReq.bRequest==CLEAR_FEATURE)                // clear endpoint stall (limit to 7 OUT's data endpoint)
 347   8                                                                                                      Slave_outEPstall &=  ~(0x01<<((dReq.wIndex>>8)&0x0F)); 
 348   8                                                                                      }
 349   7                                                                                      EP0A_IN_Arm(0,0,1);                                                     // IN status stage
 350   7                                                                              }               
 351   6                                                                              else
 352   6                                                                                      SL811Write(EP0AControl,SEND_STALL);                     // Stall unsupported requests                                           
 353   6                                                                              break;
 354   6      
 355   6                                                                      default: 
 356   6                                                                              SL811Write(EP0AControl,SEND_STALL);                             // Stall all unsupported requests
 357   6                                                                              break;
 358   6                                                              }
 359   5                                                              break;
 360   5      
 361   5                                              case SET_ADDRESS:
 362   5                                                              Slave_USBaddr = dReq.wValue>>8;                                                 // update new USB address assigned by host
 363   5                                                              EP0A_IN_Arm(0,0,1);                                         // IN status stage
 364   5                                                          
 365   5                                                              break;
C51 COMPILER V7.20   SUBP                                                                  07/05/2004 23:23:35 PAGE 7   

 366   5                                              case SET_CONFIG:
 367   5                                                              Slave_ConfigVal = dReq.wValue>>8;                                               // update configuration value
 368   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 369   5                                                              if(Slave_ConfigVal)     
 370   5                                                                      SL811Write(EP1AControl,DATA0_IN_ENABLE);                        // Enable EP1 (reponse with NAK)
 371   5                                                              else
 372   5                                                                      SL811Write(EP1AControl,DATA0_IN_DISABLE);                       // Disable EP1
 373   5                                                              break;
 374   5      
 375   5                                              case SET_INTERFACE:                                                                                     // update alternate setting for                                 
 376   5                                                              Slave_IfcAlt[dReq.wIndex>>8] = dReq.wValue>>8;                  // selected interface number
 377   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 378   5                                                              break;
 379   5      
 380   5                                                      default: 
 381   5                                                              SL811Write(EP0AControl,SEND_STALL);                                             // Stall all unsupported requests
 382   5                                                         // EP0A_IN_Arm(0,0,1);       
 383   5                                                              break;
 384   5                                              }
 385   4                                      
 386   4                                              break;
 387   4      
 388   4                                      //---------------------------------------------------------------------
 389   4                                      // Specific Class Requests (HID)
 390   4                                      //---------------------------------------------------------------------
 391   4                                      case CLASS_REQUEST:
 392   4                                          switch (dReq.bRequest)                                                                                      // Parse bRequest
 393   4                                      {
 394   5                                              case GET_IDLE:
 395   5                                                              SL811Write(EP0A_Slave_Buf,Slave_IdleRate);                              // load current idle rate value
 396   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,1,1);                                                // send 1  BYTE data back to host
 397   5                                                              len_req = 0;
 398   5                                                              break;  
 399   5      
 400   5                                              case GET_PROTOCOL:
 401   5                                                              SL811Write(EP0A_Slave_Buf,Slave_Protocol);                              // load current protocol state
 402   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,1,1);                                                // send 1  BYTE data back to host
 403   5                                                              len_req = 0;
 404   5                                                              break;  
 405   5      
 406   5                                              case SET_IDLE:
 407   5                                                              Slave_IdleRate = ( BYTE)dReq.wValue;                                            // update Idle Rate (upper  BYTE of wValue)
 408   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 409   5                                                              break;
 410   5      
 411   5                                              case SET_PROTOCOL:
 412   5                                                              Slave_Protocol = dReq.wValue>>8;                                                // update protocol value, 0=Boot, 1=report
 413   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 414   5                                                              break;
 415   5                                      
 416   5                                                      default: 
 417   5                                                              SL811Write(EP0BControl,SEND_STALL);                                             // Stall all unsupported requests
 418   5                                                              break;
 419   5                                              }
 420   4                                              break;
 421   4      
 422   4                                      //---------------------------------------------------------------------
 423   4                                      // Specific Vendor Requests
 424   4                                      //---------------------------------------------------------------------
 425   4                                      case VENDOR_REQUEST:
 426   4                                              SL811Write(EP0AControl,SEND_STALL);                                                             // Stall all unsupported requests
 427   4                                              break;
C51 COMPILER V7.20   SUBP                                                                  07/05/2004 23:23:35 PAGE 8   

 428   4      
 429   4                                      //---------------------------------------------------------------------
 430   4                                      // Unsupported Requests
 431   4                                      //---------------------------------------------------------------------
 432   4                                      default: 
 433   4                                              SL811Write(EP0AControl,SEND_STALL);                                                             // Stall all unsupported requests
 434   4                                              break;
 435   4                              }
 436   3                
 437   3                      }            // if(statuse&EP_setup) 
 438   2      
 439   2                      //================================================================
 440   2                      // IN/OUT token received from host
 441   2                      //================================================================
 442   2                      
 443   2                      else
 444   2                      {       
 445   3                              //---------------------------------
 446   3                              // IN's ACKed
 447   3                              //---------------------------------
 448   3                              if(SL811Read(EP0AControl)&DIRECTION)
 449   3                              {
 450   4                                      if(dev_first==0)                                                                                // happens on the first get device descp
 451   4                                      {                                                                                                               // the host terminate IN transfer prematurely
 452   5                                                  len_req = 0;                                                                                // (if EP0 maxpktsize is only 8  BYTEs)                 
 453   5                                              dev_first = 1;                                                                          // reset len_req, end with OUT status stage
 454   5                                      }       
 455   4      
 456   4                                      //--------------------------------------                                        
 457   4                                      // Continue with next IN if needed
 458   4                                      //--------------------------------------                                        
 459   4                                      if(len_req)                                                                                                                     
 460   4                                      {                                                               
 461   5                                              data_seq = (((SL811Read(EP0AControl)&DATAX)==0) ? 1:0);                 // toggle DATA sequence
 462   5                                              len_xfr = (len_req>=EP0_LEN) ? EP0_LEN:( BYTE)len_req;                  // get transfer length for EP0
 463   5                                              
 464   5                                              if(!IN_NULL)                // point to correct buffer location
 465   5                                              {
 466   6                                      EP0A_IN_Arm(EP0A_Slave_Buf+in_buffer_idx, len_xfr, data_seq);
 467   6                                              }
 468   5                                              else
 469   5                                                 {EP0A_IN_Arm(0,0,data_seq);}                                                         // transfer zero Null packet    
 470   5      
 471   5                                              in_buffer_idx += len_xfr;                                                                               // update buffer location
 472   5                                              len_req -= len_xfr;                                                                                             // update remaining data length
 473   5      
 474   5                                              if(len_req==0 && len_xfr==EP0_LEN && !IN_EXACT)                                 // handles null packet of data length                                   
 475   5                                              {                                                                                                                               // to host is multiple of EP0_LEN, and
 476   6                                                      len_req = 1;                                                                                            // only if host request more than this
 477   6                                                      IN_NULL = TRUE;                                                                                         // value of length, otherwise, the extra
 478   6                                              }                                                                                                                               // null pkt is not require.
 479   5                                      }
 480   4      
 481   4                                      //--------------------------------------                                        
 482   4                                      // Arm Status Stage OUT or new SETUP                                                            
 483   4                                      //--------------------------------------                                        
 484   4                                      else// Arm status OUT or next SETUP requests    
 485   4                                  {   
 486   5                                        EP0A_OUT_Arm(EP0_LEN);                // i.e. end of IN status stage.
 487   5                                      }
 488   4                              }
 489   3      
C51 COMPILER V7.20   SUBP                                                                  07/05/2004 23:23:35 PAGE 9   

 490   3                              //---------------------------------
 491   3                              // OUT's ACKed
 492   3                              //---------------------------------
 493   3                              else 
 494   3                              {
 495   4                                      if( byte_rx==0)                                                                 // zero data packet received
 496   4                                      {
 497   5                                              EP0A_OUT_Arm(EP0_LEN);                                          // get ready for next SETUP token

⌨️ 快捷键说明

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