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

📄 d12ci.lst

📁 usblab usb程序开发实验 一个实例
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.01   D12CI                                                                 04/24/2006 19:23:08 PAGE 1   


C51 COMPILER V8.01, COMPILATION OF MODULE D12CI
OBJECT MODULE PLACED IN D12CI.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE D12CI.C BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*
   2             //************************************************************************* //
   3             //                  
   4             //
   5             //           COPYRIGHT (c)   2006 BY FOSHAN LX.
   6             //                     --  ALL RIGHTS RESERVED  --
   7             //
   8             // File Name:        D12CI.C
   9             // Author:           guobin
  10             // Created:          2006/04/20
  11             // Modified:
  12             // Revision:         2.0
  13             //
  14             //*************************************************************************
  15          */
  16            
  17          #include "hardware.h"
  18          
  19          #include "mainloop.h"
  20          #include "d12ci.h"
  21          
  22          extern EPPFLAGS bEPPflags;
  23          
  24          //---------------------------------
  25          #define D12Command()    (D12_A0=1)
  26          #define D12Data()               (D12_A0=0)
  27          #define D12En()                 (D12_CS=0)
  28          #define D12Dis()                        (D12_CS=1)
  29          
  30          #define D12OutPort(x)   {P2=x;CPU_WR=0;CPU_WR=1;}
  31          #define D12InPort(x)    {CPU_RD=0;x=P2;CPU_RD=1;}
  32          
  33          
  34          void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable)
  35          {
  36   1              if(bEPPflags.bits.in_isr == 0)
  37   1                      DISABLE;
  38   1      
  39   1              D12Command();
  40   1              D12En();
  41   1              D12OutPort(0xD0);
  42   1                                                      //outportb(D12_COMMAND, 0xD0);
  43   1              if(bEnable)
  44   1                      bAddress |= 0x80;
  45   1              D12Data();
  46   1              D12OutPort(bAddress);
  47   1                                                      //outportb(D12_DATA, bAddress);
  48   1              D12Dis()        ;
  49   1              if(bEPPflags.bits.in_isr == 0)
  50   1                      ENABLE;
  51   1      }
  52          
  53          void D12_SetEndpointEnable(unsigned char bEnable)
  54          {
  55   1              if(bEPPflags.bits.in_isr == 0)
C51 COMPILER V8.01   D12CI                                                                 04/24/2006 19:23:08 PAGE 2   

  56   1                      DISABLE;
  57   1      
  58   1              D12Command();
  59   1              D12En();
  60   1              D12OutPort(0xD8);
  61   1                                                      //outportb(D12_COMMAND, 0xD8);
  62   1              D12Data();
  63   1              
  64   1              if(bEnable)
  65   1                      //outportb(D12_DATA, 1);
  66   1                      {D12OutPort(1);}
  67   1              else
  68   1                      {D12OutPort(0);}
  69   1                      //outportb(D12_DATA, 0);
  70   1              D12Dis();
  71   1      
  72   1              if(bEPPflags.bits.in_isr == 0)
  73   1                      ENABLE;
  74   1      }
  75          
  76          void D12_SetMode(unsigned char bConfig, unsigned char bClkDiv)
  77          {
  78   1              if(bEPPflags.bits.in_isr == 0)
  79   1                      DISABLE;
  80   1      
  81   1              D12Command();
  82   1              D12En();
  83   1              D12OutPort(0xF3);
  84   1                      //outportb(D12_COMMAND, 0xF3);
  85   1              D12Data();
  86   1              D12OutPort(bConfig);
  87   1              D12OutPort(bClkDiv);
  88   1                      //outportb(D12_DATA, bConfig);
  89   1                      //outportb(D12_DATA, bClkDiv);
  90   1              D12Dis()        ;
  91   1                      
  92   1              if(bEPPflags.bits.in_isr == 0)
  93   1                      ENABLE;
  94   1      }
  95          
  96          void D12_SetDMA(unsigned char bMode)
  97          {
  98   1              if(bEPPflags.bits.in_isr == 0)
  99   1                      DISABLE;
 100   1              
 101   1              D12Command();
 102   1              D12En();
 103   1              D12OutPort(0xFB);
 104   1                      //outportb(D12_COMMAND, 0xFB);
 105   1              D12Data();
 106   1              D12OutPort(bMode);      
 107   1                      //outportb(D12_DATA, bMode);
 108   1              D12Dis()        ;
 109   1                      
 110   1              if(bEPPflags.bits.in_isr == 0)
 111   1                      ENABLE;
 112   1      }
 113          
 114          unsigned short D12_ReadInterruptRegister(void)
 115          {
 116   1              unsigned char b1;
 117   1              unsigned int j;
C51 COMPILER V8.01   D12CI                                                                 04/24/2006 19:23:08 PAGE 3   

 118   1      
 119   1              D12Command();
 120   1              D12En();
 121   1              D12OutPort(0xF4);
 122   1                      //outportb(D12_COMMAND, 0xF4);
 123   1              D12Data();
 124   1              P2=0xFF;
 125   1              D12InPort(b1);
 126   1              D12InPort(j);
 127   1                      //b1 = inportb(D12_DATA);
 128   1                      //j = inportb(D12_DATA);
 129   1              D12Dis()        ;
 130   1              j <<= 8;
 131   1              j += b1;
 132   1      
 133   1              return j;
 134   1      }
 135          
 136          unsigned char D12_SelectEndpoint(unsigned char bEndp)
 137          {
 138   1              unsigned char c;
 139   1      
 140   1              if(bEPPflags.bits.in_isr == 0)
 141   1                      DISABLE;
 142   1              
 143   1              D12Command();
 144   1              D12En();
 145   1              D12OutPort(bEndp);
 146   1                      //outportb(D12_COMMAND, bEndp);
 147   1              D12Data();
 148   1              P2=0xFF;
 149   1              D12InPort(c);
 150   1                      //c = inportb(D12_DATA);
 151   1              D12Dis()        ;
 152   1                      
 153   1              if(bEPPflags.bits.in_isr == 0)
 154   1                      ENABLE;
 155   1      
 156   1              return c;
 157   1      }
 158          
 159          unsigned char D12_ReadLastTransactionStatus(unsigned char bEndp)
 160          {
 161   1              unsigned char i;
 162   1      
 163   1              D12Command();
 164   1              D12En();
 165   1              D12OutPort(0x40 + bEndp);
 166   1                      //outportb(D12_COMMAND, 0x40 + bEndp);
 167   1              D12Data();
 168   1              P2=0xFF;
 169   1              D12InPort(i);
 170   1              D12Dis()        ;
 171   1              
 172   1              return i;
 173   1      }
 174          
 175          #if 0
              unsigned char D12_ReadEndpointStatus(unsigned char bEndp)
              {
                      unsigned char c;
              
C51 COMPILER V8.01   D12CI                                                                 04/24/2006 19:23:08 PAGE 4   

                      if(bEPPflags.bits.in_isr == 0)
                              DISABLE;
              
                      D12Command();
                      D12En();
                      D12OutPort(0x80 + bEndp);
                              //outportb(D12_COMMAND, 0x80 + bEndp);
                              
                              //c = inportb(D12_DATA);
                      D12Data();
                      P2=0xFF;
                      D12InPort(c);
                      D12Dis()        ;
              
                      if(bEPPflags.bits.in_isr == 0)
                              ENABLE;
              
                      return c;
              }
              #endif
 200          
 201          void D12_SetEndpointStatus(unsigned char bEndp, unsigned char bStalled)
 202          {
 203   1              if(bEPPflags.bits.in_isr == 0)
 204   1                      DISABLE;
 205   1      
 206   1              D12Command();
 207   1              D12En();
 208   1              D12OutPort(0x40 + bEndp);
 209   1                      //outportb(D12_COMMAND, 0x40 + bEndp);
 210   1      

⌨️ 快捷键说明

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