protodma.lst

来自「pdiusbd12的一个固件程序」· LST 代码 · 共 138 行

LST
138
字号
C51 COMPILER V7.50   PROTODMA                                                              02/27/2006 15:58:43 PAGE 1   


C51 COMPILER V7.50, 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

line level    source

   1          #include <stdio.h>
   2          #include <string.h>
   3          
   4          #include <reg51.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          
  48          
  49          //厂商请求处理  protodma.h
  50          void read_write_register(void)
  51          {
  52   1              unsigned char i,len,epstatus;
  53   1      
  54   1              if(ControlData.DeviceRequest.bmRequestType & (unsigned char)USB_ENDPOINT_DIRECTION_MASK) {
  55   2      
C51 COMPILER V7.50   PROTODMA                                                              02/27/2006 15:58:43 PAGE 2   

  56   2                      if(bEPPflags.bits.verbose)
  57   2                              printf("Read Registers: Offset = 0x%x, Length = 0x%x, Index = 0x%x.\n",
  58   2                                      ControlData.DeviceRequest.wValue,
  59   2                                      ControlData.DeviceRequest.wLength,
  60   2                                      ControlData.DeviceRequest.wIndex);
  61   2      
  62   2                      if(ControlData.DeviceRequest.wIndex == GET_FIRMWARE_VERSION &&
  63   2                              ControlData.DeviceRequest.wValue == 0 &&
  64   2                              ControlData.DeviceRequest.wLength == 1)
  65   2                              get_firmware_version();//获取固件版本号
  66   2                      else
  67   2                      if(ControlData.DeviceRequest.wIndex == GET_BUFFER_SIZE &&
  68   2                              ControlData.DeviceRequest.wValue == 0 &&
  69   2                              ControlData.DeviceRequest.wLength == 4)
  70   2                              get_buffer_size();//获取缓冲区大小
  71   2                      else
  72   2                              stall_ep0();
  73   2      
  74   2              }       // if read register
  75   1              else{
  76   2                      if(bEPPflags.bits.verbose) {
  77   3      
  78   3                              printf("Write Registers: Offset = 0x%x, Length = 0x%x, Index = 0x%x.\n",
  79   3                                      ControlData.DeviceRequest.wValue,
  80   3                                      ControlData.DeviceRequest.wLength,
  81   3                                      ControlData.DeviceRequest.wIndex);
  82   3      
  83   3                              printf("Data: ");
  84   3                              for(i = 0; i < ControlData.DeviceRequest.wLength; i ++)
  85   3                                      printf("0x%bx, ", *((ControlData.dataBuffer)+i));
  86   3                              printf("\n");
  87   3                      }
  88   2      
  89   2                      if(ControlData.DeviceRequest.wIndex == SETUP_DMA_REQUEST &&
  90   2                              ControlData.DeviceRequest.wValue == 0 &&
  91   2                              ControlData.DeviceRequest.wLength == 6)
  92   2                              {
  93   3                                      if(ControlData.dataBuffer[5]==0x81)
  94   3                                      {
  95   4                                              D12_WriteEndpoint(5, ControlData.dataBuffer[3], EpBuf);//发送数据
  96   4                                      }
  97   3                                      if(ControlData.dataBuffer[5]==0x80)
  98   3                                      {
  99   4                                              epstatus=D12_ReadEndpointStatus(4);
 100   4                                              epstatus &= 0x60;
 101   4                                              if (epstatus == 0x60)
 102   4                                                      len = D12_ReadEndpoint(4, 64, EpBuf);//读取双缓冲区数据
 103   4                                      }
 104   3                                      single_transmit(0, 0);
 105   3                                      //setup_dma_request();//DMA设置处理,因为未使用DMA所以屏蔽掉
 106   3                              }                               
 107   2                      else
 108   2                              stall_ep0();
 109   2              }       // if write register
 110   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    349    ----
   CONSTANT SIZE    =    140    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
C51 COMPILER V7.50   PROTODMA                                                              02/27/2006 15:58:43 PAGE 3   

   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 + =
减小字号Ctrl + -
显示快捷键?