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

📄 sl811s.lst

📁 keyword:usb host sl8
💻 LST
📖 第 1 页 / 共 5 页
字号:
 288   6                                                                              SL811BufWrite(EP0A_Slave_Buf,(BYTE*)Dev_Descp,DEV_LEN); // load Device Descp
 289   6                                                                              len_req = (len_req>=DEV_LEN) ? DEV_LEN:len_req;                 // get exact data length
 290   6                                                              break;
 291   6      
 292   6                                                      case CONFIGURATION:
 293   6                                                                              SL811BufWrite(EP0A_Slave_Buf,(BYTE*)Cfg_Descp,CFG_LEN); // load Config Descp    
 294   6                                                                              len_req = (len_req>=CFG_LEN) ? CFG_LEN:len_req;                 // get exact data length
 295   6                                                              break;
 296   6      
 297   6                                                      case HID_DEV:
 298   6                                                                              SL811BufWrite(EP0A_Slave_Buf,(BYTE*)Cfg_Descp+18,HID_LEN);// load HID Class Descp       
 299   6                                                                              len_req = (len_req>=HID_LEN) ? HID_LEN:len_req;                 // get exact data length
 300   6                                                              break;
 301   6      
 302   6                                                      case HID_REPORT:
 303   6                                                                              SL811BufWrite(EP0A_Slave_Buf,(BYTE*)Rep_Descp,REP_LEN); // load Report Descp    
C51 COMPILER V7.09   SL811S                                                                10/04/2004 17:01:23 PAGE 6   

 304   6                                                                              len_req = (len_req>=REP_LEN) ? REP_LEN:len_req;                 // get exact data length
 305   6                                                              break;
 306   6      
 307   6                                                      case STRING:
 308   6                                                                              switch(dReq.wValue>>8)                                                                  // get string index
 309   6                                                                              {
 310   7                                                                                      case 0x00: SL811BufWrite(EP0A_Slave_Buf,(BYTE*)LangString,LangString[0]);
 311   7                                                                                                         len_req = (len_req>=LangString[0]) ? LangString[0]:len_req;
 312   7                                                                                                         break;                               
 313   7                                                                                      case 0x01: SL811BufWrite(EP0A_Slave_Buf,(BYTE*)MfgString,MfgString[0]);
 314   7                                                                                                         len_req = (len_req>=MfgString[0]) ? MfgString[0]:len_req;
 315   7                                                                                                         break;               
 316   7                                                                                      case 0x02: SL811BufWrite(EP0A_Slave_Buf,(BYTE*)ProdString,ProdString[0]);
 317   7                                                                                                         len_req = (len_req>=ProdString[0]) ? ProdString[0]:len_req;
 318   7                                                                                                         break;               
 319   7                                                                              }
 320   6                                                                              break;  
 321   6                                                              }       
 322   5      
 323   5                                                              if (len_req == WordSwap(dReq.wLength))                                  // if requested length is equal to the
 324   5                                                                      IN_EXACT = TRUE;                                                                        // exact length of descriptor, set IN_EXACT
 325   5                                                                                                                                                                              // is use during IN-NULL pkt trasnmission
 326   5                                                              len_xfr = (len_req>=EP0_LEN) ? EP0_LEN:(BYTE)len_req;   // get current IN transfer length
 327   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,len_xfr,1);                                  // Arm IN response, start with DATA1 seq
 328   5                                                              in_buffer_idx += len_xfr;                                                               // update to next muliple buffer location
 329   5                                                              len_req -= len_xfr;                                                                             // update data length for current transfer
 330   5                                                              break;
 331   5      
 332   5                                              case GET_CONFIG:
 333   5                                                              SL811Write(EP0A_Slave_Buf,Slave_ConfigVal);                             // load current configuration value
 334   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,1,1);                                                // send 1 byte data back to host
 335   5                                                              len_req = 0;
 336   5                                                              break;
 337   5      
 338   5                                              case GET_INTERFACE:
 339   5                                                              SL811Write(EP0A_Slave_Buf,Slave_IfcAlt[dReq.wIndex>>8]);// load current alternate setting
 340   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,1,1);                                                // send 1 byte data back to host
 341   5                                                              len_req = 0;
 342   5                                                              break;
 343   5      
 344   5                                              case GET_STATUS:
 345   5                                                              switch(dReq.bmRequest&0x03)                                                             // check for recipients
 346   5                                                              {
 347   6                                                                      case RECIPIENT_DEV:                                                                     // load current device status
 348   6                                                                              SL811Write(EP0A_Slave_Buf,(Slave_RemoteWU<<1)|BUS_POWERED);     
 349   6                                                                              break;
 350   6                                                                      case RECIPIENT_IFC:                                                     
 351   6                                                                              SL811Write(EP0A_Slave_Buf,0);                                   // first byte = 0
 352   6                                                                              break;
 353   6                                                                      case RECIPIENT_ENP:                                                     
 354   6                                                                              if((dReq.wIndex>>8) & 0x80)                                             // for IN direction endpoint
 355   6                                                                              {
 356   7                                                                                      if(Slave_inEPstall & (0x01<<((dReq.wIndex>>8)&0x0F)))   
 357   7                                                                                              SL811Write(EP0A_Slave_Buf,1);                   // first byte = 1 (IN endpoint stall)           
 358   7                                                                                      else
 359   7                                                                                              SL811Write(EP0A_Slave_Buf,0);                   // first byte = 0 (IN endpoint not stall)               
 360   7                                                                              }
 361   6                                                                              else                                                                                    // for OUT direction endpoint
 362   6                                                                              {
 363   7                                                                                      if(Slave_outEPstall & (0x01<<((dReq.wIndex>>8)&0x0F)))  
 364   7                                                                                              SL811Write(EP0A_Slave_Buf,1);                   // first byte = 1 (OUT endpoint stall)          
 365   7                                                                                      else
C51 COMPILER V7.09   SL811S                                                                10/04/2004 17:01:23 PAGE 7   

 366   7                                                                                              SL811Write(EP0A_Slave_Buf,0);                   // first byte = 0 (OUT endpoint not stall)              
 367   7                                                                              }
 368   6                                                                              break;
 369   6                                                              }
 370   5                                                              SL811Write(EP0A_Slave_Buf+1,0);                                                 // second byte = 0
 371   5                                                              EP0A_IN_Arm(EP0A_Slave_Buf,2,1);                                                // send 2 bytes data back to host
 372   5                                                              len_req = 0;                                                                                    // reset request length to zero
 373   5                                                              break;                                                  
 374   5      
 375   5                                              case SET_FEATURE:
 376   5                                              case CLEAR_FEATURE:
 377   5                                                              switch(dReq.bmRequest&0x03)                                                             // check for recipients
 378   5                                                              {
 379   6                                                                      case RECIPIENT_DEV:
 380   6                                                                              if((dReq.wValue>>8) == 1)                                               // feature selector = 1 (remote wakeup)
 381   6                                                                              {
 382   7                                                                                      if(dReq.bRequest==SET_FEATURE)                          // set remote wake up status    
 383   7                                                                                              Slave_RemoteWU = 1;                                             
 384   7                                                                                      if(dReq.bRequest==CLEAR_FEATURE)                        // clear remote wake up status          
 385   7                                                                                              Slave_RemoteWU = 0;                                             
 386   7                                                                                      EP0A_IN_Arm(0,0,1);                                                     // IN status stage
 387   7                                                                              }
 388   6                                                                              else
 389   6                                                                                      SL811Write(EP0AControl,SEND_STALL);                     // Stall unsupported requests                                           
 390   6                                                                              break;
 391   6      
 392   6                                                                      case RECIPIENT_ENP:
 393   6                                                                              if((dReq.wValue>>8) == 0)                                               // feature selector = 0 (endpoint stall)
 394   6                                                                              {
 395   7                                                                                      if((dReq.wIndex>>8) & 0x80)                                     // for IN direction endpoint
 396   7                                                                                      {
 397   8                                                                                              if(dReq.bRequest==SET_FEATURE)                  // set endpoint stall (limit to 7 IN's data endpoint)
 398   8                                                                                                      Slave_inEPstall |=  (0x01<<((dReq.wIndex>>8)&0x0F)); 
 399   8                                                                                              if(dReq.bRequest==CLEAR_FEATURE)                // clear endpoint stall (limit to 7 IN's data endpoint)
 400   8                                                                                                      Slave_inEPstall &=  ~(0x01<<((dReq.wIndex>>8)&0x0F)); 
 401   8                                                                                      }
 402   7                                                                                      else                                                                            // for OUT direction endpoint
 403   7                                                                                      {
 404   8                                                                                              if(dReq.bRequest==SET_FEATURE)                  // set endpoint stall (limit to 7 OUT's data endpoint)
 405   8                                                                                                      Slave_outEPstall |=  (0x01<<((dReq.wIndex>>8)&0x0F)); 
 406   8                                                                                              if(dReq.bRequest==CLEAR_FEATURE)                // clear endpoint stall (limit to 7 OUT's data endpoint)
 407   8                                                                                                      Slave_outEPstall &=  ~(0x01<<((dReq.wIndex>>8)&0x0F)); 
 408   8                                                                                      }
 409   7                                                                                      EP0A_IN_Arm(0,0,1);                                                     // IN status stage
 410   7                                                                              }               
 411   6                                                                              else
 412   6                                                                                      SL811Write(EP0AControl,SEND_STALL);                     // Stall unsupported requests                                           
 413   6                                                                              break;
 414   6      
 415   6                                                                      default: 
 416   6                                                                              SL811Write(EP0AControl,SEND_STALL);                             // Stall all unsupported requests
 417   6                                                                              break;
 418   6                                                              }
 419   5                                                              break;
 420   5      
 421   5                                              case SET_ADDRESS:
 422   5                                                              Slave_USBaddr = dReq.wValue>>8;                                                 // update new USB address assigned by host
 423   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 424   5                                                              break;
 425   5      
 426   5                                              case SET_CONFIG:
 427   5                                                              Slave_ConfigVal = dReq.wValue>>8;                                               // update configuration value
C51 COMPILER V7.09   SL811S                                                                10/04/2004 17:01:23 PAGE 8   

 428   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 429   5                                                              if(Slave_ConfigVal)     
 430   5                                                                      SL811Write(EP1AControl,DATA0_IN_ENABLE);                        // Enable EP1 (reponse with NAK)
 431   5                                                              else
 432   5                                                                      SL811Write(EP1AControl,DATA0_IN_DISABLE);                       // Disable EP1
 433   5                                                              break;

⌨️ 快捷键说明

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