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

📄 protodma.lst

📁 本源码实现了51单片机与飞利浦公司的D12USB接口芯片的固件编程.
💻 LST
字号:
C51 COMPILER V7.06   PROTODMA                                                              04/14/2004 12:09:04 PAGE 1   


C51 COMPILER V7.06, 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 <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          void setup_dma_request()
  48          {
  49   1              memcpy((unsigned char *)&ioRequest + ControlData.DeviceRequest.wValue,
  50   1                      ControlData.dataBuffer,
  51   1                      ControlData.DeviceRequest.wLength);
  52   1      
  53   1              ioRequest.uSize = SWAP(ioRequest.uSize);
  54   1              ioRequest.uAddressL = SWAP(ioRequest.uAddressL);
  55   1      
C51 COMPILER V7.06   PROTODMA                                                              04/14/2004 12:09:04 PAGE 2   

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

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


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    590    ----
   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 + -