亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fw.c

?? HIGH_SPEED_USB_To_ATA(IDE)Firmware相關代碼(EZ USB FX2芯片)
?? C
字號:
//-----------------------------------------------------------------------------
//   File:      fw.c
//   Contents:   Firmware frameworks task dispatcher and device request parser
//            source.
//
// indent 3.  NO TABS!
//
//   Copyright (c) 2001 Cypress Semiconductor
//
// $Archive: /USB/atapifx2/software/fw.c $
// $Date: 1/15/02 10:12a $
// $Revision: 45 $
//-----------------------------------------------------------------------------
#include "fx2.h"
#include "fx2regs.h"
#include "gpif.h"
#include "atapi.h"

//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
#define DELAY_COUNT   0x9248*8L      // Delay for 8 sec at 24Mhz, 4 sec at 48
// USB constants
// Class specific setup commands
#define SC_BOMS_RESET           (0x21)      // Hard/soft depends on wValue field 0 = hard

//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------
BOOL      Rwuen;
BOOL      Selfpwr;
volatile BOOL   Sleep;                  // Sleep mode enable flag
BYTE   AlternateSetting;   // Alternate settings
BYTE   Configuration;      // Current configuration


//WORD   pDeviceDscr;   // Pointer to Device Descriptor; Descriptors may be moved
//WORD   pDeviceQualDscr;
//WORD   pHighSpeedConfigDscr;
//WORD   pFullSpeedConfigDscr;   
WORD   pConfigDscr;
WORD   pOtherConfigDscr;   
//WORD   pStringDscr;

BYTE intrfcSubClass;

//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
void SetupCommand(void);
void TD_Init(void);
void TD_Poll(void);
//BOOL TD_Suspend(void);
//BOOL TD_Resume(void);
void DisconAndWaitForVbus();

WORD wPacketSize;


//-----------------------------------------------------------------------------
// Code
//-----------------------------------------------------------------------------

// Task dispatcher

void main(void)
{
   BYTE     i;

   // Init globals
   MaxPIO = 0;                // reset MaxPIO value
   Sleep = FALSE;             // Reset suspend flag
   Rwuen = FALSE;             // Disable remote wakeup
   Selfpwr = FALSE;           // Disable self powered

   // if we are hung up in a GPIF transfer, abort it.  How could this happen?  If
   // we ended up here after a USB Reset or a MSC Reset, it is possible that the
   // GPIF is hung waiting for a transfer that will never complete.
   abortGPIF(); // TPM: Unconditionally abort

   TD_Init();

   // The following section of code is used to relocate the descriptor table from
   // ROM to RAM.  It is done here because we are done with the halfKBuffer at this point.
   // Although it looks wierd, the only way to get the proper values for the offsets
   // is to tell the compiler that we want the address of the variable, not the variable itself.
   mymemmovexx(halfKBuffer, (char xdata *) &DeviceDscr, (WORD)&DscrEndOffset);
//   pDeviceDscr = (WORD)(halfKBuffer + (WORD)&DeviceDscrOffset);
//   pDeviceQualDscr = (WORD)(halfKBuffer + (WORD)&DeviceQualDscrOffset);
//   pHighSpeedConfigDscr = (WORD)(halfKBuffer + (WORD)&HighSpeedConfigDscrOffset);
//   pFullSpeedConfigDscr = (WORD)(halfKBuffer + (WORD)&FullSpeedConfigDscrOffset);
//   pStringDscr = (WORD)(halfKBuffer + (WORD)&StringDscrOffset);

   halfKBuffer[(WORD) &IntrfcSubClassHighSpeedOffset] = 
      halfKBuffer[(WORD) &IntrfcSubClassFullSpeedOffset] = intrfcSubClass;


   for (i = 0; i < ATAPI_INQUIRY_SERIAL_LEN *2; i++)
      halfKBuffer[i+(WORD)&SerialNumberOffset] = localSerialNumber[i];
  
   EZUSB_IRQ_ENABLE();            // Enable USB interrupt (INT2)
   EZUSB_ENABLE_RSMIRQ();            // Wake-up interrupt

   INTSETUP |= (bmAV2EN);     // Enable INT 2 autovectoring

   USBIE |= bmSUDAV | bmSUSP | bmURES | bmHSGRANT;   // Enable selected interrupts
   EA = 1;                  // Enable 8051 interrupts

   // Renumerate if necessary.  Do this by checking the renum bit.  If it
   // is already set, there is no need to renumerate.  The renum bit will
   // already be set if this firmware was loaded from an eeprom or if we
   // have already been through this code once and we are here again
   // because of a USB Reset.
   if(!(USBCS & bmRENUM))
   {
       EZUSB_Discon(TRUE);   // renumerate
   }

#ifdef VBUS_DETECT
   // check for the presence of VBus and re-connect.  If we loaded from eeprom
   // we are disconnected and need to connect.  If we just renumerated this
   // is not necessary but doesn't hurt anything.  VBus on the Rev *B 4611 boards
   // is tied to port A.6.
   if (IOA & bmBIT6)
   {
      USBCS &=~bmDISCON;
   }
   else
   {
      DisconAndWaitForVbus();
   }
#else
   // unconditionally re-connect.  If we loaded from eeprom we are
   // disconnected and need to connect.  If we just renumerated this
   // is not necessary but doesn't hurt anything
   USBCS &=~bmDISCON;
#endif

   CKCON = (CKCON&(~bmSTRETCH)) | FW_STRETCH_VALUE; // Set stretch to 0 (after renumeration)

   // complete the handshake phase of any pending SETUP transfer.
   // The only time this should happen is after a MSC Reset.  We want
   // to go through all of the EP init code before handshaking the status
   // phase of the MSC Reset.
   EP0CS |= bmHSNAK;

   // Task Dispatcher
   while(TRUE)                     // Main Loop
   {
#ifdef VBUS_DETECT
      // we need to constantly monitor VBus (tied to Port A.6) and disconnect if
      // it isn't there.  This is to avoid driving D+ (a spec violation) when the
      // host isn't there.
      if (!(IOA & bmBIT6))
         DisconAndWaitForVbus();
#endif

      TD_Poll();
   }
}

#ifdef VBUS_DETECT
// This function monitors VBus from the host and stays disconnected until VBus is
// is present.  VBus is tied to Port A.6 on the new FX2 ATAPI tailgate boards.
// (4611 Rev *B)
void DisconAndWaitForVbus()
{
   USBCS |= bmDISCON;
   while (!(IOA & bmBIT6));
   USBCS &= ~bmDISCON;
}
#endif
   

// Device request parser
void SetupCommand(void)
{
   void   *dscr_ptr;

   switch(SETUPDAT[1])
   {
      case SC_GET_DESCRIPTOR:                      // *** Get Descriptor
         switch(SETUPDAT[3])         
            {
               case GD_DEVICE:                     // Device
                  SUDPTRH = MSB(pDeviceDscr);
                  SUDPTRL = LSB(pDeviceDscr);
                  break;
               case GD_DEVICE_QUALIFIER:            // Device Qualifier
                  SUDPTRH = MSB(pDeviceQualDscr);
                  SUDPTRL = LSB(pDeviceQualDscr);
                  break;
               case GD_CONFIGURATION:              // Configuration
                  SUDPTRH = MSB(pConfigDscr);
                  SUDPTRL = LSB(pConfigDscr);
                  break;
               case GD_OTHER_SPEED_CONFIGURATION:  // Other Speed Configuration
                  // fx2bug - need to support multi other configs
                  SUDPTRH = MSB(pOtherConfigDscr);
                  SUDPTRL = LSB(pOtherConfigDscr);
                  break;
               case GD_STRING:            // String
                  if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
                  {
                     SUDPTRH = MSB(dscr_ptr);
                     SUDPTRL = LSB(dscr_ptr);
                  }
                  else 
                     EZUSB_STALL_EP0();   // Stall End Point 0
                  break;
               default:                   // Invalid request
                  EZUSB_STALL_EP0();      // Stall End Point 0
            }  // switch
         break;
      case SC_GET_INTERFACE:                  // *** Get Interface
         EP0BUF[0] = AlternateSetting;
         EP0BCH = 0;
         EP0BCL = 1;
         break;
      case SC_SET_INTERFACE:                  // *** Set Interface
         AlternateSetting = SETUPDAT[2];
         break;
      case SC_SET_CONFIGURATION:               // *** Set Configuration
      // BUGBUG -- Add delay for the CATC
         Configuration = SETUPDAT[2];
         break;
      case SC_GET_CONFIGURATION:               // *** Get Configuration
         EP0BUF[0] = Configuration;
         EP0BCH = 0;
         EP0BCL = 1;
         break;
      case SC_GET_STATUS:                 // *** Get Status
            switch(SETUPDAT[0])
            {
               case GS_DEVICE:            // Device
                  EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
                  EP0BUF[1] = 0;
                  EP0BCH = 0;
                  EP0BCL = 2;
                  break;
               case GS_INTERFACE:         // Interface
                  EP0BUF[0] = 0;
                  EP0BUF[1] = 0;
                  EP0BCH = 0;
                  EP0BCL = 2;
                  break;
               case GS_ENDPOINT:         // End Point
                  if (SETUPDAT[4] == 0x2)
                  {
                     EP0BUF[0] = (EP2CS & bmEPSTALL);
                  }
                  else if (SETUPDAT[4] == 0x88)
                  {
                     EP0BUF[0] = (EP8CS & bmEPSTALL);
                  }
                  else
                  {
                     EZUSB_STALL_EP0();   // Stall End Point 0
                     break;
                  }

                  EP0BUF[1] = 0;
                  EP0BCH = 0;
                  EP0BCL = 2;
                  break;
               default:                   // Invalid Command
                  EZUSB_STALL_EP0();      // Stall End Point 0
            }
         break;
      case SC_CLEAR_FEATURE:                  // *** Clear Feature
            switch(SETUPDAT[0])
            {
               case FT_DEVICE:            // Device
                  if(SETUPDAT[2] == 1)
                     Rwuen = FALSE;       // Disable Remote Wakeup
                  else
                     EZUSB_STALL_EP0();   // Stall End Point 0
                  break;
               case FT_ENDPOINT:          // End Point
                  if(SETUPDAT[2] == 0)
                  {
                     if (SETUPDAT[4] == 0x2)
                     {
                        ResetAndArmEp2();
                        TOGCTL = 0x2;
                        TOGCTL = 0x22;       // reset data toggle
                        EP2CS = 0;           // Clear stall bit
                     }
                     else if (SETUPDAT[4] == 0x88)
                        {
                        TOGCTL = 0x18;
                        TOGCTL = 0x38;       // reset data toggle
                        EP8CS = 0;           // Clear stall bit
                        }
                     else
                        EZUSB_STALL_EP0();   // Stall End Point 0
                     }
                  else
                     EZUSB_STALL_EP0();      // Stall End Point 0
                  break;
            }  
         break;
      case SC_SET_FEATURE:                  // *** Set Feature
            switch(SETUPDAT[0])
            {
               case FT_DEVICE:            // Device
                  if(SETUPDAT[2] == 1)
                     Rwuen = TRUE;        // Enable Remote Wakeup
                  else if(SETUPDAT[2] == 2)
                     // Set Feature Test Mode.  The core handles this request.  However, it is
                     // necessary for the firmware to complete the handshake phase of the
                     // control transfer before the chip will enter test mode.  It is also
                     // necessary for FX2 to be physically disconnected (D+ and D-)
                     // from the host before it will enter test mode.
                     break;
                  else
                     EZUSB_STALL_EP0();   // Stall End Point 0
                  break;
               case FT_ENDPOINT:          // End Point
                  if(SETUPDAT[2] == 0)
                     {
                     if (SETUPDAT[4] == 0x2)
                        EP2CS = bmEPSTALL;         // Set stall bit
                     else if (SETUPDAT[4] == 0x88)
                        EP8CS = bmEPSTALL;         // Set stall bit
                     else
                        EZUSB_STALL_EP0();   // Stall End Point 0
                     }
                  else
                     EZUSB_STALL_EP0();   // Stall End Point 0
                  break;
            }  
         break;

      // This is a first attempt at completing a mass storage reset.  It is not yet tested.
      case SC_MASS_STORAGE_RESET:
         // Verify that the command is actually a MS reset command sent to the proper interface
         if (SETUPDAT[0] == 0x21 && SETUPDAT[4] == 0)  // Our interface number is hard coded (0) in DSCR.A51
         {
            // All we really need to do in response to a MSC Reset is restart using
            // a soft reset (jump to 0x00).  This will re-initialize the drive and
            // endpoints.
            EZUSB_IRQ_CLEAR();
            INT2CLR = bmSUDAV;         // Clear SUDAV IRQ

            // force a soft reset after the iret.
            EA = 0;
            softReset();
         }
         else
            EZUSB_STALL_EP0();   // Stall End Point 0
         break;

      default:                            // *** Invalid Command
            EZUSB_STALL_EP0();            // Stall End Point 0
   }

   // Acknowledge handshake phase of device request
   // Required for rev C does not effect rev B
    EP0CS |= bmHSNAK;
}

// Wake-up interrupt handler
void resume_isr(void) interrupt WKUP_VECT
{
   EZUSB_CLEAR_RSMIRQ();
}

STRINGDSCR xdata *   EZUSB_GetStringDscr(BYTE StrIdx)
{
   extern BYTE code StringDscr0;
   extern BYTE code StringDscr1;
   extern BYTE code StringDscr2;
   extern BYTE code StringDscr3;

   switch (StrIdx)
   {
      case 0:
         return((STRINGDSCR xdata *)&StringDscr0);
      case 1:
         return((STRINGDSCR xdata *)&StringDscr1);
      case 2:
         return((STRINGDSCR xdata *)&StringDscr2);
      case 3:
         return((STRINGDSCR xdata *)&StringDscr3);
      default:
         return(0);
   }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美刺激午夜性久久久久久久| 国产精品中文字幕欧美| 91麻豆国产精品久久| 国产精品久久久久久久久久免费看 | 欧美成va人片在线观看| 久久国产精品72免费观看| 欧美大尺度电影在线| 成人一区二区三区中文字幕| 国产精品天干天干在线综合| 色伊人久久综合中文字幕| 亚洲狠狠爱一区二区三区| 日韩欧美国产午夜精品| 国产99久久久国产精品免费看| 中国av一区二区三区| 欧洲av在线精品| 激情另类小说区图片区视频区| 中文字幕av一区二区三区高 | 日韩欧美黄色影院| 成人性生交大片免费| 一区二区三区四区乱视频| 91精品一区二区三区久久久久久 | 日韩免费看网站| 国产成人8x视频一区二区| 亚洲成人免费视| 国产无人区一区二区三区| 欧美在线一二三四区| 国内成人免费视频| 一区二区三区av电影| www国产成人| 欧美日韩一区二区在线观看视频| 国产一区二区看久久| 亚洲香肠在线观看| 国产欧美精品一区二区三区四区| 欧美影院精品一区| 成人精品gif动图一区| 美腿丝袜在线亚洲一区| 亚洲美女视频在线观看| 精品国产麻豆免费人成网站| 91传媒视频在线播放| 欧美一区二区女人| 99久久精品国产网站| 国产主播一区二区三区| 亚洲成人免费看| 亚洲欧洲美洲综合色网| 精品99一区二区| 欧美三电影在线| 99精品国产91久久久久久| 韩日欧美一区二区三区| 日本欧美肥老太交大片| 一区二区三区欧美激情| 国产精品久久久久久久久免费丝袜 | 欧美极品xxx| 日韩免费一区二区三区在线播放| 精品婷婷伊人一区三区三| 99久久综合精品| 国产精品白丝jk黑袜喷水| 美美哒免费高清在线观看视频一区二区| 亚洲免费在线观看视频| **性色生活片久久毛片| 国产精品私人影院| 久久人人爽人人爽| 欧美大尺度电影在线| 91麻豆精品91久久久久同性| 欧美影视一区二区三区| 欧美在线视频不卡| 色综合天天综合狠狠| 处破女av一区二区| 成人一区二区视频| 成人午夜激情片| 北条麻妃国产九九精品视频| heyzo一本久久综合| 国产成人一级电影| 国产一区二区免费视频| 国产乱子伦视频一区二区三区 | 亚洲精品久久久久久国产精华液| 中文字幕精品一区| 国产欧美精品在线观看| 中文字幕精品—区二区四季| 国产精品进线69影院| 欧美激情在线看| 国产精品美女久久久久久2018| 精品sm在线观看| 久久精品人人做人人综合| 国产日韩av一区二区| 国产欧美日韩麻豆91| 中文字幕欧美一区| 亚洲美女电影在线| 亚洲第一成人在线| 日韩av电影免费观看高清完整版在线观看| 亚洲国产美女搞黄色| 日韩av在线发布| 国产自产2019最新不卡| www.亚洲精品| 91成人在线精品| 在线综合亚洲欧美在线视频| 精品日韩一区二区| 日本一区二区三区视频视频| 18成人在线视频| 91美女在线观看| 欧美精品v国产精品v日韩精品| 欧美mv和日韩mv的网站| 国产精品美女久久久久久久久久久 | 久久99精品国产麻豆婷婷| 国产伦精一区二区三区| 99国产精品久久久| 91精品国产综合久久久久| www国产成人| 一区二区在线观看视频在线观看| 午夜精品一区二区三区免费视频 | 国产69精品一区二区亚洲孕妇| 成人久久视频在线观看| 欧美挠脚心视频网站| 国产亚洲女人久久久久毛片| 亚洲乱码中文字幕| 久久av资源网| 日本高清不卡视频| www欧美成人18+| 亚洲一级电影视频| 国产成人在线网站| 欧美在线看片a免费观看| 欧美精品一区二区久久久| 综合中文字幕亚洲| 韩国欧美国产一区| 欧美在线高清视频| 国产精品无码永久免费888| 日韩极品在线观看| 成+人+亚洲+综合天堂| 日韩一区二区在线播放| 亚洲天堂精品视频| 国产米奇在线777精品观看| 欧美中文字幕一区| 欧美国产日韩在线观看| 久久精品国产精品亚洲红杏| 在线观看免费一区| 国产精品久久久久影院色老大 | 国产一区二区三区日韩| 欧美中文字幕一区二区三区亚洲| 国产日产欧美一区二区三区| 首页综合国产亚洲丝袜| 色诱亚洲精品久久久久久| 国产精品少妇自拍| 国内久久精品视频| 777xxx欧美| 亚洲123区在线观看| 色网综合在线观看| 中文在线资源观看网站视频免费不卡| 日产国产欧美视频一区精品 | 欧美mv日韩mv国产网站app| 一区av在线播放| 91美女福利视频| 中文字幕一区二区在线观看| 国产精品一区二区无线| 日韩欧美国产综合一区| 奇米一区二区三区| 欧美三级三级三级| 亚洲男人电影天堂| 91麻豆高清视频| 最新日韩av在线| eeuss鲁片一区二区三区| 日本一区二区三区视频视频| 国产激情精品久久久第一区二区| 日韩一区二区三区免费观看| 婷婷国产v国产偷v亚洲高清| 欧美视频中文一区二区三区在线观看 | 色av一区二区| 亚洲人成影院在线观看| 在线观看不卡一区| 亚洲主播在线观看| 欧美日韩一区二区三区高清 | 久久亚洲精华国产精华液| 久久国产精品区| 26uuuu精品一区二区| 精品一区二区免费| 久久久国产精品麻豆| 国产成人精品午夜视频免费| 国产精品久久777777| 色94色欧美sute亚洲线路一ni| 亚洲综合成人在线| 欧美喷水一区二区| 久久国产日韩欧美精品| 久久久精品免费免费| 成人精品免费看| 亚洲精品五月天| 欧美肥胖老妇做爰| 久久疯狂做爰流白浆xx| 久久婷婷一区二区三区| 成人不卡免费av| 亚洲午夜羞羞片| 精品美女一区二区| 成人aa视频在线观看| 一区二区三区在线影院| 91精品一区二区三区在线观看| 日韩一区二区三区四区五区六区| 久久99精品一区二区三区| 中文字幕av在线一区二区三区| 色呦呦国产精品| 久久国产夜色精品鲁鲁99| 中文字幕在线不卡国产视频| 欧美日韩久久不卡| 国产伦精品一区二区三区视频青涩 |