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

📄 inttest.lst

📁 FX2开发程序 中断传输方式包括上层软件
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.02   INTTEST                                                               10/20/2008 14:59:23 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE INTTEST
OBJECT MODULE PLACED IN intTest.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE intTest.c DEBUG OBJECTEXTEND

line level    source

   1          #pragma NOIV               // Do not generate interrupt vectors
   2          //-----------------------------------------------------------------------------
   3          //   File:      bulkloop.c
   4          //   Contents:   Hooks required to implement USB peripheral function.
   5          //
   6          //   Copyright (c) 2000 Cypress Semiconductor All rights reserved
   7          //-----------------------------------------------------------------------------
   8          #include "fx2.h"
   9          #include "fx2regs.h"
  10          #include "fx2sdly.h"            // SYNCDELAY macro
  11          
  12          extern BOOL GotSUD;             // Received setup data flag
  13          extern BOOL Sleep;
  14          extern BOOL Rwuen;
  15          extern BOOL Selfpwr;
  16          
  17          BYTE Configuration;             // Current configuration
  18          BYTE AlternateSetting;          // Alternate settings
  19          
  20          #define VR_NAKALL_ON    0xD0
  21          #define VR_NAKALL_OFF   0xD1
  22          
  23          
  24          BOOL bInEnable;//IN中断传输使能,通过控制传输设置
  25          BYTE status;//状态字节,调试用,通过控制传输读取
  26          //BYTE xdata Digit[] = { 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, 0x88, 0x83, 0xc6, 0xa
             -1, 0x86, 0x8e };
  27          BYTE xdata Digit[] = { 0xC0, 0xf9, 0x64, 0x46, 0x4b, 0x52, 0x50, 0xc7, 0x40, 0x43, 0x41, 0x58, 0xf0, 0x4c,
             - 0x70, 0x71 };
  28          
  29          //#define BTN_ADDR              0x20
  30          //#define LED_ADDR              0x21
  31          
  32          #define BTN_ADDR                0x38
  33          #define LED_ADDR                0x39
  34          
  35          //-----------------------------------------------------------------------------
  36          // Task Dispatcher hooks
  37          //   The following hooks are called by the task dispatcher.
  38          //-----------------------------------------------------------------------------
  39          
  40          void TD_Init(void)             // Called once at startup
  41          {
  42   1         // set the CPU clock to 48MHz
  43   1         CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;
  44   1      
  45   1         // set the slave FIFO interface to 48MHz
  46   1         IFCONFIG |= 0x40;
  47   1      
  48   1        // Registers which require a synchronization delay, see section 15.14
  49   1        // FIFORESET        FIFOPINPOLAR
  50   1        // INPKTEND         OUTPKTEND
  51   1        // EPxBCH:L         REVCTL
  52   1        // GPIFTCB3         GPIFTCB2
  53   1        // GPIFTCB1         GPIFTCB0
C51 COMPILER V8.02   INTTEST                                                               10/20/2008 14:59:23 PAGE 2   

  54   1        // EPxFIFOPFH:L     EPxAUTOINLENH:L
  55   1        // EPxFIFOCFG       EPxGPIFFLGSEL
  56   1        // PINFLAGSxx       EPxFIFOIRQ
  57   1        // EPxFIFOIE        GPIFIRQ
  58   1        // GPIFIE           GPIFADRH:L
  59   1        // UDMACRCH:L       EPxGPIFTRIG
  60   1        // GPIFTRIG
  61   1        
  62   1        // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
  63   1        //      ...these have been replaced by GPIFTC[B3:B0] registers
  64   1      
  65   1        // default: all endpoints have their VALID bit set
  66   1        // default: TYPE1 = 1 and TYPE0 = 0 --> BULK  
  67   1        // default: EP2 and EP4 DIR bits are 0 (OUT direction)
  68   1        // default: EP6 and EP8 DIR bits are 1 (IN direction)
  69   1        // default: EP2, EP4, EP6, and EP8 are double buffered
  70   1      
  71   1        // we are just using the default values, yes this is not necessary...
  72   1        EP1OUTCFG = 0xA0;
  73   1        EP1INCFG = 0xA0;
  74   1      
  75   1        SYNCDELAY;                    // see TRM section 15.14 
  76   1        EP2CFG = 0xB2;  //端点2 OUT INT 2xBUFFER 
  77   1        SYNCDELAY;                    
  78   1        EP4CFG = 0x00; //无效
  79   1        SYNCDELAY;                    
  80   1        EP6CFG = 0xF2; //端点6 IN INT 2xBUFFER   
  81   1        SYNCDELAY;                    
  82   1        EP8CFG = 0x00;//无效
  83   1      
  84   1        // out endpoints do not come up armed
  85   1        
  86   1        // since the defaults are double buffered we must write dummy byte counts twice
  87   1        SYNCDELAY;                    
  88   1        EP2BCL = 0x80;                // arm EP2OUT by writing byte count w/skip.
  89   1        SYNCDELAY;                    
  90   1        EP2BCL = 0x80;
  91   1        SYNCDELAY;                       
  92   1        bInEnable=FALSE;//全局变量初始化 中断IN传输使能
  93   1        status=0;
  94   1        // enable dual autopointer feature
  95   1        AUTOPTRSETUP |= 0x01;
  96   1      
  97   1      
  98   1        Rwuen = TRUE;                 // Enable remote-wakeup
  99   1      }
 100          
 101          
 102          void TD_Poll(void)              // Called repeatedly while the device is idle
 103          {
 104   1        WORD i;
 105   1        EZUSB_InitI2C();                      //初始化EZ-USB I2控制器
 106   1       //中断IN传输
 107   1        if(bInEnable)
 108   1        {  
 109   2           if(!(EP2468STAT & bmEP6FULL))
 110   2           {
 111   3                       
 112   3                      for( i = 0x0000; i < 0x200; i++ )
 113   3              {
 114   4      
 115   4                         EP6FIFOBUF[i]=(BYTE)(i&0x00ff);
C51 COMPILER V8.02   INTTEST                                                               10/20/2008 14:59:23 PAGE 3   

 116   4      
 117   4              }
 118   3                       EP6BCH = 0x02;
 119   3                       SYNCDELAY;  
 120   3                       EP6BCL = 0x00; 
 121   3                       SYNCDELAY;  
 122   3               }
 123   2                bInEnable=FALSE;
 124   2                status+=1;
 125   2            EZUSB_WriteI2C(LED_ADDR, 0x01, &(Digit[status&0x0f]));
 126   2            EZUSB_WaitForEEPROMWrite(LED_ADDR);
 127   2      
 128   2        }
 129   1        //中断OUT传输
 130   1          if(!(EP2468STAT & bmEP2EMPTY))
 131   1           {                  
 132   2                  EZUSB_WriteI2C(LED_ADDR, 0x01, &(Digit[EP2FIFOBUF[0]&0x0f]));
 133   2              EZUSB_WaitForEEPROMWrite(LED_ADDR);
 134   2                      EP2BCL = 0x80;
 135   2                      SYNCDELAY;
 136   2                  EP2BCL = 0x80;
 137   2                      SYNCDELAY; 
 138   2               }
 139   1      }
 140          
 141          BOOL TD_Suspend(void)          // Called before the device goes into suspend mode
 142          {
 143   1         return(TRUE);
 144   1      }
 145          
 146          BOOL TD_Resume(void)          // Called after the device resumes
 147          {
 148   1         return(TRUE);
 149   1      }
 150          
 151          //-----------------------------------------------------------------------------
 152          // Device Request hooks
 153          //   The following hooks are called by the end point 0 device request parser.
 154          //-----------------------------------------------------------------------------
 155          
 156          BOOL DR_GetDescriptor(void)
 157          {
 158   1         return(TRUE);
 159   1      }
 160          
 161          BOOL DR_SetConfiguration(void)   // Called when a Set Configuration command is received
 162          {
 163   1         Configuration = SETUPDAT[2];
 164   1         return(TRUE);            // Handled by user code
 165   1      }
 166          
 167          BOOL DR_GetConfiguration(void)   // Called when a Get Configuration command is received
 168          {
 169   1         EP0BUF[0] = Configuration;
 170   1         EP0BCH = 0;
 171   1         EP0BCL = 1;
 172   1         return(TRUE);            // Handled by user code
 173   1      }
 174          
 175          BOOL DR_SetInterface(void)       // Called when a Set Interface command is received
 176          {
 177   1         AlternateSetting = SETUPDAT[2];
C51 COMPILER V8.02   INTTEST                                                               10/20/2008 14:59:23 PAGE 4   

 178   1         return(TRUE);            // Handled by user code
 179   1      }
 180          
 181          BOOL DR_GetInterface(void)       // Called when a Set Interface command is received
 182          {
 183   1         EP0BUF[0] = AlternateSetting;
 184   1         EP0BCH = 0;
 185   1         EP0BCL = 1;
 186   1         return(TRUE);            // Handled by user code
 187   1      }
 188          
 189          BOOL DR_GetStatus(void)
 190          {
 191   1         return(TRUE);
 192   1      }
 193          
 194          BOOL DR_ClearFeature(void)
 195          {
 196   1         return(TRUE);
 197   1      }
 198          
 199          BOOL DR_SetFeature(void)
 200          {
 201   1         return(TRUE);
 202   1      }
 203          #define VR_B3 0xB3 // enable interrupt trans使能中断IN传输
 204          #define VR_B4 0xB4 // disenable interrupt trans非使能中断IN传输
 205          #define VR_B5 0xB5 //读取STATUS状态位
 206          BOOL DR_VendorCmnd(void)
 207          {
 208   1        BYTE tmp;
 209   1        
 210   1        switch (SETUPDAT[1])
 211   1        {
 212   2           case VR_NAKALL_ON:

⌨️ 快捷键说明

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