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

📄 subp.lst

📁 51单片机与SL811HST做从机的鼠标程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
 298   6      
 299   6                                                      case STRING:
 300   6                                                                              switch(dReq.wValue>>8)                                                                  // get string index
 301   6                                                                              {
 302   7                                                                                      case 0x00: SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)LangString,LangString[0]);
 303   7                                                                                                         len_req = (len_req>=LangString[0]) ? LangString[0]:len_req;
C51 COMPILER V7.20   SUBP                                                                  05/16/2004 23:08:35 PAGE 6   

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

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

 428   5      
 429   5                                              case SET_INTERFACE:                                                                                     // update alternate setting for                                 
 430   5                                                              Slave_IfcAlt[dReq.wIndex>>8] = dReq.wValue>>8;                  // selected interface number
 431   5                                                              EP0A_IN_Arm(0,0,1);                                                                             // IN status stage
 432   5                                                              break;
 433   5      
 434   5                                                      default: 
 435   5                                                              SL811Write(EP0AControl,SEND_STALL);                                             // Stall all unsupported requests
 436   5                                                         // EP0A_IN_Arm(0,0,1);       
 437   5                                                              break;
 438   5                                              }
 439   4                                      
 440   4                                              break;
 441   4      
 442   4                                      //---------------------------------------------------------------------
 443   4                                      // Specific Class Requests (HID)
 444   4                                      //---------------------------------------------------------------------
 445   4                                      case CLASS_REQUEST:
 446   4                                          switch (dReq.bRequest)                                                                                      // Parse bRequest
 447   4                                      {   
 448   5                                                  case SET_REPORT:

⌨️ 快捷键说明

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