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

📄 subp.lst

📁 51单片机与SL811HST做从机的鼠标程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
 145   3                     key[5]=key[4]=key[1]=key[2]=key[3]=0x00;
 146   3                     bkey=0;
 147   3                         break;
 148   3                        case 3:
 149   3                     SL811BufWrite(EP1A_Slave_Buf,(unsigned char*)key,0x03);
 150   3                             EP1A_IN_Arm(EP1A_Slave_Buf,0x03,ep1_toggle);     // Arm Ep1 and toggle data
 151   3                     key[5]=key[4]=key[1]=key[2]=key[3]=0x00;
 152   3                     bkey=0;
 153   3                         break;
 154   3                         default:
 155   3                          break;
 156   3                            }
 157   2                         // 
 158   2                       
 159   2             // Delay();
 160   2             //  while((SL811Read(EP1AControl)&0x01)==1);
 161   2             //       while(!(SL811Read(EP1AStatus) & EP_ACK) )       ;               // check for ACK bit set
 162   2              //      ep1_toggle = (((SL811Read(EP1AControl)&DATAX)==0) ? 1:0);
 163   2            //SL811BufWrite(EP1A_Slave_Buf,(unsigned char*)key,0x06);
 164   2              //      EP1A_IN_Arm(EP1A_Slave_Buf,EP1_LEN,ep1_toggle); // Arm Ep1 and toggle data
 165   2                       }
 166   1        
 167   1          else 
 168   1               SL811Write(EP1AControl,0x06);   //NAK
 169   1       }
 170          
 171          //*****************************************************************************************
 172          // Internet Control Key Scanning Routine
 173          //*****************************************************************************************
 174          /*void internet_key_scan(void)
 175          {
 176                  return;
 177          }
 178           */
 179          //*****************************************************************************************
C51 COMPILER V7.20   SUBP                                                                  05/16/2004 23:08:35 PAGE 4   

 180          // EP1 interrupt service routine 
 181          //*****************************************************************************************
 182          void ep1_isr(void)
 183          {
 184   1              SL811Write(IntStatus,EP1_DONE);                                 // clear EP1 interrupt  
 185   1              if(SL811Read(EP1AStatus) & EP_ACK)                              // check for ACK bit set
 186   1                {     ep1_toggle = (((SL811Read(EP1AControl)&DATAX)==0) ? 1:0);                       
 187   2                                                                                                              // toggle DATA sequence         
 188   2            //  audio_key_scan();
 189   2                      }
 190   1                                                                                                      //      return;
 191   1      }
 192          
 193          //*****************************************************************************************
 194          // EP1's IN Token Arming (using Set A)
 195          //*****************************************************************************************
 196          void EP1A_IN_Arm( unsigned char buf_adr,  unsigned char len,  unsigned char seq)
 197          {                                                                                               
 198   1          SL811Write(EP1AAddress,buf_adr);                            // ep1 address buffer start adress
 199   1              SL811Write(EP1AXferLen,len);                                    // max length of transfer allowed
 200   1              if(seq)
 201   1                  SL811Write(EP1AControl,DATA1_IN);                   // armed to transmit to host, DATA1
 202   1              else
 203   1                  SL811Write(EP1AControl,DATA0_IN);                   // armed to transmit to host, DATA0
 204   1      }
 205          
 206          //*****************************************************************************************
 207          // SOF interrupt service routine (act as 1ms timer)
 208          //*****************************************************************************************
 209          void sof_isr(void)
 210          {
 211   1              SL811Write(IntStatus,SOF_DONE);                                 // clear SOF interrupt          
 212   1              //sof_cnt++;                                                                            // track msec timing
 213   1      
 214   1       //     if(sof_cnt==TIME_OUT)                                                   //5 reset counter on specify 
 215   1      //      {                                                                                               // time out.                            
 216   1                      sof_cnt = 0;                                                            
 217   1              //      timeout = 1;                                                            // set timeout flag
 218   1      //      }
 219   1      
 220   1      
 221   1      }
 222          
 223          
 224                  
 225          //*****************************************************************************************
 226          // EP0 interrupt service routine
 227          //*****************************************************************************************
 228          //int ep0_isr(void)
 229          void  ep0_isr(void)
 230          {
 231   1               unsigned char  status,  byte_rx, len_xfr;
 232   1               unsigned char   req_type,data_seq;
 233   1      
 234   1              SL811Write(IntStatus,EP0_DONE); // clear EP0 interrupt  
 235   1              status  = SL811Read(EP0AStatus);                                                        // get packet status
 236   1              byte_rx = SL811Read(EP0AXferLen) - SL811Read(EP0ACounter);      // get no. of  unsigned chars received
 237   1                                                                                                                                      // for OUT data from host
 238   1              //----------------------------------------------------------------------------------------
 239   1              // ACK received 
 240   1              //----------------------------------------------------------------------------------------
 241   1              if(status & EP_ACK)
C51 COMPILER V7.20   SUBP                                                                  05/16/2004 23:08:35 PAGE 5   

 242   1              {
 243   2                      //----------------------------------------------------------------
 244   2                      // Set newly assigned USB address
 245   2                      //----------------------------------------------------------------
 246   2                      if(Slave_USBaddr)                                                               
 247   2                  {                                                                                                           // if new USB address was assigned, 
 248   3                          SL811Write(USBAddress,Slave_USBaddr);                               // communicate all USB transaction      
 249   3                      Slave_USBaddr = 0;                                                                      // using this new address.                              
 250   3                      }
 251   2              
 252   2                      //================================================================
 253   2                      // SETUP's ACKed
 254   2                      //================================================================
 255   2                      //status        = SL811Read(EP0AStatus);
 256   2                      if(status & EP_SETUP)                                   
 257   2                      {
 258   3                       
 259   3                      SL811BufRead(EP0A_Slave_Buf, ( unsigned char*)&dReq,  byte_rx);                 // capture SETUP data request
 260   3                              len_req = WordSwap(dReq.wLength);                                                       // len_req = actual requested length
 261   3                              in_buffer_idx = 0;                                                                                      // reset buffer locatio indexing
 262   3                              IN_NULL = FALSE;                                                                                        // these are for IN-NULL packet
 263   3                              IN_EXACT = FALSE;                                                                                       // transfer condition
 264   3                              req_type = (dReq.bmRequest&0x60)>>5;                                            // decode for Std,Class,Vendor type
 265   3                   
 266   3                          switch (req_type)                                                                                   // Parse bmRequest Type
 267   3                              {     
 268   4                                      //---------------------------------------------------------------------
 269   4                                      // Standard USB Requests
 270   4                                      //---------------------------------------------------------------------
 271   4                                      case STD_REQUEST:
 272   4                                          switch (dReq.bRequest)                                                              // Parse bRequest
 273   4                                      { 
 274   5                                              case GET_DESCRIPTOR:
 275   5                                                      switch (( unsigned char)dReq.wValue)                            // Parse wValue
 276   5                                              {         
 277   6                                                              case DEVICE:
 278   6                                                                              SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)Dev_Descp,DEV_LEN);       // load Device Descp
 279   6                                                                              len_req = (len_req>=DEV_LEN) ? DEV_LEN:len_req;                 // get exact data length                                                                                                         
 280   6                                                                                      
 281   6                                                                              break;
 282   6      
 283   6                                                      case CONFIGURATION:
 284   6                                                                              SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)Cfg_Descp,CFG_LEN);       // load Config Descp    
 285   6                                                                              len_req = (len_req>=CFG_LEN) ? CFG_LEN:len_req; // get exact data length
 286   6                                                         
 287   6                                                                              break;
 288   6      
 289   6                                                      case HID_DEV:
 290   6                                                                              SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)Cfg_Descp+18,HID_LEN);// load HID Class Descp     
 291   6                                                                              len_req = (len_req>=HID_LEN) ? HID_LEN:len_req;                 // get exact data length
 292   6                                                              break;
 293   6      
 294   6                                                      case HID_REPORT:
 295   6                                                                              SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)Rep_Descp,REP_LEN);       // load Report Descp    
 296   6                                                                              len_req = (len_req>=REP_LEN) ? REP_LEN:len_req;                 // get exact data length
 297   6                                                              break;

⌨️ 快捷键说明

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