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

📄 gpif.lst

📁 cypress 68013a-56pvxc usb2.0
💻 LST
📖 第 1 页 / 共 4 页
字号:
C51 COMPILER V7.10   GPIF                                                                  05/28/2007 19:12:30 PAGE 1   


C51 COMPILER V7.10, COMPILATION OF MODULE GPIF
OBJECT MODULE PLACED IN .\_Oput\gpif.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE source\gpif.c ROM(COMPACT) OPTIMIZE(9,SPEED) BROWSE ORDER DEFINE(GPIF=0,FLA
                    -SH=0,DEVICE_TYPE_IS_SCSI=1,DEVICE_TYPE_IS_IDE=1,VBUS_DETECT=1) DEBUG OBJECTEXTEND CODE PRINT(.\_List\gpif.lst) OBJECT(.\
                    -_Oput\gpif.obj)

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          
  21          
  22          #include <scsi.h>
  23          #include "fx2.h"
  24          #include "fx2regs.h"
  25          #include "gpif.h"
  26          
  27          
  28          #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
  37          //
  38          // Do not edit the following waveform array!  Use the GPIF utility to edit the file
  39          // GPIFPIO0.C.  Once modifications are made there, paste the resulting waveform
  40          // array into this file.
  41          //
  42          const char code WaveDataPio0[128] =                                                           
  43          { 
  44          // Wave 0                                                                                  
  45          /* LenBr */ 0x0A,     0x01,     0x0A,     0x3F,     0x00,     0x00,     0x00,     0x00,    
  46          /* Opcode*/ 0x02,     0x02,     0x04,     0x01,     0x00,     0x00,     0x00,     0x00,    
  47          /* Output*/ 0xFE,     0xFF,     0xFF,     0xFF,     0x00,     0x00,     0x00,     0x00,    
  48          /* LFun  */ 0x00,     0x00,     0x00,     0x76,     0x00,     0x00,     0x00,     0x00,    
  49          // Wave 1                                                                                  
  50          /* LenBr */ 0x08,     0x0A,     0x3F,     0x00,     0x00,     0x00,     0x00,     0x00,    
  51          /* Opcode*/ 0x00,     0x06,     0x01,     0x00,     0x00,     0x00,     0x00,     0x00,    
  52          /* Output*/ 0xFD,     0xFF,     0xFF,     0x00,     0x00,     0x00,     0x00,     0x00,    
  53          /* LFun  */ 0x00,     0x00,     0x36,     0x00,     0x00,     0x00,     0x00,     0x00,    
C51 COMPILER V7.10   GPIF                                                                  05/28/2007 19:12:30 PAGE 2   

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

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

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

⌨️ 快捷键说明

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