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

📄 usbd_udphs.lst

📁 本代bootloader通过usb下载代码首先存放在sdram中
💻 LST
📖 第 1 页 / 共 5 页
字号:
    658              if( pTransfer->remaining == 0 ) {
    659          
    660                  TRACE_DEBUG_WP("EOT ");
    661                  UDPHS_EndOfTransfer(bEndpoint, result);
    662              }
    663          }
    664          #endif
    665          
    666          
    667          //------------------------------------------------------------------------------
    668          //      Exported functions
    669          //------------------------------------------------------------------------------
    670          
    671          //------------------------------------------------------------------------------
    672          /// USB interrupt handler
    673          /// Manages device resume, suspend, end of bus reset. 
    674          /// Forwards endpoint interrupts to the appropriate handler.
    675          //------------------------------------------------------------------------------
    676          void USBD_InterruptHandler(void)
    677          {
    678              unsigned int  status;
    679              unsigned char numIT;
    680          
    681              if (deviceState >= USBD_STATE_POWERED) {
    682          
    683                  LED_Set(USBD_LEDUSB);
    684              }
    685          
    686              // Get interrupts status
    687              status = AT91C_BASE_UDPHS->UDPHS_INTSTA & AT91C_BASE_UDPHS->UDPHS_IEN;
    688          
    689              // Handle all UDPHS interrupts
    690              TRACE_DEBUG_WP("H");
    691              while (status != 0) {
    692          
    693                  // Start Of Frame (SOF)
    694                  if ((status & AT91C_UDPHS_IEN_SOF) != 0) {
    695          
    696                      TRACE_DEBUG_WP("SOF ");
    697          
    698                      // Invoke the SOF callback
    699                      //USB_StartOfFrameCallback(pUsb);
    700          
    701                      // Acknowledge interrupt
    702                      AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_IEN_SOF;
    703                      status &= ~AT91C_UDPHS_IEN_SOF;
    704                  }
    705                  // Suspend
    706                  // This interrupt is always treated last (hence the '==')
    707                  else if (status == AT91C_UDPHS_DET_SUSPD) {
    708          
    709                      TRACE_DEBUG_WP("S");
    710          
    711                      // The device enters the Suspended state
    712                      // MCK + UDPCK must be off
    713                      // Pull-Up must be connected
    714                      // Transceiver must be disabled
    715          
    716                      LED_Clear(USBD_LEDUSB);
    717          
    718                      UDPHS_DisableBIAS();
    719          
    720                      // Enable wakeup
    721                      AT91C_BASE_UDPHS->UDPHS_IEN |= AT91C_UDPHS_WAKE_UP | AT91C_UDPHS_ENDOFRSM;
    722                      AT91C_BASE_UDPHS->UDPHS_IEN &= ~AT91C_UDPHS_DET_SUSPD;
    723          
    724                      // Acknowledge interrupt
    725                      AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_DET_SUSPD | AT91C_UDPHS_WAKE_UP;
    726                      previousDeviceState = deviceState;
    727                      deviceState = USBD_STATE_SUSPENDED;
    728                      UDPHS_DisableUsbClock();
    729          
    730                      // Invoke the Suspend callback
    731                      USBDCallbacks_Suspended();
    732                  }
    733                  // Resume
    734                  else if( ((status & AT91C_UDPHS_WAKE_UP) != 0)      // line activity
    735                        || ((status & AT91C_UDPHS_ENDOFRSM) != 0))  { // pc wakeup
    736          
    737          //JCB
    738          #ifdef NOT_DEFINED
    739          #if !defined(PIN_USB_VBUS)
    740                      // Configure PIO
    741                      PIO_Configure(&pinVbus, 1);
    742          
    743                      // Check current level on VBus
    744                      if (PIO_Get(&pinVbus) == 1)    // Protection
    745          #endif
    746          #endif
    747                      {
    748                          // Invoke the Resume callback
    749                          USBDCallbacks_Resumed();
    750          
    751                          TRACE_DEBUG_WP("R");
    752          
    753                          UDPHS_EnableUsbClock();
    754                          UDPHS_EnableBIAS();
    755          
    756                          // The device enters Configured state
    757                          // MCK + UDPCK must be on
    758                          // Pull-Up must be connected
    759                          // Transceiver must be enabled
    760          
    761                          deviceState = previousDeviceState;
    762          
    763                          AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_WAKE_UP | AT91C_UDPHS_ENDOFRSM | AT91C_UDPHS_DET_SUSPD;
    764          
    765                          AT91C_BASE_UDPHS->UDPHS_IEN |= AT91C_UDPHS_ENDOFRSM | AT91C_UDPHS_DET_SUSPD;
    766                          AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_WAKE_UP | AT91C_UDPHS_ENDOFRSM;
    767                          AT91C_BASE_UDPHS->UDPHS_IEN &= ~AT91C_UDPHS_WAKE_UP;
    768                      }
    769          // jcb !!!
    770          #ifdef NOT_DEFINED
    771          #if !defined(PIN_USB_VBUS)
    772                      else {
    773          
    774                          // No VBUS
    775                          // Disconnect the pull-up
    776                          USBD_Disconnect();
    777                          AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_WAKE_UP;
    778                      }
    779          #endif
    780          #endif
    781                  }
    782                  // End of bus reset
    783                  else if ((status & AT91C_UDPHS_ENDRESET) == AT91C_UDPHS_ENDRESET) {
    784          
    785          //            TRACE_DEBUG_WP("EoB ");
    786          
    787                      // The device enters the Default state
    788                      deviceState = USBD_STATE_DEFAULT;
    789                      //      MCK + UDPCK are already enabled
    790                      //      Pull-Up is already connected
    791                      //      Transceiver must be enabled
    792                      //      Endpoint 0 must be enabled
    793          
    794                      UDPHS_ResetEndpoints();
    795                      UDPHS_DisableEndpoints();
    796                      USBD_ConfigureEndpoint(0);
    797          
    798                      // Flush and enable the Suspend interrupt
    799                      AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_WAKE_UP | AT91C_UDPHS_DET_SUSPD;
    800          
    801                      //// Enable the Start Of Frame (SOF) interrupt if needed
    802                      //if (pCallbacks->startOfFrame != 0)
    803                      //{
    804                      //    AT91C_BASE_UDPHS->UDPHS_IEN |= AT91C_UDPHS_IEN_SOF;
    805                      //}
    806          
    807                      // Invoke the Reset callback
    808                      USBDCallbacks_Reset();
    809          
    810                      // Acknowledge end of bus reset interrupt
    811                      AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_ENDRESET;
    812          
    813                      AT91C_BASE_UDPHS->UDPHS_IEN |= AT91C_UDPHS_DET_SUSPD;
    814                  }
    815                  // Handle upstream resume interrupt
    816                  else if (status & AT91C_UDPHS_UPSTR_RES) {
    817          
    818                      TRACE_DEBUG_WP("ExtRes ");
    819          
    820                      // - Acknowledge the IT
    821                      AT91C_BASE_UDPHS->UDPHS_CLRINT = AT91C_UDPHS_UPSTR_RES;
    822                  }
    823                  // Endpoint interrupts
    824                  else {
    825          #ifndef DMA
    826                      // Handle endpoint interrupts
    827                      for (numIT = 0; numIT < NUM_IT_MAX; numIT++) {
    828          
    829                          if ((status & (1 << SHIFT_INTERUPT << numIT)) != 0) {
    830          
    831                              UDPHS_EndpointHandler(numIT);
    832                          }
    833                      }
    834          #else
    835                      // Handle endpoint control interrupt
    836                      if ((status & (1 << SHIFT_INTERUPT << 0)) != 0) {
    837          
    838                          UDPHS_EndpointHandler( 0 );
    839                      }
    840                      else {
    841          
    842                          numIT = 1;
    843                          while((status&(0x7E<<SHIFT_DMA)) != 0) {
    844          
    845                              // Check if endpoint has a pending interrupt
    846                              if ((status & (1 << SHIFT_DMA << numIT)) != 0) {
    847          
    848                                  UDPHS_DmaHandler(numIT);
    849                                  status &= ~(1 << SHIFT_DMA << numIT);
    850                                  if (status != 0) {
    851          
    852                                      TRACE_INFO_WP("\n\r  - ");
    853                                  }
    854                              }
    855                              numIT++;
    856                          }
    857                      }
    858          #endif
    859                  }
    860          
    861                  // Retrieve new interrupt status
    862                  status = AT91C_BASE_UDPHS->UDPHS_INTSTA & AT91C_BASE_UDPHS->UDPHS_IEN;
    863          
    864                  TRACE_DEBUG_WP("\n\r");
    865                  if (status != 0) {
    866          
    867                      TRACE_DEBUG_WP("  - ");
    868                  }
    869              }
    870          
    871              if (deviceState >= USBD_STATE_POWERED) {
    872          
    873                  LED_Clear(USBD_LEDUSB);
    874              }
    875          }
    876          
    877          //------------------------------------------------------------------------------
    878          /// Configure an endpoint with the provided endpoint descriptor
    879          /// \param pDdescriptor Pointer to the endpoint descriptor
    880          //------------------------------------------------------------------------------
    881          void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor)
    882          {
    883              Endpoint *pEndpoint;
    884              unsigned char bEndpoint;
    885              unsigned char bType;
    886              unsigned char bEndpointDir;
    887              unsigned char bSizeEpt = 0;
    888          
    889              // NULL descriptor -> Control endpoint 0
    890              if (pDescriptor == 0) {

⌨️ 快捷键说明

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