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

📄 scusb.lst

📁 psoc_usb的代码,用来小卡测试的.没事下下来
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.06   SCUSB                                                                 01/31/2008 22:24:27 PAGE 1   


C51 COMPILER V8.06, COMPILATION OF MODULE SCUSB
OBJECT MODULE PLACED IN scusb.OBJ
COMPILER INVOKED BY: C:\Program Files\Keil\C51\BIN\C51.EXE scusb.c OPTIMIZE(9,SPEED) MODDP2 INCDIR(C:\Cypress\USB\Target
                    -\Inc) DEFINE(__USE_USB__) DEBUG OBJECTEXTEND

line level    source

   1          //-----------------------------------------------------------------------------
   2          //   File:      peripheral.c
   3          //   Contents:  Hooks required to implement USB peripheral function.
   4          //
   5          // $Archive: /USB/Examples/FX2LP/bulkext/peripheral.c $
   6          // $Date: 3/23/05 2:53p $
   7          // $Revision: 3 $
   8          //
   9          //
  10          //-----------------------------------------------------------------------------
  11          // Copyright 2003, Cypress Semiconductor Corporation
  12          //-----------------------------------------------------------------------------
  13          #pragma NOIV               // Do not generate interrupt vectors
  14          #include <ctype.h>
  15          
  16          #include "fx2.h"
  17          #include "fx2regs.h"
  18          #include "syncdly.h"            // SYNCDELAY macro
  19          #include "scmain.h"
  20          
  21          //-----------------------------------------------------------------------------
  22          // extern function for smallcard test
  23          //-----------------------------------------------------------------------------
  24          extern int user_init();
  25          extern int user_loop();
  26          extern int sc_main(char *cmd_buff,int size);  
  27          extern void sc_process_blinking();
  28          
  29          //-----------------------------------------------------------------------------
  30          //extern & define  for usb firmware framework
  31          //-----------------------------------------------------------------------------
  32          extern BOOL GotSUD;             // Received setup data flag
  33          extern BOOL Sleep;
  34          extern BOOL Rwuen;
  35          extern BOOL Selfpwr;
  36          
  37          BYTE Configuration;             // Current configuration
  38          BYTE AlternateSetting;          // Alternate settings
  39          
  40          extern BYTE xdata g_in_buffer[BUFF_LENGTH];
  41          extern WORD xdata g_loopcount;
  42          extern WORD xdata g_in_buffer_len;
  43          //-----------------------------------------------------------------------------
  44          // Task Dispatcher hooks
  45          // The following hooks are called by the task dispatcher.
  46          //-----------------------------------------------------------------------------
  47          void TD_Init(void)             // Called once at startup
  48          {
  49   1          // set the CPU clock to 48MHz
  50   1          CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
  51   1      
  52   1          // set the slave FIFO interface to 48MHz
  53   1          IFCONFIG |= 0x40;
  54   1             
C51 COMPILER V8.06   SCUSB                                                                 01/31/2008 22:24:27 PAGE 2   

  55   1          // Registers which require a synchronization delay, see section 15.14
  56   1          // FIFORESET        FIFOPINPOLAR
  57   1          // INPKTEND         OUTPKTEND
  58   1          // EPxBCH:L         REVCTL
  59   1          // GPIFTCB3         GPIFTCB2
  60   1          // GPIFTCB1         GPIFTCB0
  61   1          // EPxFIFOPFH:L     EPxAUTOINLENH:L
  62   1          // EPxFIFOCFG       EPxGPIFFLGSEL
  63   1          // PINFLAGSxx       EPxFIFOIRQ
  64   1          // EPxFIFOIE        GPIFIRQ
  65   1          // GPIFIE           GPIFADRH:L
  66   1          // UDMACRCH:L       EPxGPIFTRIG
  67   1          // GPIFTRIG
  68   1          
  69   1          // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
  70   1          //      ...these have been replaced by GPIFTC[B3:B0] registers
  71   1          
  72   1          // default: all endpoints have their VALID bit set
  73   1          // default: TYPE1 = 1 and TYPE0 = 0 --> BULK  
  74   1          // default: EP2 and EP4 DIR bits are 0 (OUT direction)
  75   1          // default: EP6 and EP8 DIR bits are 1 (IN direction)
  76   1          // default: EP2, EP4, EP6, and EP8 are double buffered
  77   1        
  78   1          // we are just using the default values, yes this is not necessary...
  79   1          EP1OUTCFG = 0xA0;
  80   1          EP1INCFG = 0xA0;
  81   1          SYNCDELAY;                    // see TRM section 15.14
  82   1          EP2CFG = 0xA2;
  83   1          SYNCDELAY;                    
  84   1          EP6CFG = 0xE2;
  85   1          
  86   1          SYNCDELAY;                    
  87   1          EP4CFG = 0xA0;
  88   1          SYNCDELAY;                    
  89   1          EP8CFG = 0xE0;
  90   1        
  91   1          // out endpoints do not come up armed
  92   1          // since the defaults are double buffered we must write dummy byte counts twice
  93   1          SYNCDELAY;                    
  94   1          EP2BCL = 0x80;                // arm EP2OUT by writing byte count w/skip.
  95   1          SYNCDELAY;                    
  96   1          EP2BCL = 0x80;
  97   1      
  98   1          SYNCDELAY;                    
  99   1          EP4BCL = 0x80;                // arm EP4OUT by writing byte count w/skip.
 100   1          SYNCDELAY;                    
 101   1          EP4BCL = 0x80;    
 102   1        
 103   1          // enable dual autopointer feature
 104   1          AUTOPTRSETUP |= 0x01;
 105   1          
 106   1          //init variable
 107   1          g_in_buffer_len = 0;
 108   1          
 109   1          //call user init function
 110   1          user_init();
 111   1      }
 112          
 113          void TD_Poll(void)              // Called repeatedly while the device is idle
 114          {
 115   1          WORD i;
 116   1          WORD count;
C51 COMPILER V8.06   SCUSB                                                                 01/31/2008 22:24:27 PAGE 3   

 117   1      
 118   1          // if there is new data in EP2FIFOBUF, then copy it to a temporary buffer
 119   1          if(!(EP2468STAT & bmEP2EMPTY)) {
 120   2              // Source is EP2OUT
 121   2              APTR1H = MSB( &EP2FIFOBUF );
 122   2              APTR1L = LSB( &EP2FIFOBUF );
 123   2              
 124   2              // Destination is external RAM
 125   2              AUTOPTRH2 = MSB( &g_in_buffer );
 126   2              AUTOPTRL2 = LSB( &g_in_buffer );
 127   2                  
 128   2              g_in_buffer_len = (EP2BCH << 8) + EP2BCL;
 129   2              for( i = 0x0000; i < g_in_buffer_len; i++ ) {
 130   3                  EXTAUTODAT2 = EXTAUTODAT1;
 131   3              }
 132   2      
 133   2              SYNCDELAY;                    
 134   2              EP2BCL = 0x80;                      // re(arm) EP2OUT
 135   2      
 136   2              if (g_in_buffer_len){
 137   3                  g_in_buffer_len = sc_main(g_in_buffer,g_in_buffer_len);
 138   3              }        
 139   2          }
 140   1          
 141   1          // if there is room in EP6IN, then copy the contents of the temporarty buffer to it
 142   1          if(!(EP2468STAT & bmEP6FULL) && g_in_buffer_len) {
 143   2              APTR1H = MSB( &g_in_buffer );
 144   2              APTR1L = LSB( &g_in_buffer );
 145   2      
 146   2              AUTOPTRH2 = MSB( &EP6FIFOBUF );
 147   2              AUTOPTRL2 = LSB( &EP6FIFOBUF );
 148   2      
 149   2              for( i = 0x0000; i < g_in_buffer_len; i++ ) {
 150   3                  EXTAUTODAT2 = EXTAUTODAT1;
 151   3              }
 152   2              
 153   2              SYNCDELAY;                    // 
 154   2              EP6BCH = MSB(g_in_buffer_len);
 155   2              SYNCDELAY;                    // 
 156   2              EP6BCL = LSB(g_in_buffer_len);  // arm EP6IN
 157   2              
 158   2              g_in_buffer_len=0;        
 159   2          }
 160   1      
 161   1          //use EP4(out) & EP8(in) as loop test 
 162   1          if(!(EP2468STAT & bmEP4EMPTY)) { // check EP4 EMPTY(busy) bit in EP2468STAT (SFR), core set's this bit
             - when FIFO is empty
 163   2               if(!(EP2468STAT & bmEP8FULL)) {  // check EP8 FULL(busy) bit in EP2468STAT (SFR), core set's this
             - bit when FIFO is full
 164   3                    APTR1H = MSB( &EP4FIFOBUF );
 165   3                    APTR1L = LSB( &EP4FIFOBUF );
 166   3            
 167   3                    AUTOPTRH2 = MSB( &EP8FIFOBUF );
 168   3                    AUTOPTRL2 = LSB( &EP8FIFOBUF );
 169   3            
 170   3                    count = (EP4BCH << 8) + EP4BCL;
 171   3                    // loop EP4OUT buffer data to EP8IN
 172   3                    for( i = 0x0000; i < count; i++ ) {
 173   4                       // setup to transfer EP4OUT buffer to EP8IN buffer using AUTOPOINTER(s)
 174   4                       EXTAUTODAT2 = EXTAUTODAT1;
 175   4                    }
 176   3                    EP8BCH = EP4BCH;  
C51 COMPILER V8.06   SCUSB                                                                 01/31/2008 22:24:27 PAGE 4   

 177   3                    SYNCDELAY;  
 178   3                    EP8BCL = EP4BCL;        // arm EP8IN
 179   3                    SYNCDELAY;                    
 180   3                    EP4BCL = 0x80;          // re(arm) EP4OUT
 181   3               }
 182   2          }
 183   1      
 184   1          //process blinking                
 185   1          if (0 == (g_loopcount%5000)) {
 186   2              sc_process_blinking();
 187   2          }
 188   1          
 189   1          //process user loop
 190   1          if (0 == (g_loopcount%1000)) {
 191   2              user_loop();
 192   2          }
 193   1          
 194   1          //inc counter
 195   1          g_loopcount++;
 196   1      }
 197          
 198          BOOL TD_Suspend(void)          // Called before the device goes into suspend mode
 199          {
 200   1         return(TRUE);
 201   1      }
 202          
 203          BOOL TD_Resume(void)          // Called after the device resumes
 204          {
 205   1         return(TRUE);
 206   1      }
 207          
 208          //-----------------------------------------------------------------------------
 209          // Device Request hooks
 210          //   The following hooks are called by the end point 0 device request parser.
 211          //-----------------------------------------------------------------------------
 212          
 213          BOOL DR_GetDescriptor(void)
 214          {
 215   1         return(TRUE);
 216   1      }
 217          
 218          BOOL DR_SetConfiguration(void)   // Called when a Set Configuration command is received
 219          {
 220   1         Configuration = SETUPDAT[2];
 221   1         return(TRUE);            // Handled by user code
 222   1      }

⌨️ 快捷键说明

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