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

📄 gpif.lst

📁 HIGH_SPEED_USB_To_ATA(IDE)Firmware相关代码(EZ USB FX2芯片)
💻 LST
📖 第 1 页 / 共 4 页
字号:
C51 COMPILER V7.50   GPIF                                                                  11/07/2006 14:52:08 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE GPIF
OBJECT MODULE PLACED IN gpif.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE gpif.c ROM(COMPACT) OPTIMIZE(9,SPEED) REGFILE(.\fx2_ata.ORC) BROWSE ORDER I
                    -NCDIR(c:\cypress\usb\target\inc) DEFINE(GPIF=0,FLASH=0,DEVICE_TYPE_IS_SCSI=1,DEVICE_TYPE_IS_IDE=1,VBUS_DETECT=1) DEBUG O
                    -BJECTEXTEND CODE

line level    source

   1          //-----------------------------------------------------------------------------
   2          //  Copyright (c) 1999 Cypress Semiconductor, Inc. All rights reserved
   3          //-----------------------------------------------------------------------------
   4          //
   5          // This file contains GPIF support code.  
   6          //
   7          // $Archive: /USB/atapifx2/software/gpif.c $
   8          // $Date: 1/23/02 9:37a $
   9          // $Revision: 62 $
  10          //-----------------------------------------------------------------------------
  11          #pragma ot(8,SPEED) // keep gpif.c at Optimization Level 8 (no re-ordering)
  12                                                  // This is because some DVD-RAM drives had a problem when a common
  13                                                  // subroutine was replaced. The problem appeared to be only a minor
  14                                                  // difference in timing. The DVD-RAM drive would fail if a subroutine
  15                                                  // call was added to readPIO8. It reported a residue of data after
  16                                                  // a prior transfer had been completed, and when that data was read,
  17                                                  // it was just a buffer filled with invalid (repeating) data.
  18                                                  // The problem appeared to be the fault of the DVD-ROM drive.
  19          
  20          #include <scsi.h>
  21          #include "fx2.h"
  22          #include "fx2regs.h"
  23          #include "gpif.h"
  24          
  25          
  26          #ifdef GPIF_ABORT_BUG_PRESENT
              const char code AbortWave[32] =                                                           
              { 
              /* LenBr */ 0x01,     0x3F,     0x00,     0x00,     0x00,     0x00,     0x00,     0x00,    
              /* Opcode*/ 0x00,     0x07,     0x00,     0x00,     0x00,     0x00,     0x00,     0x00,    
              /* Output*/ 0x00,     0x00,     0x00,     0x00,     0x00,     0x00,     0x00,     0x00,    
              /* LFun  */ 0x00,     0x40,     0x00,     0x00,     0x00,     0x00,     0x00,     0x00    
              };
              #endif
  35          //
  36          // Do not edit the following waveform array!  Use the GPIF utility to edit the file
  37          // GPIFPIO0.C.  Once modifications are made there, paste the resulting waveform
  38          // array into this file.
  39          //
  40          const char code WaveDataPio0[128] =                                                           
  41          { 
  42          // Wave 0                                                                                  
  43          /* LenBr */ 0x0A,     0x01,     0x0A,     0x3F,     0x00,     0x00,     0x00,     0x00,    
  44          /* Opcode*/ 0x02,     0x02,     0x04,     0x01,     0x00,     0x00,     0x00,     0x00,    
  45          /* Output*/ 0xFE,     0xFF,     0xFF,     0xFF,     0x00,     0x00,     0x00,     0x00,    
  46          /* LFun  */ 0x00,     0x00,     0x00,     0x76,     0x00,     0x00,     0x00,     0x00,    
  47          // Wave 1                                                                                  
  48          /* LenBr */ 0x08,     0x0A,     0x3F,     0x00,     0x00,     0x00,     0x00,     0x00,    
  49          /* Opcode*/ 0x00,     0x06,     0x01,     0x00,     0x00,     0x00,     0x00,     0x00,    
  50          /* Output*/ 0xFD,     0xFF,     0xFF,     0x00,     0x00,     0x00,     0x00,     0x00,    
  51          /* LFun  */ 0x00,     0x00,     0x36,     0x00,     0x00,     0x00,     0x00,     0x00,    
  52          // Wave 0  UDMA Write
  53          /* LenBr */ 0x08,     0x01,     0x05,     0x1C,     0x03,     0x01,     0x02,     0x01,    
C51 COMPILER V7.50   GPIF                                                                  11/07/2006 14:52:08 PAGE 2   

  54          /* Opcode*/ 0x01,     0x00,     0x02,     0x03,     0x02,     0x02,     0x26,     0x00,    
  55          /* Output*/ 0xFF,     0xFB,     0xFA,     0xFA,     0xF8,     0xF9,     0xC3,     0xFF,    
  56          /* LFun  */ 0x09,     0x09,     0xA8,     0x09,     0x00,     0x00,     0x36,     0x3F,     
  57          // Wave 1 UDMA Read
  58          /* LenBr */ 0x08,     0x01,     0x13,     0x05,     0x01,     0x02,     0x01,     0x01,    
  59          /* Opcode*/ 0x01,     0x00,     0x01,     0x00,     0x00,     0x26,     0x26,     0x00,    
  60          /* Output*/ 0xFF,     0xFB,     0xF8,     0xFB,     0xFB,     0xFB,     0xFF,     0xFF,    
  61          /* LFun  */ 0x09,     0x09,     0x09,     0x09,     0x00,     0x2D,     0x36,     0x3F,    
  62          };                                                                                         
  63          
  64          //
  65          // Do not edit the following waveform array!  Use the GPIF utility to edit the file
  66          // GPIFPIO4.C.  Once modifications are made there, paste the resulting waveform
  67          // array into this file.
  68          //
  69          // Don't forget that the IORDY signal can be produced at the drive up to 35ns after we
  70          // drop RD or WR.  It then takes 2 clocks for us to demet the signal (async input).  The
  71          // IORDY signal is available on the FIFTH clock edge after RD or WR is dropped.
  72          // Edge 1)  Drop RD/WR (start state 0)
  73          // Edge 2)  No action
  74          // Edge 3)  IORDY detected at first flop
  75          // Edge 4)  IORDY detected at second flop
  76          // Edge 5)  IORDY available as an input to IF/THEN statements. (start state 1)
  77          //
  78          const char code WaveDataPio4[128] =                                                           
  79          {                                                                                          
  80          // Wave 0                                                                                  
  81          /* LenBr */ 0x04,     0x11,     0x01,     0x3F,     0,0,0,0,
  82          /* Opcode*/ 0x02,     0x03,     0x02,     0x07,     0,0,0,0,
  83          /* Output*/ 0xFE,     0xFE,     0xFF,     0xFF,     0,0,0,0,
  84          /* LFun  */ 0x00,     0x00,     0x00,     0x36,     0,0,0,0,
  85          // Wave 1                                                                                  
  86          /* LenBr */ 0x04,     0x11,     0x3f,     0x00,     0,0,0,0,
  87          /* Opcode*/ 0x00,     0x01,     0x07,     0x00,     0,0,0,0,
  88          /* Output*/ 0xFD,     0xFD,     0xFF,     0x00,     0,0,0,0,
  89          /* LFun  */ 0x00,     0x00,     0x00,     0x00,     0,0,0,0,
  90          // Wave 0  UDMA Write
  91          /* LenBr */ 0x08,     0x01,     0x06,     0x1C,     0x01,     0x01,     0x02,     0x07,    
  92          /* Opcode*/ 0x01,     0x00,     0x02,     0x03,     0x02,     0x02,     0x26,     0x00,    
  93          /* Output*/ 0xFF,     0xFB,     0xFA,     0xFA,     0xF8,     0xFB,     0xFB,     0xFF,    
  94          /* LFun  */ 0x09,     0x09,     0x12,     0x09,     0x00,     0x2d,     0x36,     0x3F,     
  95          // Wave 1  UDMA Read
  96          /* LenBr */ 0x08,     0x01,     0x13,     0x01,     0x01,     0x02,     0x01,     0x07,    
  97          /* Opcode*/ 0x01,     0x00,     0x01,     0x00,     0x00,     0x26,     0x26,     0x00,    
  98          /* Output*/ 0xFF,     0xFB,     0xF8,     0xFB,     0xFB,     0xFB,     0xFF,     0xFF,    
  99          /* LFun  */ 0x09,     0x09,     0x09,     0x1b,     0x00,     0x2D,     0x36,     0x3F,    
 100          };                                                                                         
 101          
 102          void hardwareReset()
 103          {
 104   1          OUTATAPI &= ~ATAPI_RESET_;
 105   1          EZUSB_Delay(100);
 106   1          OUTATAPI |= ATAPI_RESET_;
 107   1      }   
 108          
 109          
 110          void initUdmaRead()
 111          {
 112   1      
 113   1         FLOWLOGIC = 0x36;
 114   1         FLOWEQ0CTL = 0x00;
 115   1         FLOWEQ1CTL = 0x02;
C51 COMPILER V7.50   GPIF                                                                  11/07/2006 14:52:08 PAGE 3   

 116   1         FLOWSTB = 0xD0;
 117   1         FLOWSTBEDGE = 0x03;
 118   1         GPIFHOLDAMOUNT = 0x01;
 119   1      
 120   1         EP8FIFOCFG = 0x0D;
 121   1         IFCONFIG = 0xc6;
 122   1      }
 123          
 124          void initUdmaWrite()
 125          {
 126   1         FLOWLOGIC = 0x70;
 127   1         FLOWEQ0CTL = 0x00;
 128   1         FLOWEQ1CTL = 0x08;           // Enable CTL3 signal for XRO
 129   1         FLOWSTB = 0x11;
 130   1         FLOWSTBEDGE = 0x03;
 131   1         if(udmaMode == TRANSFER_MODE_UDMA2)
 132   1                 FLOWSTBHPERIOD = 0x04;  // for UDMA33
 133   1         else  
 134   1                 FLOWSTBHPERIOD = 0x02;  // for UDMA66
 135   1         GPIFHOLDAMOUNT = 0x01;
 136   1         EP2GPIFFLGSEL = 0x01;
 137   1         IFCONFIG = 0x86;
 138   1      }
 139          
 140          // Write a single byte to the given disk register or buffer
 141          void writePIO8(char addr, WORD indata)
 142          {
 143   1      
 144   1         // make sure GPIF is not busy
 145   1          while (!gpifIdle())
 146   1              {
 147   2              }
 148   1      
 149   1         GPIFWFSELECT = 0;    // PIO write is waveform 0
 150   1      
 151   1         // Write the address/chip selects
 152   1          OUTATAPI = addr | (~ATAPI_ADDR_MASK & ATAPI_IDLE_VALUE);
 153   1      
 154   1          // trigger the GPIF
 155   1          XGPIFSGLDATH = MSB(indata);                       // Single bus transaction on the GPIF
 156   1          XGPIFSGLDATLX = LSB(indata);                   // Single bus transaction on the GPIF
 157   1      
 158   1         // make sure GPIF is not busy
 159   1          while (!gpifIdle())
 160   1              {
 161   2              }
 162   1      
 163   1          // Clear the address/chip selects
 164   1          OUTATAPI = ATAPI_IDLE_VALUE;
 165   1      
 166   1      }   
 167          
 168          // Write the string to the given disk register or buffer
 169          void writePIO16(char addr, WORD count)
 170          {
 171   1          int timeout = IORDY_TIMEOUT_RELOAD;
 172   1      
 173   1          GPIFABORT = 0x00;
 174   1      
 175   1          while (!gpifIdle())
 176   1            ;
 177   1      
C51 COMPILER V7.50   GPIF                                                                  11/07/2006 14:52:08 PAGE 4   

 178   1         GPIFWFSELECT = 0;    // PIO write is waveform 0
 179   1      
 180   1         // Write the address/chip selects
 181   1          OUTATAPI = addr | (~ATAPI_ADDR_MASK & ATAPI_IDLE_VALUE);
 182   1      
 183   1      
 184   1         // set up GPIF transfer
 185   1         EP2GPIFTCH = MSB(count >> 1);
 186   1         EP2GPIFTCL = LSB(count >> 1);  // # of GPIF wordwide transactions
 187   1         EP2GPIFTRIG = 0x00;           // trigger the transfer
 188   1      //   GPIFTRIG = 0x00;        // GPIFTRIG[2] = RD/WR BIT (1 = READ)
 189   1                                    // xxxxxxxx
 190   1                                    // ||||||00 b0/b1:  EP bit code:  00=EP2, 01=EP4, 10=EP6, 11=EP8
 191   1                                    // |||||0-- b3:     R/W#: W=0, R=1
 192   1                                    // 0------- b7:     DONE
 193   1          while (!gpifIdle())
 194   1            ; 
 195   1      }   
 196          
 197          // Read the status register.  Added to save space.
 198          BYTE readATAPI_STATUS_REG()
 199          {
 200   1         return(readPIO8(ATAPI_STATUS_REG));
 201   1      }
 202          
 203          // Read a string from the given disk register or buffer
 204          BYTE readPIO8(char addr)
 205          {
 206   1         BYTE retval;
 207   1      
 208   1         while (!gpifIdle());
 209   1      
 210   1         GPIFWFSELECT = (1 << 4);    // PIO read is waveform 1
 211   1      
 212   1         // put out address of interest
 213   1         OUTATAPI = addr | (~ATAPI_ADDR_MASK & ATAPI_IDLE_VALUE);
 214   1      
 215   1         // trigger the GPIF
 216   1         retval = XGPIFSGLDATLX;         // Single bus transaction on the GPIF
 217   1      
 218   1         while (!gpifIdle());             // wait till GPIF is done before getting real data
 219   1      
 220   1         retval = XGPIFSGLDATLNOX;        // get data from last GPIF transaction
 221   1         OUTATAPI = ATAPI_IDLE_VALUE;     // Clear the address/chip selects      
 222   1      
 223   1          return(retval);
 224   1      }
 225          
 226          WORD readWordPIO8(char addr)
 227          {
 228   1         WORD retval;
 229   1         
 230   1         while (!gpifIdle());

⌨️ 快捷键说明

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