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

📄 protodma.lst

📁 修改后的PDIUSBD12完整固件源码
💻 LST
字号:
C51 COMPILER V7.00  PROTODMA                                                               07/11/2005 17:15:00 PAGE 1   


C51 COMPILER V7.00, COMPILATION OF MODULE PROTODMA
OBJECT MODULE PLACED IN Protodma.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Protodma.c OPTIMIZE(2,SPEED) DEBUG OBJECTEXTEND

stmt level    source

   1          #include <stdio.h>
   2          #include <string.h>
   3          
   4          #include <reg552.h>                /* special function register declarations   */
   5          #include "epphal.h"
   6          
   7          #include "d12ci.h"
   8          #include "mainloop.h"
   9          #include "usb100.h"
  10          #include "chap_9.h"
  11          
  12          extern CONTROL_XFER ControlData;
  13          extern IO_REQUEST idata ioRequest;
  14          extern EPPFLAGS bEPPflags;
  15          extern BOOL bNoRAM;
  16          extern unsigned char idata EpBuf[EP2_PACKET_SIZE];
  17          
  18          //获取固件版本号
  19          void get_firmware_version()
  20          {
  21   1              unsigned char i;
  22   1      
  23   1              i = 0x30; // firmware version number
  24   1              single_transmit((unsigned char *)&i, 1);
  25   1      }
  26          
  27          //获取端点2缓存区大小
  28          void get_buffer_size()
  29          {
  30   1              unsigned char i[4];
  31   1      
  32   1              if(bNoRAM == TRUE) {
  33   2                      i[0] = EP2_PACKET_SIZE;
  34   2                      i[1] = 0;
  35   2                      i[2] = 0;
  36   2                      i[3] = 0;
  37   2              } else {
  38   2                      i[0] = 0;
  39   2                      i[1] = 1;
  40   2                      i[2] = 0;
  41   2                      i[3] = 0;
  42   2              }
  43   1              single_transmit((unsigned char *)&i, 4);
  44   1      }
  45          
  46          /*  //DMA请求响应子程序
  47          void setup_dma_request()
  48          {
  49                  memcpy((unsigned char *)&ioRequest + ControlData.DeviceRequest.wValue,
  50                          ControlData.dataBuffer,
  51                          ControlData.DeviceRequest.wLength);
  52          
  53                  ioRequest.uSize = SWAP(ioRequest.uSize);
  54                  ioRequest.uAddressL = SWAP(ioRequest.uAddressL);
  55          
C51 COMPILER V7.00  PROTODMA                                                               07/11/2005 17:15:00 PAGE 2   

  56                  if(ioRequest.uSize > DMA_BUFFER_SIZE) { // Unaccepted request
  57                          stall_ep0();//DMA设置出错
  58                  }
  59                  else if(bNoRAM == TRUE && ioRequest.uSize > EP2_PACKET_SIZE) {
  60                          stall_ep0();//DMA缓冲区出错
  61                  }
  62                  else {
  63                          if(bEPPflags.bits.dma_state == DMA_IDLE) {
  64                                  DISABLE;
  65                                  bEPPflags.bits.setup_dma ++;
  66                                  ENABLE;
  67                          }
  68                          else {
  69                                  DISABLE;
  70                                  bEPPflags.bits.dma_state = DMA_PENDING;
  71                                  ENABLE;
  72                          }
  73          
  74                  } // else if accepted request
  75          }
  76          */
  77          
  78          //厂商请求处理
  79          void read_write_register(void)
  80          {
  81   1              unsigned char i,len,epstatus;
  82   1      
  83   1              if(ControlData.DeviceRequest.bmRequestType & (unsigned char)USB_ENDPOINT_DIRECTION_MASK) {
  84   2      
  85   2                      if(bEPPflags.bits.verbose)
  86   2                              printf("Read Registers: Offset = 0x%x, Length = 0x%x, Index = 0x%x.\n",
  87   2                                      ControlData.DeviceRequest.wValue,
  88   2                                      ControlData.DeviceRequest.wLength,
  89   2                                      ControlData.DeviceRequest.wIndex);
  90   2      
  91   2                      if(ControlData.DeviceRequest.wIndex == GET_FIRMWARE_VERSION &&
  92   2                              ControlData.DeviceRequest.wValue == 0 &&
  93   2                              ControlData.DeviceRequest.wLength == 1)
  94   2                              get_firmware_version();//获取固件版本号
  95   2                      else
  96   2                      if(ControlData.DeviceRequest.wIndex == GET_BUFFER_SIZE &&
  97   2                              ControlData.DeviceRequest.wValue == 0 &&
  98   2                              ControlData.DeviceRequest.wLength == 4)
  99   2                              get_buffer_size();//获取缓冲区大小
 100   2                      else
 101   2                              stall_ep0();
 102   2      
 103   2              }       // if read register
 104   1              else{
 105   2                      if(bEPPflags.bits.verbose) {
 106   3      
 107   3                              printf("Write Registers: Offset = 0x%x, Length = 0x%x, Index = 0x%x.\n",
 108   3                                      ControlData.DeviceRequest.wValue,
 109   3                                      ControlData.DeviceRequest.wLength,
 110   3                                      ControlData.DeviceRequest.wIndex);
 111   3      
 112   3                              printf("Data: ");
 113   3                              for(i = 0; i < ControlData.DeviceRequest.wLength; i ++)
 114   3                                      printf("0x%bx, ", *((ControlData.dataBuffer)+i));
 115   3                              printf("\n");
 116   3                      }
 117   2      
C51 COMPILER V7.00  PROTODMA                                                               07/11/2005 17:15:00 PAGE 3   

 118   2                      if(ControlData.DeviceRequest.wIndex == SETUP_DMA_REQUEST &&
 119   2                              ControlData.DeviceRequest.wValue == 0 &&
 120   2                              ControlData.DeviceRequest.wLength == 6)
 121   2                              {
 122   3                                      if(ControlData.dataBuffer[5]==0x81)
 123   3                                      {
 124   4                                              D12_WriteEndpoint(5, ControlData.dataBuffer[3], EpBuf);//发送数据
 125   4                                      }
 126   3                                      if(ControlData.dataBuffer[5]==0x80)
 127   3                                      {
 128   4                                              epstatus=D12_ReadEndpointStatus(4);
 129   4                                              epstatus &= 0x60;
 130   4                                              if (epstatus == 0x60)
 131   4                                                      len = D12_ReadEndpoint(4, 64, EpBuf);//读取双缓冲区数据
 132   4                                      }
 133   3                                      single_transmit(0, 0);
 134   3                                      //setup_dma_request();//DMA设置处理,因为未使用DMA所以屏蔽掉
 135   3                              }                               
 136   2                      else
 137   2                              stall_ep0();
 138   2              }       // if write register
 139   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    349    ----
   CONSTANT SIZE    =    140    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       8
   IDATA SIZE       =   ----    ----
   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 + -