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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? fw.c

?? cy68013a USB2.0 highspeed mass storage source code
?? C
?? 第 1 頁 / 共 3 頁
字號:
//-----------------------------------------------------------------------------
//   File:      fw.c
//   Contents:   Firmware frameworks task dispatcher and device request parser
//            source.
//
// indent 3.  NO TABS!
//
//   Copyright (c) 2001-2004 Cypress Semiconductor
//
// $Workfile: fw.c $
// $Date: 6/26/05 1:57p $
// $Revision: 10 $
//-----------------------------------------------------------------------------
#include "fx2.h"
#include "fx2regs.h"
#include "gpif.h"
#include "atapi.h"
#include "globals.h"

#define GD_CS_GENERAL_DESCRIPTOR 0x21
#define GD_CHANNEL_DESCRIPTOR 0x22
#define GD_CSM_DESCRIPTOR 0x23
#define GD_CSMV_DESCRIPTOR 0x24

#define SC_GET_CHANNEL_SETTINGS 1
#define SC_SET_CHANNEL_SETTINGS 2

#define SC_GET_UNIQUE_ID 0x80

//-----------------------------------------------------------------------------
// 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

//-----------------------------------------------------------------------------
// Prototypes
//-----------------------------------------------------------------------------
void SetupCommand(void);
void TD_Init(void);
void TD_Poll(void);

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

// Task dispatcher

void main(void)
{
   // set the renum bit so that firmware handles SETUP transfers.
   USBCS |= bmRENUM;

   // 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

   EZUSB_ENABLE_RSMIRQ();            // Wake-up interrupt

   TD_Init();      

   EZUSB_IRQ_ENABLE();            // Enable USB interrupt (INT2)

   INTSETUP = bmAV2EN;     // Enable INT 2 autovectoring

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

   Sleep = 0;
   driveIsInStandby = 0;

   noFlashMedia = 1;
   ejected = 0;
   udmaErrorCount = 0;
   oldButtons = 0xff;

   // 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.
   if (IN_MASS_STORAGE_CLASS_RESET)
      EP0CS |= bmHSNAK;
   EA = 1;                  // Enable 8051 interrupts
   TR0 = 1;                 // Make sure that the timer ISR runs at once.  This will take care of the ATA_ENABLE line

   // Reconnect to USB if we have our MAX_LUN or if we need a SET_CONFIGURATION msg
   if (VBUS_POWERED || b1LUN_SET_BY_EEPROM || b2LUN_SET_BY_EEPROM)
      {
      USBCS &=~bmDISCON;            // Reconnect to USB.  This line has no effect in a system that's already connected.
      }

   // Enable interrupts and wait here until we receive a SET_CONFIGURATION message.
   // why?
   // because we can not identify bus-powered drives until we can turn on nPWR500.
   // We no longer pull the serial number from the drive.  We will not get a GET_MAX_LUN
   // command until after the drives are turned on.

   // Okay to connect here IF we're not planning to update the number of LUNs
   if (!(bFirstTime || deviceCount == 0x80))
      USBCS &=~bmDISCON;

   if (!mfgMode)
      ATAInit();
   // Reconnect to USB.  This line has no effect in a system that's already connected.
   USBCS &=~bmDISCON;

   USBIE = bmSUDAV | bmSUSP | bmURES | bmHSGRANT;   // Enable SETUP interrupts
   CKCON = (CKCON&(~bmSTRETCH)) | FW_STRETCH_VALUE; // Set stretch to 0 (after renumeration)

   // Check for spurious sleep flag.  We will often detect SUSPEND during startup but it's probably over now.
   if (Sleep)
      {
      USBCS |= bmNOSYNSOF;
      USBIRQ |= bmSOF;
      EZUSB_Delay(3);
      if (USBIRQ & bmSOF)
         Sleep = 0;
      }         

//   FIFORESET = 0;    // turn off nakall
   // Task Dispatcher
   while(TRUE)                     // Main Loop
   {
      ////////////////////////////////////////////////////////////////////
      // There are four sleep states in a removable-drive system, three
      // in a non-removable system.
      //
      // 1. Unplugged -- Reached whenever ATA_EN/VBUS is low.  D+ is not pulled up.
      //       This state is coded in checkATAEnable(), reached via the ISR or from this routine.
      //       This state wakes only on WAKEUP# 0-->1, so WAKEUPCS = bmWU | bmWUPOL | bmWUEN
      //       The code passes through softReset at the end of this state.
      // 2. Active -- D+ is pulled up.  This is the main code path.
      // 3. Sleeping -- CPU is shut down waiting for D+ to go active.  In the removable drive (CF) case,
      //       WU2 can also wake the device so that card swaps during suspend can be detected.
      // 4. Card swap -- If we are awakened by WU2, set the noFlashMedia flag so we will report new media 
      //       the next time that we detect a CF.  This detection takes place in TD_Poll()
      ////////////////////////////////////////////////////////////////////
#if STANDBY_IMMEDIATE
      WAKEUPCS = 0x45;
      if (Sleep || (WAKEUPCS & 0x40) || (!bNewAt2pinout && !VBUS_PRESENT))     // check VBUS and old part's VBUS detector
      {
         WORD i;
         Sleep = FALSE;

         //////////////////////////////////////////////////
         // Special purpose power-saving code.
         //
         // Expected conditions:  
         //     Self-powered, no bus-sharing, single IDE device
         //
         // This code will wait 100ms before turning off the drive.
         // This is to debounce any short sleep conditions that occur, like the 
         // ~75ms sleep period that many hosts do during startup.
         //////////////////////////////////////////////////
         USBCS |= bmNOSYNSOF;
         USBIRQ |= bmSOF;
         for (i = 0; i < 500; i++)
            {
            EZUSB_Delay(1);
            if (USBIRQ & bmSOF)
                break;
            }

         if (!(USBIRQ & bmSOF))
            standbyImmediate();
#else
      if (Sleep)
      {
         Sleep = FALSE;

         if (!bScsi)
             flushCache();
#endif

         // Before going to sleep, check the tri-state pin one last time.
         // This will also catch the case where we were woken up by the tri-state pin and must go back to sleep.
         EZUSB_Delay(10);      // Make sure VBUS has time to go away before checking it.
         checkATAEnable();
         OEC = PORTC_OE_SUSPEND;
         OEE = PORTE_OE_SUSPEND | (mx2_config_data.GpioOE << 2);

         powerOff();

         // Drive the data bus low.  This code is only called in suspend, not in the other power-off cases.
         if (VBUS_POWERED)
            {
            IFCONFIG &= ~3;   // Turn off GPIF control of ports B and D.
            IOB = IOD = IOA = 0;
            OEB = OED = 0xff;
            OEA = 0xf7;
            GPIFCTLCFG = 0x80;   // 
            GPIFIDLECTL = 0x70;  // x111x000 - CTL3 not enabled.  Drive the CTL lines LOW
            }
         
         #if STANDBY_IMMEDIATE
         // Standby_Immediate case kills all of the stuff done in check_ata_enable so that 
         // it can turn off the drive in this background loop.  This means that WAKEUP# could
         // be high or low here in the STANDBY_IMMEDIATE case
         WAKEUPCS = bmWU2 | bmWU                      | bmDPEN | bmWUEN;
         if (WAKEUPCS & bmWU)
            WAKEUPCS = WAKEUPCS = bmWU2 | bmWU | bmWUPOL         | bmDPEN | bmWUEN;
         #else
         // Wake up on D+ traffic, WAKEUP 1-->0.
         // If there is a CF, wake up on CF insertion too.
         if (bDRVPWRVLD_ENABLE)
            {
            if (CF_DETECT_)
               WAKEUPCS = bmWU2 | bmWU | bmWU2EN |            bmDPEN | bmWUEN;      // No CF, wake on low
            else
               WAKEUPCS = bmWU2 | bmWU | bmWU2EN | bmWU2POL | bmDPEN | bmWUEN;      // CF there, wake on high
            }
         else
            WAKEUPCS = bmWU2 | bmWU                      | bmDPEN | bmWUEN;
         #endif

         // Make sure that we don't get a USB reset interrupt before we can enable everything
         USBIE = 0;

         EZUSB_Susp();         // Place processor in idle mode.

         // If we were woken up by a CF insertion, go back to sleep after one loop.
         if (WAKEUPCS & bmWU2)
            Sleep = TRUE;

         // Undo "drive data bus low" code above.
         if (VBUS_POWERED)
            {
            OEA = PORTA_OE;
            OUTATAPI = ATAPI_IDLE_VALUE;
            IFCONFIG = IFCONFIG_DEFAULT;    
            GPIFCTLCFG = 0x80;   // 
            GPIFIDLECTL = 0x77;  // x111x000 - CTL3 not enabled.  Drive the CTL lines LOW
            }

         OEC = PORTC_OE;
         OEE = PORTE_OE | (mx2_config_data.GpioOE << 2);

         powerOn();
         // Re-enable USB reset interrupt 
         USBIE = bmSUDAV | bmSUSP | bmURES | bmHSGRANT;   // Enable SETUP interrupts
      }  // endif (sleep)

      TD_Poll();     
   }  // End while-forever loop
}


// Standard requests are 
#define STANDARD(x)  (x | (SETUP_STANDARD_REQUEST<<8))  
#define CLASS(x) (x | (SETUP_CLASS_REQUEST << 8))
#define VENDOR(x) (x | (SETUP_VENDOR_REQUEST << 8))

// We can cheat on all of these parameters.  All of our supported commands only use the LSB.
#define wValue  setupdat2
#define wIndex  setupdat4
#define wLength setupdat67

// Device request parser
void SetupCommand(void)
{
   // Making these items static doesn't hurt the stack compilation because this is an ISR.
   // It also removes them from the stack compilation, allowing them to be fit into gaps in the data space
   static BYTE setupdat0;
   static BYTE setupdat2;
   static BYTE setupdat4;
   static WORD setupdat67;
   BYTE i;
   setupdat0 = SETUPDAT[0];
   setupdat2 = SETUPDAT[2];
   setupdat4 = SETUPDAT[4];
   setupdat67 = SETUPDAT[6] | (SETUPDAT[7] << 8);
   EP0BCH = 0;                                     // Default to MSB of the length is 0
   SUDPTRH = MSB(halfKBuffer);                     // Default to descriptor table

   if ((setupdat0 & SETUP_MASK) == SETUP_STANDARD_REQUEST)
      {
      switch(SETUPDAT[1])
         {
         case SC_GET_DESCRIPTOR:                      // *** Get Descriptor

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
26uuu精品一区二区三区四区在线| 国内精品伊人久久久久av影院| 成人精品视频一区二区三区尤物| 精品盗摄一区二区三区| 九九九精品视频| 亚洲精品一区二区三区精华液 | 欧美撒尿777hd撒尿| 亚洲精品欧美激情| 欧美性大战久久久久久久蜜臀| 亚洲亚洲精品在线观看| 91麻豆精品国产91久久久久久| 精品一区二区三区欧美| 久久久久国产精品厨房| av中文字幕一区| 一区二区三区成人在线视频| 欧美区一区二区三区| 美女视频第一区二区三区免费观看网站| 91精品国产综合久久久蜜臀粉嫩 | 国产女同互慰高潮91漫画| 国产美女久久久久| 中文字幕五月欧美| 欧美精品亚洲二区| 国产一区二区伦理| 最新国产精品久久精品| 欧美网站大全在线观看| 国产最新精品免费| 一区二区三区自拍| 日韩午夜av电影| 国产精品亚洲午夜一区二区三区| 1024成人网| 91精品国产91综合久久蜜臀| 国产传媒欧美日韩成人| 亚洲美女屁股眼交3| 日韩欧美一级二级三级久久久| 丁香天五香天堂综合| 亚洲综合久久av| 久久久国产精品午夜一区ai换脸| 91丨九色丨国产丨porny| 蜜桃视频在线观看一区| 亚洲欧洲精品一区二区三区| 91精品国产91久久久久久最新毛片 | 国产精品一品二品| 亚洲国产欧美一区二区三区丁香婷| 日韩午夜在线影院| 色av一区二区| 国产精品自拍网站| 视频精品一区二区| 亚洲欧美一区二区三区孕妇| 日韩欧美在线影院| 在线精品视频免费观看| 国产精品888| 青青草视频一区| 亚洲一二三四在线| 国产精品污污网站在线观看| 欧美一区二区视频网站| 91丨九色丨尤物| 国产成人免费av在线| 免费观看在线综合| 亚洲午夜免费视频| 亚洲日穴在线视频| 国产亚洲综合在线| 欧美精品一区男女天堂| 欧美精品久久一区二区三区| 91香蕉视频污在线| 成人禁用看黄a在线| 国产精品综合在线视频| 蜜臀av性久久久久蜜臀aⅴ | 亚洲成年人影院| 国产精品白丝在线| 国产日韩精品久久久| 精品国产乱码久久久久久免费| 欧美日韩国产色站一区二区三区| 日本韩国一区二区三区视频| 波多野结衣一区二区三区| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 国产精品久久久久一区二区三区共 | 色老汉一区二区三区| 国产麻豆成人精品| 韩国女主播一区| 国产一区激情在线| 国产毛片精品国产一区二区三区| 激情成人午夜视频| 激情综合色播激情啊| 国产一区二区三区四区五区入口| 麻豆精品久久精品色综合| 蜜臀久久99精品久久久久宅男| 日韩不卡在线观看日韩不卡视频| 日本在线观看不卡视频| 日韩高清一区二区| 激情综合网av| 国产精品一区二区你懂的| 成人午夜大片免费观看| fc2成人免费人成在线观看播放| 成人h版在线观看| 99久久综合色| 在线亚洲一区二区| 91精品国产一区二区三区香蕉| 正在播放亚洲一区| 久久夜色精品一区| 国产精品传媒视频| 亚洲五码中文字幕| 麻豆久久一区二区| 国产精品一区二区你懂的| 成人性生交大片免费看视频在线 | 毛片一区二区三区| 国产伦理精品不卡| 97se亚洲国产综合自在线不卡| 色综合婷婷久久| 在线成人免费观看| 欧美精品一区二区三区久久久 | 性欧美大战久久久久久久久| 免费观看在线色综合| av一区二区久久| 欧美日韩免费观看一区二区三区| 日韩三级视频在线看| 国产欧美日本一区二区三区| 亚洲精品国产成人久久av盗摄 | kk眼镜猥琐国模调教系列一区二区| 色婷婷久久久久swag精品 | 激情文学综合网| 成人av在线电影| 精品视频一区三区九区| 久久天堂av综合合色蜜桃网| 亚洲人成网站影音先锋播放| 日韩高清在线不卡| 懂色av一区二区三区免费观看| 欧洲一区在线观看| 久久久99免费| 午夜日韩在线电影| 成人丝袜高跟foot| 884aa四虎影成人精品一区| 欧美国产1区2区| 日韩精品色哟哟| 99久久精品免费看国产| 日韩午夜小视频| 亚洲曰韩产成在线| 成人综合在线观看| 欧美另类久久久品| 亚洲色图欧洲色图| 国内精品免费**视频| 欧美亚洲综合网| 成人欧美一区二区三区1314| 99这里只有久久精品视频| 欧美日韩国产成人在线免费| 国产精品久久久久久久久免费桃花| 日日欢夜夜爽一区| 色狠狠色狠狠综合| 中文字幕不卡一区| 国产一区视频在线看| 日韩一区二区高清| 一区二区三国产精华液| 成人美女在线视频| 久久亚洲免费视频| 久久99国产精品尤物| 制服丝袜中文字幕一区| 亚洲国产视频一区二区| 色www精品视频在线观看| 自拍偷在线精品自拍偷无码专区| 激情综合网av| 欧美va亚洲va| 日韩av网站免费在线| 欧美日本韩国一区二区三区视频| 亚洲人成影院在线观看| 不卡av在线免费观看| 国产女人18水真多18精品一级做| 蜜桃视频一区二区三区在线观看| 91精品国产一区二区三区蜜臀| 午夜久久久影院| 欧美日韩精品高清| 午夜日韩在线观看| 欧美电影一区二区| 日本麻豆一区二区三区视频| 91精品国模一区二区三区| 日本不卡123| 欧美大片拔萝卜| 国产一区二区三区在线观看免费视频 | 日韩一区二区视频在线观看| 欧美aaaaaa午夜精品| 欧美一级片在线看| 久久丁香综合五月国产三级网站| 日韩一级免费观看| 黄色日韩网站视频| 久久尤物电影视频在线观看| 国产精品自产自拍| 中文字幕一区日韩精品欧美| 9久草视频在线视频精品| 亚洲男同性视频| 精品视频在线看| 毛片av一区二区| 久久久久国产免费免费| 99精品久久只有精品| 悠悠色在线精品| 这里只有精品视频在线观看| 狠狠v欧美v日韩v亚洲ⅴ| 国产日韩精品一区二区三区在线| 成人激情校园春色| 亚洲一区二区三区四区的| 欧美一级二级在线观看| 国产精品资源在线| 亚洲欧美韩国综合色|