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

📄 fw.lst

📁 在KEILC下进行编译的程序,单片机可以进行AD,DA数据采集
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.09   FW                                                                    04/03/2007 16:19:12 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE FW
OBJECT MODULE PLACED IN fw.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE fw.c BROWSE

line level    source

   1          //-----------------------------------------------------------------------------
   2          //   File:      fw.c
   3          //   Contents:   Firmware frameworks task dispatcher and device request parser
   4          //            source.
   5          //   包含硬件框架任务 调度和设备请求源
   6          // indent 3.  NO TABS!
   7          //
   8          // $Revision: 1 $
   9          // $Date: 07/03/26 8:36a $
  10          //
  11          //   Copyright (c) 1997 weiyong. All rights reserved
  12          //-----------------------------------------------------------------------------
  13          #include "fx2.h"
  14          #include "fx2regs.h"
  15          #include "string.h"
  16          #include "io.h"
  17          #include "key.h"
  18          #include "led.h"
  19          //#include "serial.h"
  20          #include "eeprom.h"
  21          
  22          //-----------------------------------------------------------------------------
  23          // Constants
  24          //-----------------------------------------------------------------------------
  25          #define DELAY_COUNT   0x9248*8L  // Delay for 8 sec at 24Mhz, 4 sec at 48
  26          #define _IFREQ  48000            // IFCLK constant for Synchronization Delay
  27          #define _CFREQ  48000            // CLKOUT constant for Synchronization Delay
  28          
  29          //-----------------------------------------------------------------------------
  30          // Random Macros
  31          //-----------------------------------------------------------------------------
  32          #define   min(a,b) (((a)<(b))?(a):(b))
  33          #define   max(a,b) (((a)>(b))?(a):(b))
  34          
  35            // Registers which require a synchronization delay, see section 15.14
  36            // FIFORESET        FIFOPINPOLAR
  37            // INPKTEND         OUTPKTEND
  38            // EPxBCH:L         REVCTL
  39            // GPIFTCB3         GPIFTCB2
  40            // GPIFTCB1         GPIFTCB0
  41            // EPxFIFOPFH:L     EPxAUTOINLENH:L
  42            // EPxFIFOCFG       EPxGPIFFLGSEL
  43            // PINFLAGSxx       EPxFIFOIRQ
  44            // EPxFIFOIE        GPIFIRQ
  45            // GPIFIE           GPIFADRH:L
  46            // UDMACRCH:L       EPxGPIFTRIG
  47            // GPIFTRIG
  48            
  49            // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
  50            //      ...these have been replaced by GPIFTC[B3:B0] registers
  51            
  52          #include "fx2sdly.h"             // Define _IFREQ and _CFREQ above this #include
  53          
  54          //-----------------------------------------------------------------------------
  55          // Global Variables全局变量
C51 COMPILER V7.09   FW                                                                    04/03/2007 16:19:12 PAGE 2   

  56          //-----------------------------------------------------------------------------
  57          volatile BOOL   GotSUD;//可变的BOOL变量
  58          BOOL      Rwuen;
  59          BOOL      Selfpwr;
  60          volatile BOOL   Sleep;                  // Sleep mode enable flag睡眠模式的表示
  61          
  62          WORD   pDeviceDscr;   // Pointer to Device Descriptor; Descriptors may be moved
  63          WORD   pDeviceQualDscr; //设备限定描述
  64          WORD   pHighSpeedConfigDscr;//高速配置
  65          WORD   pFullSpeedConfigDscr;//全速配置
  66          WORD   pConfigDscr;
  67          WORD   pOtherConfigDscr;   
  68          WORD   pStringDscr;   
  69          
  70          //char   AD_X;
  71          // int tttttt;
  72          //-----------------------------------------------------------------------------
  73          // Prototypes函数原形
  74          //-----------------------------------------------------------------------------
  75          void SetupCommand(void);                  //设置命令函数
  76          void TD_Init(void);                       //初始化函数
  77          void TD_Poll(void);                       //测量??
  78          //----------------------
  79          void Sys_Timer0_Init ();
  80          
  81          void Sys_Timer1_Init (); 
  82          void ad0809();
  83          
  84          //void tttttt_ioa();
  85          //----------------------
  86          BOOL TD_Suspend(void);                    //挂起函数,设备进入挂起前调用
  87          BOOL TD_Resume(void);                     //设备恢复后调用。
  88          
  89          BOOL DR_GetDescriptor(void);              //得到描述符。BOOL变量
  90          BOOL DR_SetConfiguration(void);           //设置配置
  91          BOOL DR_GetConfiguration(void);           //得到配置
  92          BOOL DR_SetInterface(void);
  93          BOOL DR_GetInterface(void);
  94          BOOL DR_GetStatus(void);                  //得到状态
  95          BOOL DR_ClearFeature(void);               //清除状态
  96          BOOL DR_SetFeature(void);                 //设置特征
  97          BOOL DR_VendorCmnd(void);                 //用户自定义的函数
  98          
  99          // this table is used by the epcs macro 宏//里面没有EP0。
 100          const char code  EPCS_Offset_Lookup_Table[] =
 101          {
 102             0,    // EP1OUT
 103             1,    // EP1IN
 104             2,    // EP2OUT
 105             2,    // EP2IN
 106             3,    // EP4OUT
 107             3,    // EP4IN
 108             4,    // EP6OUT
 109             4,    // EP6IN
 110             5,    // EP8OUT
 111             5,    // EP8IN
 112          };
 113          
 114          
 115          
 116          //用于生成地址和状态寄存器的端点。
 117          // macro for generating the address of an endpoint's control and status register (EPnCS)
C51 COMPILER V7.09   FW                                                                    04/03/2007 16:19:12 PAGE 3   

 118          #define epcs(EP) (EPCS_Offset_Lookup_Table[(EP & 0x7E) | (EP > 128)] + 0xE6A1)
 119          
 120          //-----------------------------------------------------------------------------
 121          // Code
 122          //-----------------------------------------------------------------------------
 123          
 124          // Task dispatcher任务调度程序,分配任务
 125          void main(void)
 126          {
 127   1         DWORD   i;
 128   1         WORD   offset;//偏移量
 129   1         DWORD   DevDescrLen;//设备描述的长度
 130   1         DWORD   j=0;
 131   1         WORD   IntDescrAddr;//内部描述的地址
 132   1         WORD   ExtDescrAddr;//外部描述的地址
 133   1              BYTE temp_data;
 134   1      
 135   1         // Initialize Global States
 136   1         Sleep = FALSE;               // Disable sleep mode
 137   1         Rwuen = FALSE;               // Disable remote wakeup
 138   1         Selfpwr = FALSE;            // Disable self powered
 139   1         GotSUD = FALSE;               // Clear "Got setup data" flag
 140   1      
 141   1         // Initialize user device
 142   1         TD_Init();
 143   1              
 144   1         //////user init/////用户函数的初始化,包括IO初始化,寄存器初始化,显示初始化。
 145   1              IO_Init();
 146   1              REG_Init();
 147   1              OKey_RP_Init();
 148   1              Disp_Init();
 149   1              EEPROMInit();
 150   1      //------------------------
 151   1         Sys_Timer0_Init ();
 152   1         
 153   1      //   Sys_Timer1_Init (); 
 154   1      //------------------------
 155   1         // The following section of code is used to relocate the descriptor table. 
 156   1         //下面的部分代码用于重新部署描述表
 157   1         // Since the SUDPTRH and SUDPTRL are assigned the address of the descriptor 
 158   1         //因为SUDPTRH and SUDPTRL被分配到描述表的地址,描绘表必须被定位到片内内存中
 159   1         // table, the descriptor table must be located in on-part memory.
 160   1         // The 4K demo tools locate all code sections in external memory.
 161   1         //4K的演示工具把所有的代码定位到片外的内存中
 162   1         // The descriptor table is relocated by the frameworks ONLY if it is found 
 163   1         //只有描述表被发现被定位到外部内存时,描述表被框架重新定位。
 164   1         // to be located in external memory.
 165   1      
 166   1      
 167   1      
 168   1      
 169   1      
 170   1         pDeviceDscr = (WORD)&DeviceDscr;
 171   1         pDeviceQualDscr = (WORD)&DeviceQualDscr;
 172   1         pHighSpeedConfigDscr = (WORD)&HighSpeedConfigDscr;
 173   1         pFullSpeedConfigDscr = (WORD)&FullSpeedConfigDscr;
 174   1         pStringDscr = (WORD)&StringDscr;
 175   1      
 176   1         if ((WORD)&DeviceDscr & 0xe000)
 177   1         {
 178   2            IntDescrAddr = INTERNAL_DSCR_ADDR;
 179   2            ExtDescrAddr = (WORD)&DeviceDscr;
C51 COMPILER V7.09   FW                                                                    04/03/2007 16:19:12 PAGE 4   

 180   2            DevDescrLen = (WORD)&UserDscr - (WORD)&DeviceDscr + 2;
 181   2            for (i = 0; i < DevDescrLen; i++)
 182   2               *((BYTE xdata *)IntDescrAddr+i) = 0xCD;
 183   2            for (i = 0; i < DevDescrLen; i++)
 184   2               *((BYTE xdata *)IntDescrAddr+i) = *((BYTE xdata *)ExtDescrAddr+i);
 185   2            pDeviceDscr = IntDescrAddr;
 186   2            offset = (WORD)&DeviceDscr - INTERNAL_DSCR_ADDR;
 187   2            pDeviceQualDscr -= offset;
 188   2            pConfigDscr -= offset;
 189   2            pOtherConfigDscr -= offset;
 190   2            pHighSpeedConfigDscr -= offset;
 191   2            pFullSpeedConfigDscr -= offset;
 192   2            pStringDscr -= offset;
 193   2         }
 194   1      
 195   1         EZUSB_IRQ_ENABLE();            // Enable USB interrupt (INT2)
 196   1         EZUSB_ENABLE_RSMIRQ();            // Wake-up interrupt
 197   1      
 198   1         INTSETUP |= (bmAV2EN | bmAV4EN);     // Enable INT 2 & 4 autovectoring
 199   1      
 200   1         USBIE |= bmSUDAV | bmSUTOK | bmSUSP | bmURES | bmHSGRANT;   // Enable selected interrupts
 201   1      
 202   1      
 203   1      
 204   1      
 205   1      
 206   1        /////////user init///////////
 207   1      //      SerialPort_Init();//串口的初始化
 208   1      
 209   1      //Sys_Timer1and2_Init ();
 210   1        /////////////////////////////
 211   1         EA = 1;                  // Enable 8051 interrupts
 212   1      #ifndef NO_RENUM
 213   1         // Renumerate if necessary.  Do this by checking the renum bit.  If it
 214   1         // is already set, there is no need to renumerate.  The renum bit will
 215   1         // already be set if this firmware was loaded from an eeprom.
 216   1         if(!(USBCS & bmRENUM))
 217   1         {
 218   2             EZUSB_Discon(TRUE);   // renumerate
 219   2         }
 220   1      #endif
 221   1      
 222   1      
 223   1      
 224   1      
 225   1      
 226   1      
 227   1      
 228   1         // unconditionally re-connect.  If we loaded from eeprom we are
 229   1         //无条件重新连接,如果我们从EEPROM开始装载,我们断开,需要连接,如果我们重列举,这不是必须的,但不会有
 230   1         //任何害处
 231   1         // disconnected and need to connect.  If we just renumerated this
 232   1         // is not necessary but doesn't hurt anything
 233   1         USBCS &=~bmDISCON;
 234   1      //////////////////////////////////////////

⌨️ 快捷键说明

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