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

📄 isr.lst

📁 200元买来的D12开发资料,包括上位机驱动和应用程序
💻 LST
字号:
C51 COMPILER V7.09   ISR                                                                   03/30/2005 12:31:37 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE ISR
OBJECT MODULE PLACED IN ISR.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ISR.C BROWSE DEBUG OBJECTEXTEND

line level    source

   1          //#include <reg51.h>                /* special function register declarations   */
   2          #include <stdio.h>
   3          #include <string.h>
   4          
   5          #include "hal.h"
   6          #include "d12ci.h"
   7          #include "main.h"
   8          #include "USB100.h"
   9          
  10          void ep0_txdone(void);
  11          void ep0_rxdone(void);
  12          void ep1_txdone(void);
  13          void ep1_rxdone(void);
  14          void main_txdone(void);
  15          void main_rxdone(void);
  16          
  17          
  18          /*
  19          //*************************************************************************
  20          //  Public static data
  21          //*************************************************************************
  22          */
  23          EPPFLAGS bEPPflags;
  24          
  25          /* Control endpoint TX/RX buffers */
  26          extern CONTROL_XFER ControlData;
  27          
  28          /* ISR static vars */
  29          unsigned char idata GenEpBuf[EP1_PACKET_SIZE];
  30          unsigned char idata EpBuf[EP2_PACKET_SIZE];
  31          IO_REQUEST idata ioRequest;
  32          unsigned char ioSize, ioCount;
  33          
  34          unsigned long ClockTicks = 0;
  35          
  36          //TO 中断
  37          timer_isr() interrupt 1
  38          {
  39   1              DISABLE;
  40   1              ClockTicks++;
  41   1              bEPPflags.bits.timer = 1;
  42   1              ENABLE;
  43   1      }
  44          //D12中断处理函数
  45          usb_isr() interrupt 0
  46          {
  47   1              unsigned char x;
  48   1              DISABLE;
  49   1              bEPPflags.bits.in_isr = 1;
  50   1              x = D12_ReadInterruptRegister();
  51   1              if(x != 0) {
  52   2                      if(x & 0x40)//总线复位 
  53   2                              bEPPflags.bits.bus_reset = 1;
  54   2                      if(x & D12_INT_SUSPENDCHANGE) //总线挂起
  55   2                              bEPPflags.bits.suspend = 1;
C51 COMPILER V7.09   ISR                                                                   03/30/2005 12:31:37 PAGE 2   

  56   2                      if(x & D12_INT_ENDP0IN)
  57   2                              ep0_txdone();
  58   2                      if(x & D12_INT_ENDP0OUT)
  59   2                              ep0_rxdone();
  60   2                      if(x & D12_INT_ENDP1IN)
  61   2                              ep1_txdone();
  62   2                      if(x & D12_INT_ENDP1OUT)
  63   2                              ep1_rxdone();
  64   2                      if(x & D12_INT_ENDP2IN)
  65   2                              main_txdone();
  66   2                      if(x & D12_INT_ENDP2OUT)
  67   2                              main_rxdone();
  68   2              }
  69   1              bEPPflags.bits.in_isr = 0;
  70   1              ENABLE;
  71   1      }
  72          //端点0接收中断,不用修改
  73          void ep0_rxdone(void)
  74          {
  75   1              unsigned char ep_last, i;
  76   1      
  77   1              ep_last = D12_ReadLastTransactionStatus(0); // Clear interrupt flag
  78   1              if (ep_last & D12_SETUPPACKET) {
  79   2      
  80   2                      ControlData.wLength = 0;
  81   2                      ControlData.wCount = 0;
  82   2              //判断端点是否满,如是,则取出
  83   2                      if( D12_ReadEndpoint(0, sizeof(ControlData.DeviceRequest),
  84   2                              (unsigned char *)(&(ControlData.DeviceRequest))) != sizeof(DEVICE_REQUEST) ) {
  85   3      
  86   3                              D12_SetEndpointStatus(0, 1);
  87   3                              D12_SetEndpointStatus(1, 1);
  88   3                              bEPPflags.bits.control_state = USB_IDLE;
  89   3      
  90   3                              return;
  91   3                      }
  92   2      
  93   2                      ControlData.DeviceRequest.wValue = SWAP(ControlData.DeviceRequest.wValue);
  94   2                      ControlData.DeviceRequest.wIndex = SWAP(ControlData.DeviceRequest.wIndex);
  95   2                      ControlData.DeviceRequest.wLength = SWAP(ControlData.DeviceRequest.wLength);
  96   2      
  97   2                      // Acknowledge setup here to unlock in/out endp
  98   2              //向控制输出端点发送应答建立命令以重新使能下一个建立阶段
  99   2                      D12_AcknowledgeEndpoint(0);
 100   2                      D12_AcknowledgeEndpoint(1);
 101   2      
 102   2                      ControlData.wLength = ControlData.DeviceRequest.wLength;
 103   2                      ControlData.wCount = 0;
 104   2              //需要证实控制传输是控制读还是写,如果是读:
 105   2              //如果控制传输是一个控制读类型那就是说器件需要在下一个数据阶段向
 106   2              //主机发回数据包.MCU需要设置一个标志以指示USB 设备现在正处于传输
 107   2              //模式即准备在主机发送请求时发送数据
 108   2      
 109   2                      if (ControlData.DeviceRequest.bmRequestType & (unsigned char)USB_ENDPOINT_DIRECTION_MASK) {
 110   3                              bEPPflags.bits.setup_packet = 1;
 111   3                              bEPPflags.bits.control_state = USB_IDLE;                /* get command */
 112   3                          }
 113   2              //如果是写
 114   2                      else {
 115   3                              if (ControlData.DeviceRequest.wLength == 0) {
 116   4                                      bEPPflags.bits.setup_packet = 1;
 117   4                                      bEPPflags.bits.control_state = USB_IDLE;                /* set command */
C51 COMPILER V7.09   ISR                                                                   03/30/2005 12:31:37 PAGE 3   

 118   4                                   }
 119   3                              else {
 120   4                                      if(ControlData.DeviceRequest.wLength > MAX_CONTROLDATA_SIZE) {
 121   5                                              bEPPflags.bits.control_state = USB_IDLE;
 122   5                                              D12_SetEndpointStatus(0, 1);
 123   5                                              D12_SetEndpointStatus(1, 1);
 124   5                                              }
 125   4                                      else {
 126   5                                              bEPPflags.bits.control_state = USB_RECEIVE;     /* set command with OUT token */
 127   5                                            }
 128   4                                   } // set command with data
 129   3                            } // else set command
 130   2                 } // if setup packet
 131   1      
 132   1              else if (bEPPflags.bits.control_state == USB_RECEIVE) {
 133   2                      i =     D12_ReadEndpoint(0, EP0_PACKET_SIZE,
 134   2                              ControlData.dataBuffer + ControlData.wCount);
 135   2      
 136   2                      ControlData.wCount += i;
 137   2                      if( i != EP0_PACKET_SIZE || ControlData.wCount >= ControlData.wLength) {
 138   3                              bEPPflags.bits.setup_packet = 1;
 139   3                              bEPPflags.bits.control_state = USB_IDLE;
 140   3                      }
 141   2              }
 142   1      
 143   1              else {
 144   2                      bEPPflags.bits.control_state = USB_IDLE;
 145   2              }
 146   1      
 147   1      }
 148          //端点0发送中断,不用修改
 149          void ep0_txdone(void)
 150          {
 151   1              short i = ControlData.wLength - ControlData.wCount;
 152   1      
 153   1              D12_ReadLastTransactionStatus(1); // Clear interrupt flag
 154   1      
 155   1              if (bEPPflags.bits.control_state != USB_TRANSMIT)
 156   1                      return;
 157   1              //-------------------------
 158   1              if( i >= EP0_PACKET_SIZE) {
 159   2                      D12_WriteEndpoint(1, EP0_PACKET_SIZE, ControlData.pData + ControlData.wCount);
 160   2                      ControlData.wCount += EP0_PACKET_SIZE;
 161   2      
 162   2                      bEPPflags.bits.control_state = USB_TRANSMIT;
 163   2              }
 164   1              else if( i != 0) {
 165   2                      D12_WriteEndpoint(1, i, ControlData.pData + ControlData.wCount);
 166   2                      ControlData.wCount += i;
 167   2      
 168   2                      bEPPflags.bits.control_state = USB_IDLE;
 169   2              }
 170   1              else if (i == 0){
 171   2                      D12_WriteEndpoint(1, 0, 0); // Send zero packet at the end ???
 172   2      
 173   2                      bEPPflags.bits.control_state = USB_IDLE;
 174   2              }
 175   1      
 176   1      }
 177          //端点1发送中断
 178          void ep1_txdone(void)
 179          {
C51 COMPILER V7.09   ISR                                                                   03/30/2005 12:31:37 PAGE 4   

 180   1              D12_ReadLastTransactionStatus(3); //清中断标志
 181   1      }
 182          //端点1接收中断
 183          void ep1_rxdone(void)
 184          {
 185   1              unsigned char len;
 186   1              D12_ReadLastTransactionStatus(2); //清中断标志
 187   1              len = D12_ReadEndpoint(2, sizeof(GenEpBuf), GenEpBuf);
 188   1              if(len != 0)
 189   1                      bEPPflags.bits.ep1_rxdone = 1;
 190   1      }
 191          //主端点EP2IN发送中断
 192          void main_txdone(void)
 193          {
 194   1              D12_ReadLastTransactionStatus(5); //清中断标志
 195   1      }
 196          //主端点EP2OUT收收中断
 197          void main_rxdone(void)
 198          {
 199   1              unsigned char len,epstatus;
 200   1      
 201   1              D12_ReadLastTransactionStatus(4); //清中断标志
 202   1              epstatus=D12_ReadEndpointStatus(4);
 203   1              epstatus&=0x60;
 204   1              len=D12_ReadEndpoint(4,64,EpBuf);
 205   1              if(epstatus==0x60)
 206   1              {
 207   2                  len=D12_ReadEndpoint(4,64,EpBuf);
 208   2              }
 209   1      }
 210          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    663    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      8       4
   IDATA SIZE       =     74    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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