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

📄 bulksrc.lst

📁 批量端点无限发送接受侧试,EP2OUT和EP4OUT,EP6IN总是返回一个512字节包
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.10  BULKSRC                                                                08/10/2004 11:57:18 PAGE 1   


C51 COMPILER V6.10, COMPILATION OF MODULE BULKSRC
OBJECT MODULE PLACED IN .\bulksrc.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\bulksrc.c DEBUG OBJECTEXTEND

stmt level    source

   1          #pragma NOIV               // Do not generate interrupt vectors
   2          //-----------------------------------------------------------------------------
   3          //   File:      bulksrc.c
   4          //   Contents:   Hooks required to implement USB peripheral function.
   5          //
   6          // $Archive: /USB/Examples/Fx2/bulksrc/bulksrc.c $
   7          // $Date: 11/10/01 11:41a $
   8          // $Revision: 9 $
   9          //
  10          //   Copyright (c) 2000 Cypress Semiconductor All rights reserved
  11          //-----------------------------------------------------------------------------
  12          #include "fx2.h"
  13          #include "fx2regs.h"
  14          #include "fx2sdly.h"            // SYNCDELAY macro
  15          
  16          extern BOOL GotSUD;             // Received setup data flag
  17          extern BOOL Sleep;
  18          extern BOOL Rwuen;
  19          extern BOOL Selfpwr;
  20          
  21          BYTE Configuration;             // Current configuration
  22          BYTE AlternateSetting;          // Alternate settings
  23          BYTE xdata myBuffer[512];
  24          WORD myBufferCount;
  25          
  26          //-----------------------------------------------------------------------------
  27          // Task Dispatcher hooks
  28          //   The following hooks are called by the task dispatcher.
  29          //-----------------------------------------------------------------------------
  30          
  31          void TD_Init(void)              // Called once at startup
  32          {
  33   1        int i;
  34   1      
  35   1        // set the CPU clock to 48MHz
  36   1        CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
  37   1      
  38   1        // set the slave FIFO interface to 48MHz
  39   1        IFCONFIG |= 0x40;
  40   1      
  41   1        // Registers which require a synchronization delay, see section 15.14
  42   1        // FIFORESET        FIFOPINPOLAR
  43   1        // INPKTEND         OUTPKTEND
  44   1        // EPxBCH:L         REVCTL
  45   1        // GPIFTCB3         GPIFTCB2
  46   1        // GPIFTCB1         GPIFTCB0
  47   1        // EPxFIFOPFH:L     EPxAUTOINLENH:L
  48   1        // EPxFIFOCFG       EPxGPIFFLGSEL
  49   1        // PINFLAGSxx       EPxFIFOIRQ
  50   1        // EPxFIFOIE        GPIFIRQ
  51   1        // GPIFIE           GPIFADRH:L
  52   1        // UDMACRCH:L       EPxGPIFTRIG
  53   1        // GPIFTRIG
  54   1        
  55   1        // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
C51 COMPILER V6.10  BULKSRC                                                                08/10/2004 11:57:18 PAGE 2   

  56   1        //      ...these have been replaced by GPIFTC[B3:B0] registers
  57   1      
  58   1        // default: all endpoints have their VALID bit set
  59   1        // default: TYPE1 = 1 and TYPE0 = 0 --> BULK  
  60   1        // default: EP2 and EP4 DIR bits are 0 (OUT direction)
  61   1        // default: EP6 and EP8 DIR bits are 1 (IN direction)
  62   1        // default: EP2, EP4, EP6, and EP8 are double buffered
  63   1      
  64   1        // we are just using the default values, yes this is not necessary...
  65   1        EP1OUTCFG = 0xA0;
  66   1        EP1INCFG = 0xA0;
  67   1        SYNCDELAY;                    // see TRM section 15.14
  68   1        EP2CFG = 0xA2;
  69   1        SYNCDELAY;                    // 
  70   1        EP4CFG = 0xA0;
  71   1        SYNCDELAY;                    // 
  72   1        EP6CFG = 0xE2;
  73   1        SYNCDELAY;                    // 
  74   1        EP8CFG = 0xE0;
  75   1      
  76   1        // out endpoints do not come up armed
  77   1        
  78   1        // since the defaults are double buffered we must write dummy byte counts twice
  79   1        SYNCDELAY;                    // 
  80   1        EP2BCL = 0x80;                // arm EP2OUT by writing byte count w/skip.
  81   1        SYNCDELAY;                    // 
  82   1        EP4BCL = 0x80;    
  83   1        SYNCDELAY;                    // 
  84   1        EP2BCL = 0x80;                // arm EP4OUT by writing byte count w/skip.
  85   1        SYNCDELAY;                    // 
  86   1        EP4BCL = 0x80;    
  87   1      
  88   1        // fill up both IN endpoints
  89   1      
  90   1        for (i=0;i<512;i++)
  91   1           EP6FIFOBUF[i] = i+2;
  92   1        SYNCDELAY;                    // 
  93   1        EP6BCH = 0x02;
  94   1        SYNCDELAY;                    // 
  95   1        EP6BCL = 0x00;
  96   1      
  97   1        for (i=0;i<512;i++)
  98   1           EP6FIFOBUF[i] = i+2;
  99   1        SYNCDELAY;                    // 
 100   1        EP6BCH = 0x02;
 101   1        SYNCDELAY;                    // 
 102   1        EP6BCL = 0x00;
 103   1      
 104   1        myBufferCount = 0;
 105   1      
 106   1        // enable dual autopointer(s)
 107   1        AUTOPTRSETUP |= 0x01;  
 108   1      
 109   1        Rwuen = TRUE;                 // Enable remote-wakeup
 110   1      }
 111          
 112          void TD_Poll(void)              // Called repeatedly while the device is idle
 113          {
 114   1         int i;
 115   1      
 116   1         // if there is some data in EP2 OUT, re-arm it
 117   1         if(!(EP2468STAT & bmEP2EMPTY))
C51 COMPILER V6.10  BULKSRC                                                                08/10/2004 11:57:18 PAGE 3   

 118   1         {
 119   2            SYNCDELAY;                // 
 120   2            EP2BCL = 0x80;
 121   2         }
 122   1      
 123   1         // if EP6 IN is available, re-arm it
 124   1         if(!(EP2468STAT & bmEP6FULL))
 125   1         {
 126   2            SYNCDELAY;                // 
 127   2            EP6BCH = 0x02;
 128   2            SYNCDELAY;                // 
 129   2            EP6BCL = 0x00;
 130   2         }
 131   1      
 132   1         // if there is new data in EP4FIFOBUF, then copy it to a temporary buffer
 133   1         if(!(EP2468STAT & bmEP4EMPTY))
 134   1         {
 135   2            APTR1H = MSB( &EP4FIFOBUF );
 136   2            APTR1L = LSB( &EP4FIFOBUF );
 137   2      
 138   2            AUTOPTRH2 = MSB( &myBuffer );
 139   2            AUTOPTRL2 = LSB( &myBuffer );
 140   2      
 141   2            myBufferCount = (EP4BCH << 8) + EP4BCL;
 142   2      
 143   2            for( i = 0x0000; i < myBufferCount; i++ )
 144   2            {
 145   3               EXTAUTODAT2 = EXTAUTODAT1;
 146   3            }
 147   2      
 148   2            SYNCDELAY;                // 
 149   2            EP4BCL = 0x80;            // re(arm) EP4OUT
 150   2         }
 151   1      
 152   1         // if there is room in EP8IN, then copy the contents of the temporarty buffer to it
 153   1         if(!(EP2468STAT & bmEP8FULL) && myBufferCount)
 154   1         {
 155   2            APTR1H = MSB( &myBuffer );
 156   2            APTR1L = LSB( &myBuffer );
 157   2      
 158   2            AUTOPTRH2 = MSB( &EP8FIFOBUF );
 159   2            AUTOPTRL2 = LSB( &EP8FIFOBUF );
 160   2      
 161   2            for( i = 0x0000; i < myBufferCount; i++ )
 162   2            {
 163   3               // setup to transfer EP4OUT buffer to EP8IN buffer using AUTOPOINTER(s) in SFR space
 164   3               EXTAUTODAT2 = EXTAUTODAT1;
 165   3            }
 166   2            SYNCDELAY;                    // 
 167   2            EP8BCH = MSB(myBufferCount);
 168   2            SYNCDELAY;                    // 
 169   2            EP8BCL = LSB(myBufferCount);  // arm EP8IN
 170   2         }
 171   1      
 172   1      }
 173          
 174          BOOL TD_Suspend(void)          // Called before the device goes into suspend mode
 175          {
 176   1         return(TRUE);
 177   1      }
 178          
 179          BOOL TD_Resume(void)          // Called after the device resumes
C51 COMPILER V6.10  BULKSRC                                                                08/10/2004 11:57:18 PAGE 4   

 180          {
 181   1         return(TRUE);
 182   1      }
 183          
 184          //-----------------------------------------------------------------------------
 185          // Device Request hooks
 186          //   The following hooks are called by the end point 0 device request parser.
 187          //-----------------------------------------------------------------------------
 188          
 189          BOOL DR_GetDescriptor(void)
 190          {
 191   1         return(TRUE);
 192   1      }
 193          
 194          BOOL DR_SetConfiguration(void)   // Called when a Set Configuration command is received
 195          {
 196   1         Configuration = SETUPDAT[2];
 197   1         return(TRUE);            // Handled by user code
 198   1      }
 199          
 200          BOOL DR_GetConfiguration(void)   // Called when a Get Configuration command is received
 201          {
 202   1         EP0BUF[0] = Configuration;
 203   1         EP0BCH = 0;
 204   1         EP0BCL = 1;
 205   1         return(TRUE);            // Handled by user code
 206   1      }
 207          
 208          BOOL DR_SetInterface(void)       // Called when a Set Interface command is received
 209          {
 210   1         AlternateSetting = SETUPDAT[2];
 211   1         return(TRUE);            // Handled by user code

⌨️ 快捷键说明

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