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

📄 periph.lst

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


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

line level    source

   1          #pragma NOIV               // Do not generate interrupt vectors
   2          //-----------------------------------------------------------------------------
   3          //   File:      periph.c
   4          //   Contents:   Hooks required to implement USB peripheral function.
   5          //
   6          //   Copyright (c) 1997 AnchorChips, Inc. All rights reserved
   7          //-----------------------------------------------------------------------------
   8          #include "fx2.h"
   9          #include "fx2regs.h"
  10          #include "io.h"
  11          #include "key.h"
  12          #include "led.h"
  13          //#include "serial.h"
  14          #include "eeprom.h"
  15          #include "fx2sdly.h"     
  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                  char AD_X1;
  24          //-----------------------------------------------------------------------------
  25          // Task Dispatcher hooks
  26          //   The following hooks are called by the task dispatcher.任务调度
  27          //-----------------------------------------------------------------------------
  28          
  29          void TD_Init(void)             // Called once at startup
  30          {
  31   1              REVCTL = 0x03; // MUST set REVCTL.0 and REVCTL.1 to 1
  32   1          SYNCDELAY;
  33   1          BREAKPT &= ~bmBPEN;      // to see BKPT LED go out TGE
  34   1          Rwuen = TRUE;            // Enable remote-wakeup*/
  35   1      }
  36          
  37          void TD_Poll(void)             // Called repeatedly while the device is idle
  38          {
  39   1      }
  40          
  41          BOOL TD_Suspend(void)          // Called before the device goes into suspend mode
  42          {
  43   1         return(TRUE);
  44   1      }
  45          
  46          BOOL TD_Resume(void)          // Called after the device resumes
  47          {
  48   1         return(TRUE);
  49   1      }
  50          
  51          //-----------------------------------------------------------------------------
  52          // Device Request hooks设备请求钩子程序
  53          //   The following hooks are called by the end point 0 device request parser.
  54          //-----------------------------------------------------------------------------
  55          //下面的钩子程序被端点0设备请求器调用
C51 COMPILER V7.09   PERIPH                                                                04/03/2007 16:19:05 PAGE 2   

  56          BOOL DR_GetDescriptor(void)
  57          {
  58   1         return(TRUE);
  59   1      }
  60          
  61          BOOL DR_SetConfiguration(void)   // Called when a Set Configuration command is received
  62          {
  63   1         Configuration = SETUPDAT[2];
  64   1         return(TRUE);            // Handled by user code
  65   1      }
  66          
  67          BOOL DR_GetConfiguration(void)   // Called when a Get Configuration command is received
  68          {
  69   1         EP0BUF[0] = Configuration;//34页,端口0
  70   1         EP0BCH = 0;               //32页,端口0
  71   1         EP0BCL = 1;
  72   1         return(TRUE);            // Handled by user code
  73   1      }
  74          
  75          BOOL DR_SetInterface(void)       // Called when a Set Interface command is received
  76          {
  77   1         AlternateSetting = SETUPDAT[2];//收到端口命令时
  78   1         return(TRUE);            // Handled by user code
  79   1      }
  80          
  81          BOOL DR_GetInterface(void)       // Called when a Set Interface command is received
  82          {
  83   1         EP0BUF[0] = AlternateSetting;
  84   1         EP0BCH = 0;
  85   1         EP0BCL = 1;
  86   1         return(TRUE);            // Handled by user code
  87   1      }
  88          
  89          BOOL DR_GetStatus(void)
  90          {
  91   1         return(TRUE);
  92   1      }
  93          
  94          BOOL DR_ClearFeature(void)
  95          {
  96   1         return(TRUE);
  97   1      }
  98          
  99          BOOL DR_SetFeature(void)
 100          {
 101   1         return(TRUE);
 102   1      }
 103          
 104          
 105          #define VR_UPLOAD               0xc0     //1100
 106          #define VR_DOWNLOAD             0x40     //0100
 107          
 108          #define ZSUSB20DDB_VENDOR_REQUEST_LED_DISP                0xB0   //led显示
 109          #define ZSUSB20DDB_VENDOR_REQUEST_KEY_READ                0xB1   //键盘读取
 110          #define ZSUSB20DDB_VENDOR_REQUEST_EEPROM_ACCESS           0xB2   //EEPROM访问
 111          #define ZSUSB20DDB_VENDOR_REQUEST_SRAM_ACCESS             0xB3   //SRAM访问
 112          //#define ZSUSB20DDB_VENDOR_REQUEST_SERIAL_ACCESS           0xB4   //串口访问
 113          
 114          ///////////////////////////////////////////////////////////////////////////
 115          
 116          #define ZSUSB20DDB_VENDOR_REQUEST_PA_ON_OFF               0xB6   //PA的亮/灭控制 
 117          #define ZSUSB20DDB_VENDOR_REQUEST_AD                      0xB7   //AD 
C51 COMPILER V7.09   PERIPH                                                                04/03/2007 16:19:05 PAGE 3   

 118          ///////////////////////////////////////////////////////////////////////////
 119          
 120          BOOL DR_VendorCmnd(void)
 121          {
 122   1              WORD            addr, len, bc;                         //这几个数都是WORD型变量
 123   1              WORD i;
 124   1      //      BYTE flag;
 125   1      //      BYTE xdata *point;
 126   1      
 127   1      
 128   1      ///////////////////////////////
 129   1      
 130   1      
 131   1        //  int j;
 132   1      
 133   1      ///////////////////////////////
 134   1      
 135   1              len = SETUPDAT[6];             //33页,是WLENGTH
 136   1              len |= (SETUPDAT[7] << 8);     //是长度的意思?左移动8位,然后或,是什么意思?
 137   1              switch(SETUPDAT[1])            //这个数据bmRequest,是否就是说把B0到B6等地址与应用软件通信?
 138   1              { 
 139   2                      case ZSUSB20DDB_VENDOR_REQUEST_LED_DISP:    //led显示
 140   2                      {
 141   3                              DispBuf[SETUPDAT[3]&3] = SETUPDAT[2];   //wValueH为第几位了led,wValueL为显示值
 142   3      
 143   3      
 144   3      //////////////////////////////
 145   3      /*      PORTACFG=0x00;
 146   3              OEA=0xFF;
 147   3              
 148   3              j++;
 149   3              if (j%2==0)
 150   3              IOA=0x55;
 151   3              if (j%2==1)
 152   3              IOA=0xAA;
 153   3              if (j>100)
 154   3              j=0;*/
 155   3      
 156   3      /////////////////////////////
 157   3      
 158   3                              break;
 159   3                      }
 160   2      //------------------------------------------------------//
 161   2      
 162   2              case ZSUSB20DDB_VENDOR_REQUEST_PA_ON_OFF:    //-------------------
 163   2                      {
 164   3              
 165   3      /*              PORTACFG=0x00;
 166   3                      OEA=0xFF;
 167   3                      IOA = SETUPDAT[2]; 
 168   3      
 169   3      */
 170   3                      //初始化A,B,C,D端口。
 171   3      /*      
 172   3                      j++;
 173   3                      if (j%2==0)
 174   3                      IOA=0x55;
 175   3                      if (j%2==1)
 176   3                      IOA=0xAA;
 177   3                      if (j>100)
 178   3                      j=0;
 179   3      */
C51 COMPILER V7.09   PERIPH                                                                04/03/2007 16:19:05 PAGE 4   

 180   3      
 181   3      /*              IFCONFIG=0x00;
 182   3      
 183   3                      OED=0xFF;
 184   3                      IOD = SETUPDAT[2]; 
 185   3      */
 186   3      
 187   3      
 188   3      //              PORTCCFG=0x00;
 189   3      //              OEC=0xFF;
 190   3      //              IOC = SETUPDAT[2]; 
 191   3      
 192   3                              
 193   3                      break;
 194   3                      }
 195   2      //有可能是通过SETUPDAT[2]或者   EP0BUF[0]这样的数组来进行数据传递的。
 196   2      case ZSUSB20DDB_VENDOR_REQUEST_AD:    //-------------------
 197   2                      {
 198   3                      char  ad;
 199   3      
 200   3                      ad= AD_X;
 201   3      //              ad=IOC;
 202   3                      //最大 值好像只能是127,如果是128,变成-128,256时为0;
 203   3      //              EP0BUF[0] = ad;             //把AD的值给        EP0BUF[0]
 204   3              
 205   3                      EP0BUF[0] = ad;   
 206   3                      EP0BCH = 0;
 207   3                      EP0BCL = 1;               
 208   3      
 209   3      
 210   3      //              SETUPDAT[2]=0x08;
 211   3                              
 212   3                      break;
 213   3                      }
 214   2      //------------------------------------------------------//
 215   2      
 216   2      
 217   2      
 218   2      
 219   2      
 220   2      
 221   2                      case ZSUSB20DDB_VENDOR_REQUEST_KEY_READ:    //键盘读取
 222   2                      {
 223   3                              if(OKey_Value != 0xFF)                  //如果有键盘被按下去了
 224   3                              {
 225   4                                      EP0BUF[0] = OKey_Value;             //把按件的值给      EP0BUF[0]
 226   4                                      EP0BCH = 0;
 227   4                                      EP0BCL = 1;                          //EP0BCL = 1的意思是有数据的长度
 228   4                                      OKey_Value = 0xFF;
 229   4                              }
 230   3                              else
 231   3                              {
 232   4                                      EP0BCH = 0;
 233   4                                      EP0BCL = 0;
 234   4                              }
 235   3                              break;
 236   3                      }
 237   2                      case ZSUSB20DDB_VENDOR_REQUEST_EEPROM_ACCESS:
 238   2                      case ZSUSB20DDB_VENDOR_REQUEST_SRAM_ACCESS:
 239   2                      {
 240   3                              addr = SETUPDAT[2];             // Get address and length得到地址和长度
 241   3                              addr |= SETUPDAT[3] << 8;
C51 COMPILER V7.09   PERIPH                                                                04/03/2007 16:19:05 PAGE 5   

⌨️ 快捷键说明

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