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

📄 usb.lst

📁 非常全的nrf2401设计资料
💻 LST
📖 第 1 页 / 共 2 页
字号:
 224   1          packetizer_pkt_size = MAX_PACKET_SIZE_EP0;
 225   1          // Switch on descriptor type
 226   1          switch(setupbuf[3])
 227   1          {
 228   2              case USB_DESC_DEVICE:
 229   2                  packetizer_data_ptr = (uint8_t*)&g_usb_dev_desc;
 230   2                  packetizer_data_size = MIN(setupbuf[6], sizeof(usb_dev_desc_t));
 231   2                  packetizer_isr_ep0_in();
 232   2                  break;
 233   2      
 234   2              case USB_DESC_CONFIGURATION:
 235   2                  // For now we just support one configuration. The asked configuration is stored in LSB(wValue)
             -.
 236   2                  packetizer_data_ptr = (uint8_t*)&g_usb_conf_desc;
 237   2                  packetizer_data_size = MIN(setupbuf[6], sizeof(usb_conf_desc_bootloader_t));
 238   2                  packetizer_isr_ep0_in();
 239   2                  break;
C51 COMPILER V7.50   USB                                                                   03/05/2008 17:32:45 PAGE 5   

 240   2      
 241   2              case USB_DESC_STRING:
 242   2                  // For now we just support english as string descriptor language.
 243   2                  if(setupbuf[2] == 0x00)
 244   2                  {
 245   3                      packetizer_data_ptr = string_zero;
 246   3                      packetizer_data_size = MIN(setupbuf[6], sizeof(string_zero));
 247   3                      packetizer_isr_ep0_in();
 248   3                  }
 249   2                  else
 250   2                  {
 251   3                      if((setupbuf[2] - 1) < USB_STRING_DESC_COUNT)
 252   3                      {
 253   4                          if (setupbuf[2] == 1)
 254   4                              packetizer_data_ptr = g_usb_string_desc_1;
 255   4                          else
 256   4                              packetizer_data_ptr = g_usb_string_desc_2;;
 257   4                          packetizer_data_size = MIN(setupbuf[6], packetizer_data_ptr[0]);
 258   4                          packetizer_isr_ep0_in();
 259   4                      }
 260   3                      else
 261   3                      {
 262   4                          USB_EP0_STALL();
 263   4                      }
 264   3                  }
 265   2                  break;
 266   2              case USB_DESC_INTERFACE:
 267   2              case USB_DESC_ENDPOINT:
 268   2              case USB_DESC_DEVICE_QUAL:
 269   2              case USB_DESC_OTHER_SPEED_CONF:
 270   2              case USB_DESC_INTERFACE_POWER:
 271   2                  USB_EP0_STALL();
 272   2                  break;
 273   2              default:
 274   2                  USB_EP0_HSNAK();
 275   2                  break;
 276   2          }
 277   1      }
 278          
 279          static void isr_sudav()
 280          {
 281   1          bmRequestType = setupbuf[0];
 282   1          if((bmRequestType & 0x60 ) == 0x00)
 283   1          {
 284   2              switch(setupbuf[1])
 285   2              {
 286   3                 case USB_REQ_GET_DESCRIPTOR:
 287   3                     usb_process_get_descriptor();
 288   3                     break;
 289   3      
 290   3                 case USB_REQ_GET_STATUS:
 291   3                     usb_process_get_status();
 292   3                     break;
 293   3      
 294   3                  case USB_REQ_SET_ADDRESS:
 295   3                     usb_state = ADDRESSED;
 296   3                     usb_current_config = 0x00;
 297   3                     break;
 298   3      
 299   3                  case USB_REQ_GET_CONFIGURATION:
 300   3                      switch(usb_state)
 301   3                      {
C51 COMPILER V7.50   USB                                                                   03/05/2008 17:32:45 PAGE 6   

 302   4                          case ADDRESSED:
 303   4                              in0buf[0] = 0x00;
 304   4                              in0bc = 0x01;
 305   4                              break;
 306   4                          case CONFIGURED:
 307   4                              in0buf[0] = usb_current_config;
 308   4                              in0bc = 0x01;
 309   4                              break;
 310   4                          case ATTACHED:
 311   4                          case POWERED:
 312   4                          case SUSPENDED:
 313   4                          case DEFAULT:
 314   4                          default:
 315   4                              USB_EP0_STALL();
 316   4                              break;
 317   4                      }
 318   3                      break;
 319   3      
 320   3                  case USB_REQ_SET_CONFIGURATION:
 321   3                      switch(setupbuf[2])
 322   3                      {
 323   4                          case 0x00:
 324   4                              usb_state = ADDRESSED;
 325   4                              usb_current_config = 0x00;
 326   4                              USB_EP0_HSNAK();
 327   4                              break;
 328   4                          case 0x01:
 329   4                              usb_state = CONFIGURED;
 330   4                              usb_bm_state |= USB_BM_STATE_CONFIGURED;
 331   4                              usb_current_config = 0x01;
 332   4                              USB_EP0_HSNAK();
 333   4                              break;
 334   4                          default:
 335   4                              USB_EP0_STALL();
 336   4                              break;
 337   4                      }
 338   3                     break;
 339   3      
 340   3                  case USB_REQ_GET_INTERFACE: // GET_INTERFACE
 341   3                      in0buf[0] = usb_current_alt_interface;
 342   3                      in0bc = 0x01;
 343   3                      break;
 344   3      
 345   3                  case USB_REQ_SET_DESCRIPTOR:
 346   3                  case USB_REQ_SET_INTERFACE: // SET_INTERFACE
 347   3                  case USB_REQ_SYNCH_FRAME:   // SYNCH_FRAME
 348   3                  default:
 349   3                      USB_EP0_STALL();
 350   3                      break;
 351   3              }
 352   2          } 
 353   1          // bmRequestType = 0 01 xxxxx : Data transfer direction: Host-to-device, Type: Class
 354   1          else if((bmRequestType & 0x60 ) == 0x20)  // Class request
 355   1          {
 356   2              if(setupbuf[6] != 0 && ((bmRequestType & 0x80) == 0x00))
 357   2              {
 358   3                  // If there is a OUT-transaction associated with the Control-Transfer-Write we call the callba
             -ck
 359   3                  // when the OUT-transaction is finished. Note that this function do not handle several out tra
             -nsactions.
 360   3                  out0bc = 0xff;
 361   3              }
C51 COMPILER V7.50   USB                                                                   03/05/2008 17:32:45 PAGE 7   

 362   2              else
 363   2              {
 364   3                  USB_EP0_HSNAK();
 365   3              }
 366   2          } 
 367   1          else  // Unknown request type
 368   1          {
 369   2              USB_EP0_STALL();
 370   2          }
 371   1      }
 372          
 373          void usb_irq(void)
 374          {
 375   1          //
 376   1          // Split case into an if and a switch to force Keil into not using a library function:
 377   1          if (ivec == INT_USBRESET)
 378   1          {
 379   2              usbirq = 0x10;
 380   2              usb_state = DEFAULT;
 381   2              usb_current_config = 0;
 382   2              usb_current_alt_interface = 0;
 383   2              usb_bm_state = 0;
 384   2          }
 385   1          else
 386   1          {
 387   2              switch(ivec)
 388   2              {
 389   3                  case INT_SUDAV:
 390   3                      usbirq = 0x01;
 391   3                      isr_sudav();
 392   3                      break;
 393   3                  case INT_SOF:
 394   3                      usbirq = 0x02;
 395   3                      break;
 396   3                  case INT_SUTOK:
 397   3                      usbirq = 0x04;
 398   3                      packetizer_data_ptr = NULL;
 399   3                      packetizer_data_size = 0;
 400   3                      packetizer_pkt_size = 0;
 401   3                      break;
 402   3                  case INT_SUSPEND:
 403   3                      usbirq = 0x08;
 404   3                      break;
 405   3                  case INT_EP0IN:
 406   3                      in_irq = 0x01;
 407   3                      packetizer_isr_ep0_in();
 408   3                      break;
 409   3                  case INT_EP0OUT:
 410   3                      out_irq = 0x01;
 411   3                      packetizer_data_size = 0;
 412   3                      //        req.misc_data = out0buf;
 413   3                      USB_EP0_HSNAK();
 414   3                      break;
 415   3                  case INT_EP1IN:
 416   3                      // Clear interrupt 
 417   3                      in_irq = 0x02;
 418   3                      in1cs = 0x02;
 419   3                      break;
 420   3                  case INT_EP1OUT:
 421   3                      // Clear interrupt
 422   3                      out_irq = 0x02;     
 423   3                      packet_received = true;
C51 COMPILER V7.50   USB                                                                   03/05/2008 17:32:45 PAGE 8   

 424   3                      out1bc = 0xff;
 425   3                      break;
 426   3                  default:
 427   3                      break;
 428   3              }
 429   2          }
 430   1      }
 431          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    826    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     10    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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