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

📄 fw.lst

📁 linux下数据下载器的设计与实现
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.50   FW                                                                    10/12/2007 17:05:42 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE FW
OBJECT MODULE PLACED IN fw.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE fw.c OBJECTADVANCED OPTIMIZE(11,SIZE) REGFILE(.\nand_fw2k.ORC) BROWSE ORDER
                    - INCDIR(c:\cypress\usb\target\inc) DEFINE(NAND_2K) DEBUG

line level    source

   1          #pragma NOIV
   2          //-----------------------------------------------------------------------------
   3          // File:     fw.c
   4          // Contents: Firmware frameworks task dispatcher and device request parser
   5          //           source.
   6          
   7          //--------------------------------------------------------------------------
   8          
   9          #include "globals.h"
  10          void NM_ReadPageTEST();
  11          //-----------------------------------------------------------------------------
  12          // Code
  13          // Task dispatcher
  14          //-----------------------------------------------------------------------------
  15          void main(void)
  16          {
  17   1         //OEE = 0xFE;                // NAND chip select use PD0-7
  18   1         //TM_ClearWTD();
  19   1         TD_Init();                     // HW/SW initialization
  20   1      
  21   1         EZUSB_IRQ_ENABLE();            // Enable USB interrupt (INT2)
  22   1         EZUSB_ENABLE_RSMIRQ();         // Wake-up interrupt
  23   1         INTSETUP |= (bmAV2EN);         // Enable INT 2 autovectoring
  24   1      
  25   1         USBIE = bmSUDAV | bmSUSP | bmURES | bmHSGRANT;   // Enable selected interrupts
  26   1      
  27   1         //////////////////////////////////////////////////////////////////////////////
  28   1         //
  29   1         // How we got here         Renum Bit Discon Bit  Desired Action
  30   1         // ---------------         --------- ----------  --------------------
  31   1         // LI Boot-Loader Good_FW     0          1       Set the renum bit and connect
  32   1         // LI Boot-Loader !Good_FW    0          0       renumerate
  33   1         // USB Reset                  1          0       do nothing
  34   1         // Debug Mode (no bootloader) 0          0       renumerate
  35   1         // I2C Boot-Loader Good_FW    1          0       do nothing
  36   1         // I2C Boot-Loader !Good_FW   0          0       renumerate
  37   1         //
  38   1         //////////////////////////////////////////////////////////////////////////////
  39   1         if(!(USBCS & (bmRENUM | bmDISCON)))
  40   1         {
  41   2            EA = 0;
  42   2            // disconnect from USB and set the renumerate bit
  43   2            USBCS |= (bmDISCON | bmRENUM);        
  44   2            EZUSB_Delay(2500);      // Wait 2500 ms  
  45   2            USBIRQ = 0xff;          // Clear any pending USB interrupt requests.  
  46   2            EPIRQ = 0xff;
  47   2            EZUSB_IRQ_CLEAR();
  48   2         }
  49   1      
  50   1         EA = 1;                  // Enable 8051 interrupts
  51   1         TR0 = 1;                 // Make sure that the timer ISR runs at once.  
  52   1      
  53   1         // unconditionally re-connect.  If we loaded from eeprom we are
  54   1         // disconnected and need to connect.  If we just renumerated this
C51 COMPILER V7.50   FW                                                                    10/12/2007 17:05:42 PAGE 2   

  55   1         // is not necessary but doesn't hurt anything
  56   1         USBCS = (bmRENUM|bmNOSYNSOF);
  57   1      
  58   1         // complete the handshake phase of any pending SETUP transfer.
  59   1         // The only time this should happen is after a MSC Reset.  We want
  60   1         // to go through all of the EP init code before handshaking the status
  61   1         // phase of the MSC Reset.
  62   1         EP0CS |= bmHSNAK;
  63   1         Sleep = 0;                     // sleep is off
  64   1         //TM_ClearWTD();
  65   1         /////////////////////////////////////////////////////////////////////////////
  66   1      
  67   1         //chech power
  68   1      #ifdef DEBUG_VER
                 TM_Timer0_Init();
                 UM_InitUART();
              #endif
  72   1      
  73   1      #ifndef DEBUG_VER
  74   1         if((IOE & 0x01) == 0)  
  75   1      #endif
  76   1         {
  77   2                 RM_InitDS1302();
  78   2                 if(FM_fat_install())
  79   2                 {
  80   3                              ;//UM_SendString("FAT32 install ok\n");
  81   3                 }
  82   2      #ifndef DEBUG_VER
  83   2                 TM_Timer0_Init();
  84   2                 UM_InitUART();          
  85   2      #endif
  86   2         }
  87   1         /////////////////////////////////////////////////////////////////////////////
  88   1         // Task Dispatcher
  89   1      
  90   1         while(TRUE)                     // Main Loop
  91   1         {
  92   2                //TM_ClearWTD();
  93   2      #ifndef DEBUG_VER
  94   2            if((IOE & 0x01) == 1)
  95   2      #endif
  96   2                {
  97   3                    // Suspend code -- Turn off LEDs, chip enables and put CPU into suspend.
  98   3                    // We don't support remote wakeup.  Only wake on SOFs.
  99   3                    if (Sleep)
 100   3                    {
 101   4                       Sleep = FALSE;
 102   4                       WAKEUPCS = bmWU2 | bmWU | bmDPEN;      
 103   4                       EZUSB_Susp();         // Place processor in idle mode.
 104   4                    }  // endif (sleep)
 105   3                    TD_Poll();
 106   3            }
 107   2      #ifndef DEBUG_VER
 108   2                else
 109   2      #endif
 110   2                {
 111   3                        //timeout auto save
 112   3                        if(timer0_tick >= 50)
 113   3                        {
 114   4                                      if(FM_CurrentBuff == 0)                  
 115   4                                      {
 116   5                                              if(FM_DPointer1 != 0)
C51 COMPILER V7.50   FW                                                                    10/12/2007 17:05:42 PAGE 3   

 117   5                                              {
 118   6                                                      FM_CurrentBuff = 1;
 119   6                                                      FM_DataBuff1[FM_DPointer1] = 0;
 120   6                                                      FM_WriteFile(FM_DataBuff1, FM_DPointer1);
 121   6                                                      FM_DPointer1 = 0;
 122   6                                              }
 123   5                                      }
 124   4                                      else
 125   4                                      {
 126   5                                              if(FM_DPointer2 != 0)
 127   5                                              {
 128   6                                                      FM_CurrentBuff = 0;
 129   6                                                      FM_DataBuff2[FM_DPointer2] = 0;
 130   6                                                      FM_WriteFile(FM_DataBuff2, FM_DPointer2);
 131   6                                                      FM_DPointer2 = 0;
 132   6                                              }
 133   5                                      }       
 134   4                      
 135   4                                      //clear timer count
 136   4                                      timer0_tick = 0;
 137   4                        }
 138   3              
 139   3                        if(FM_CurrentBuff == 0)                        
 140   3                        {
 141   4                                if(FM_DPointer2 >= (MAX_RS232_BUFF))
 142   4                                {
 143   5                                        FM_WriteFile(FM_DataBuff2, FM_DPointer2);
 144   5                                        FM_DPointer2 = 0;
 145   5                                }
 146   4                        }
 147   3                        else
 148   3                        {
 149   4                                if(FM_DPointer1 >= (MAX_RS232_BUFF))
 150   4                                {
 151   5                                        FM_WriteFile(FM_DataBuff1, FM_DPointer1);
 152   5                                        FM_DPointer1 = 0;
 153   5                                }
 154   4                        }             
 155   3                }
 156   2         }  // End while-forever loop
 157   1      }
 158          
 159          //-----------------------------------------------------------------------------
 160          // Standard requests are 
 161          // Device request parser
 162          //-----------------------------------------------------------------------------
 163          void SetupCommand(void)
 164          {
 165   1         WORD xdata Tmp;
 166   1         BYTE xdata setupdat0 = SETUPDAT[0];
 167   1         BYTE xdata setupdat2 = SETUPDAT[2];
 168   1         BYTE xdata setupdat4 = SETUPDAT[4];
 169   1         EP0BCH = 0;                                     // Default to MSB of the length is 0
 170   1         SUDPTRH = MSB(halfKBuffer);                     // Default to descriptor table
 171   1      
 172   1         if ((setupdat0 & SETUP_MASK) == SETUP_STANDARD_REQUEST)
 173   1            {
 174   2            switch(SETUPDAT[1])
 175   2               {
 176   3               case SC_GET_DESCRIPTOR:                       // *** Get Descriptor
 177   3                  switch(SETUPDAT[3])         
 178   3                     {
C51 COMPILER V7.50   FW                                                                    10/12/2007 17:05:42 PAGE 4   

 179   4                        case GD_DEVICE:                      // Device
 180   4                           SUDPTRL = pLSB(DeviceDscrOffset); //sendDescriptor(LSB(pDeviceDscr), 0);
 181   4                           break;
 182   4                        case GD_DEVICE_QUALIFIER:            // Device Qualifier
 183   4                           // if high-speed is disabled, we are supposed to STALL this request
 184   4                           if (!CT1)
 185   4                           {
 186   5                              // high-speed is enabled, return the device qualifier
 187   5                              // sendDescriptor(LSB(pDeviceQualDscr), 0);
 188   5                              SUDPTRL = pLSB(DeviceQualDscrOffset);
 189   5                           }
 190   4                           else
 191   4                           {
 192   5                              // high-speed is disabled, STALL this request
 193   5                              EZUSB_STALL_EP0();
 194   5                           }
 195   4                           break;
 196   4                        case GD_CONFIGURATION:              // Configuration
 197   4                           ((CONFIGDSCR xdata *) pHighSpeedConfigDscr)->type = CONFIG_DSCR;
 198   4                           Tmp = wPacketSize;
 199   4                           goto gd_cases;
 200   4      
 201   4                        case GD_OTHER_SPEED_CONFIGURATION:  // Other Speed Configuration
 202   4                           ((CONFIGDSCR xdata *) pHighSpeedConfigDscr)->type = OTHERSPEED_DSCR;
 203   4                           if (EZUSB_HIGHSPEED()) Tmp = 64; else Tmp = 512;
 204   4                           gd_cases:
 205   4                           ((BYTE xdata *) pHighSpeedConfigDscr)[9+9+4] =       
 206   4                           ((BYTE xdata *) pHighSpeedConfigDscr)[9+9+7+4] = ((BYTE*)&Tmp)[1];      
 207   4                           ((BYTE xdata *) pHighSpeedConfigDscr)[9+9+5] =       
 208   4                           ((BYTE xdata *) pHighSpeedConfigDscr)[9+9+7+5] = ((BYTE*)&Tmp)[0];      
 209   4                           sendDescriptor(LSB(pHighSpeedConfigDscr), (BYTE)&HighSpeedConfigLen);
 210   4                           break;
 211   4      
 212   4                        case GD_STRING:            // String
 213   4                           SUDPTRH = MSB(halfKBuffer+cHALF_BUFF_OFFSET);
 214   4                           SUDPTRL = cINQUIRY_LENGTH + (setupdat2 * 48);
 215   4                           break;
 216   4      #ifdef HID
                                case GD_REPORT:        // Get-Descriptor: Report
                                   if (halfKBuffer[(WORD)&HIDIntrfcDscrOffset+3] == setupdat4)
                                   {  
                                      sendDescriptor(pLSB(HIDReportDscrOffset), (BYTE)&HIDReportDscrLen);
                                      break;
                                   }
                                                   else EZUSB_STALL_EP0();      // Stall End Point 0
                                   break;
                                case GD_HID:                                    // Get-Descriptor: HID
                                   SUDPTRL = pLSB(HIDDscrOffset);
                                   break;
              #endif

⌨️ 快捷键说明

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