vendor.LST
上传用户:ids068
上传日期:2013-04-04
资源大小:639k
文件大小:17k
源码类别:

USB编程

开发平台:

C/C++

  1. C51 COMPILER V7.06   VENDOR                                                                07/02/2003 09:29:10 PAGE 1   
  2. C51 COMPILER V7.06, COMPILATION OF MODULE VENDOR
  3. OBJECT MODULE PLACED IN vendor.OBJ
  4. COMPILER INVOKED BY: C:KEILC51BINC51.EXE vendor.c OPTIMIZE(2,SPEED) BROWSE DEBUG OBJECTEXTEND
  5. stmt level    source
  6.    1          //***********************************************************************
  7.    2          //                                                                                                                                                        *
  8.    3          //                P H I L I P S   P R O P R I E T A R Y                            *    
  9.    4          //                                                                      *
  10.    5          //          COPYRIGHT (c)   1999 BY PHILIPS SINGAPORE (APIC).                      *
  11.    6          //                    --  ALL RIGHTS RESERVED  --                               *       
  12.    7          //                                                                      *
  13.    8          //      File Name       :       DMADebug.c                                    *
  14.    9          //      Author          :       Albert Goh                                                                                    *
  15.   10          //      Created         :       3 March 2000                                    *
  16.   11          //                                                                         *
  17.   12          //***********************************************************************
  18.   13          //***********************************************************************
  19.   14          //                                                                      *
  20.   15          // GDMADebug.c is the file that contain the routine for the GDMA debug  *
  21.   16          // It will be able to configured as master for slave for the debugging  *
  22.   17          //                                                                      *
  23.   18          //***********************************************************************
  24.   19          //***********************************************************************
  25.   20          //                                                                      *
  26.   21          //  Module History                                                                                                                          *
  27.   22          //  **************                                                                                                                          *
  28.   23          //                                                                                                                                                                *
  29.   24          //  Date        Version                 Author                          Changes                                       *
  30.   25          //  ====           =======                      ======                          =======                                       *
  31.   26          //  030300        0.1                   Albert                          Created                                       *
  32.   27          //                                                                      *
  33.   28          //                                                                      *
  34.   29          //***********************************************************************
  35.   30          
  36.   31          //***********************************************************************
  37.   32          //*                                                                                                                                                            *
  38.   33          //*                          Include Files Definition                                              *
  39.   34          //*                                                                                                                                                            *
  40.   35          //***********************************************************************
  41.   36          
  42.   37          #include "standard.h"
  43.   38          #include "Kernel.h"
  44.   39          #include "D14.h"
  45.   40          
  46.   41          
  47.   42          
  48.   43          
  49.   44          //***********************************************************************
  50.   45          //*                                                                                                                                                            *
  51.   46          //*                      External Variable Definition                                         *
  52.   47          //*                                                                                                                                                            *
  53.   48          //***********************************************************************
  54.   49          
  55.   50          extern USB_DEVICE USB_Device;
  56.   51          extern DMA_INT_FLAG DMA_Int_Flag;
  57.   52          extern USB_INT_FLAG USB_Int_Flag;
  58.   53          extern volatile D14_CNTRL_REG xdata D14_Cntrl_Reg;
  59.   54          extern void Start_mSEC_Timer(Data);
  60.   55          extern UC Data;
  61. C51 COMPILER V7.06   VENDOR                                                                07/02/2003 09:29:10 PAGE 2   
  62.   56          extern UI Temp,PIO_Count;
  63.   57          extern KERNEL Kernel_Flag;
  64.   58          extern ULI      bytecount;
  65.   59          extern FILESIZE FileSize;
  66.   60          extern UI       count;
  67.   61          extern UC idata Endpt_FIFO[MAX_BUF];
  68.   62          extern UC Type;
  69.   63          
  70.   64          //***********************************************************************
  71.   65          //*                                                                                                                                                            *
  72.   66          //*                          Variable Definition                                                              *
  73.   67          //*                                                                                                                                                            *
  74.   68          //***********************************************************************
  75.   69          
  76.   70          UI Count_PIO;
  77.   71          
  78.   72          //***********************************************************************
  79.   73          //*                                                                                                                                                            *
  80.   74          //*                          Prototype Definition                                                          *
  81.   75          //*                                                                                                                                                            *
  82.   76          //***********************************************************************
  83.   77          
  84.   78          void DMA_Debug_Mode(void);
  85.   79          void DMA_Init(void);
  86.   80          void DMA_Mode(Data);
  87.   81          
  88.   82          //***********************************************************************
  89.   83          //*                                                                                                                                                            *
  90.   84          //*                          Routine Definition                                                            *
  91.   85          //*                                                                                                                                                            *
  92.   86          //***********************************************************************
  93.   87          
  94.   88          //***********************************************************************
  95.   89          //*                                                                                                                                                    *
  96.   90          //*     Routine         : DMA Debug Mode                                                   *
  97.   91          //*     Input           : None                                                                                              *
  98.   92          //*     Output  : None                                                                        *
  99.   93          //*     Function        : Generic DMA mode routine                                            *
  100.   94          //*                                                                                                                                                            *
  101.   95          //***********************************************************************
  102.   96          
  103.   97          void DMA_Debug_Mode(void)
  104.   98          {
  105.   99   1              if(Kernel_Flag.BITS.Transfer_Start)
  106.  100   1              {
  107.  101   2                      if(FileSize.Size.Address[0] == 0 &&
  108.  102   2                              FileSize.Size.Address[1] == 0 &&
  109.  103   2                              FileSize.Size.Address[2] == 0)
  110.  104   2                      {
  111.  105   3                              Kernel_Flag.BITS.Out_Reset_Done = 0;
  112.  106   3                              Kernel_Flag.BITS.In_Reset_Done = 0;
  113.  107   3                      }
  114.  108   2                      
  115.  109   2                      if(FileSize.Size.DIR == 0x00 || FileSize.Size.DIR == 0x80)
  116.  110   2                              DMA_Mode(Write);
  117.  111   2                      else
  118.  112   2                              DMA_Mode(Read);
  119.  113   2              }
  120.  114   1      }
  121.  115          
  122.  116          
  123.  117          //***********************************************************************
  124. C51 COMPILER V7.06   VENDOR                                                                07/02/2003 09:29:10 PAGE 3   
  125.  118          //*                                                                                                                                                    *
  126.  119          //*     Routine         : DMA Mode                                                         *
  127.  120          //*     Input           : DMA Controller setting                                                    *
  128.  121          //*     Output  : None                                                                        *
  129.  122          //*     Function        : to do GDMA data transfer                                            *
  130.  123          //*                                                                                                                                                            *
  131.  124          //***********************************************************************
  132.  125          
  133.  126          void DMA_Mode(Data)
  134.  127          {
  135.  128   1              UI Datcount;
  136.  129   1      
  137.  130   1              if(Data)
  138.  131   1              {
  139.  132   2                      //read
  140.  133   2                      do
  141.  134   2                      {
  142.  135   3                              //Check for Out Token ACK interrupt
  143.  136   3                              while(!USB_Int_Flag.BITS.EP2RX)
  144.  137   3                              {
  145.  138   4                                      if(USB_Int_Flag.BITS.SUSP || Kernel_Flag.BITS.Bus_Reset || USB_Int_Flag.BITS.EP0SETUP)
  146.  139   4                                              break;
  147.  140   4                              }
  148.  141   3                              EA_DISABLE;
  149.  142   3                              USB_Int_Flag.BITS.EP2RX = 0;
  150.  143   3                              EA_ENABLE;
  151.  144   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 4;
  152.  145   3                              D14_Cntrl_Reg.D14_DMA_ENDPOINT = 2;
  153.  146   3                              //Read in FIFO data
  154.  147   3                              if (bytecount > PIO_Count)
  155.  148   3                              {
  156.  149   4                                      Datcount = PIO_Count;
  157.  150   4                              }
  158.  151   3                              else
  159.  152   3                              {
  160.  153   4                                      Datcount = bytecount;
  161.  154   4                              }
  162.  155   3                              if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
  163.  156   3                              {
  164.  157   4                                      for(Count_PIO = 0 ; Count_PIO < Datcount ; Count_PIO++)
  165.  158   4                                              Endpt_FIFO[Count_PIO] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  166.  159   4                              }
  167.  160   3                              else
  168.  161   3                              {
  169.  162   4                                      for(Count_PIO = 0 ; Count_PIO < Datcount; Count_PIO++)
  170.  163   4                                              Temp = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  171.  164   4                              }
  172.  165   3                              bytecount -= Datcount;
  173.  166   3                      }while(bytecount);
  174.  167   2              }
  175.  168   1              else
  176.  169   1              {
  177.  170   2                      //write
  178.  171   2                      do
  179.  172   2                      {
  180.  173   3                              //initialize endpoint index
  181.  174   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 5;
  182.  175   3                              D14_Cntrl_Reg.D14_DMA_ENDPOINT = 2;
  183.  176   3                              //Write data to FIFO
  184.  177   3                              if (bytecount>PIO_Count)
  185.  178   3                              {
  186.  179   4                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB =( unsigned char ) PIO_Count;
  187. C51 COMPILER V7.06   VENDOR                                                                07/02/2003 09:29:10 PAGE 4   
  188.  180   4                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = ( unsigned char ) (PIO_Count>>8);
  189.  181   4                                      Datcount = PIO_Count;
  190.  182   4                              }
  191.  183   3                              else
  192.  184   3                              {
  193.  185   4                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB =( unsigned char ) bytecount;
  194.  186   4                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = ( unsigned char ) (bytecount>>8);
  195.  187   4                                      Datcount = bytecount;
  196.  188   4                              }
  197.  189   3      
  198.  190   3                              if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
  199.  191   3                              {
  200.  192   4                                      for(Count_PIO = 0 ; Count_PIO < Datcount ; Count_PIO++)
  201.  193   4                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = Endpt_FIFO[Count_PIO];
  202.  194   4                              }
  203.  195   3                              else
  204.  196   3                              {
  205.  197   4                                      for(Count_PIO = 0 ; Count_PIO < Datcount ; Count_PIO++)
  206.  198   4                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = Count_PIO % 256;
  207.  199   4                              }
  208.  200   3                              //Check for In Token ACK
  209.  201   3                              while(!USB_Int_Flag.BITS.EP2TX)
  210.  202   3                              {    
  211.  203   4                                      if(USB_Int_Flag.BITS.SUSP || Kernel_Flag.BITS.Bus_Reset || USB_Int_Flag.BITS.EP0SETUP)
  212.  204   4                                              break;
  213.  205   4                              }    
  214.  206   3                              EA_DISABLE;
  215.  207   3                              USB_Int_Flag.BITS.EP2TX = 0;
  216.  208   3                              EA_ENABLE;
  217.  209   3                              bytecount -= Datcount; 
  218.  210   3                      }while(bytecount);
  219.  211   2                      //stop DMA controller
  220.  212   2                      DMA_Start = GDMA_Stop;
  221.  213   2                      //transfewr done,reset internal variables
  222.  214   2                      DMA_Int_Flag.BITS.DMA_DONE = 0;
  223.  215   2                      Count_PIO = 0;
  224.  216   2              }
  225.  217   1              Kernel_Flag.BITS.Transfer_Start = 0;  
  226.  218   1      }
  227.  219          
  228. MODULE INFORMATION:   STATIC OVERLAYABLE
  229.    CODE SIZE        =    619    ----
  230.    CONSTANT SIZE    =   ----    ----
  231.    XDATA SIZE       =   ----    ----
  232.    PDATA SIZE       =   ----    ----
  233.    DATA SIZE        =      2       4
  234.    IDATA SIZE       =   ----    ----
  235.    BIT SIZE         =   ----    ----
  236. END OF MODULE INFORMATION.
  237. C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)