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

📄 xxgchap9.lst

📁 200元买来的D12开发资料,包括上位机驱动和应用程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V7.02b   XXGCHAP9                                                             03/17/2005 23:11:51 PAGE 1   


C51 COMPILER V7.02b, COMPILATION OF MODULE XXGCHAP9
OBJECT MODULE PLACED IN J:\D12\FW\XXGCHAP9.OBJ
COMPILER INVOKED BY: C:\keil\c51\bin\C51.EXE J:\D12\FW\XXGCHAP9.C DB SB OE

stmt level    source

   1          
   2          
   3          #include <stdio.h>
   4          #include <string.h>
   5          
   6          //#include <reg51.h>                /* special function register declarations   */
   7          
   8          #include "xxghal.h"
   9          #include "xxgd12ci.h"
  10          #include "xxgmain.h"
  11          #include "xxgusb100.h"
  12          #include "xxgchap9.h"
  13          
  14          //---------------------------
  15          extern void single_transmit(unsigned char * buf, unsigned char len);
  16          extern void code_transmit(unsigned char code * pRomData, unsigned short len);
  17          extern void stall_ep0(void);
  18          extern void init_unconfig(void);
  19          extern void init_config(void);
  20          
  21          #define NUM_ENDPOINTS   4
  22          
  23          #define CONFIG_DESCRIPTOR_LENGTH    sizeof(USB_CONFIGURATION_DESCRIPTOR) \
  24                                                                                  + sizeof(USB_INTERFACE_DESCRIPTOR) \
  25                                                                                  + (NUM_ENDPOINTS * sizeof(USB_ENDPOINT_DESCRIPTOR))
  26          
  27          extern CONTROL_XFER ControlData;
  28          extern IO_REQUEST idata ioRequest;
  29          extern EPPFLAGS bEPPflags;
  30          
  31          code USB_DEVICE_DESCRIPTOR DeviceDescr =
  32          {
  33                  sizeof(USB_DEVICE_DESCRIPTOR),
  34              USB_DEVICE_DESCRIPTOR_TYPE,
  35              SWAP(0x0100),
  36              USB_CLASS_CODE_TEST_CLASS_DEVICE,
  37              0, 
  38              0,
  39                  EP0_PACKET_SIZE,
  40                  SWAP(0x0471),   //VID
  41                  SWAP(0x0666),   //PID
  42                  SWAP(0x0100),
  43              0,                  //Manufactory
  44              0,                  //Product
  45              0,                  //Serial Number
  46              25                  //Number of possible configurations
  47          };
  48          
  49          code USB_CONFIGURATION_DESCRIPTOR ConfigDescr =
  50          {
  51              sizeof(USB_CONFIGURATION_DESCRIPTOR),
  52              USB_CONFIGURATION_DESCRIPTOR_TYPE,
  53              SWAP(CONFIG_DESCRIPTOR_LENGTH),
  54                  1,
  55                  1,
C51 COMPILER V7.02b   XXGCHAP9                                                             03/17/2005 23:11:51 PAGE 2   

  56              0,
  57                  0x60,
  58                  0xf0
  59                  //0x1
  60          };
  61          
  62          code USB_INTERFACE_DESCRIPTOR InterfaceDescr =
  63          {
  64              sizeof(USB_INTERFACE_DESCRIPTOR),
  65              USB_INTERFACE_DESCRIPTOR_TYPE,
  66              0,
  67              0,
  68                  NUM_ENDPOINTS,
  69                  USB_CLASS_CODE_TEST_CLASS_DEVICE,
  70                  USB_SUBCLASS_CODE_TEST_CLASS_D12,
  71                  USB_PROTOCOL_CODE_TEST_CLASS_D12,
  72                  0
  73          };
  74          
  75          code USB_ENDPOINT_DESCRIPTOR EP1_TXDescr =
  76          {
  77                  sizeof(USB_ENDPOINT_DESCRIPTOR),
  78                  USB_ENDPOINT_DESCRIPTOR_TYPE,
  79                  0x81,
  80                  USB_ENDPOINT_TYPE_INTERRUPT,
  81                  SWAP(EP1_PACKET_SIZE),
  82                  10
  83          };
  84          
  85          code USB_ENDPOINT_DESCRIPTOR EP1_RXDescr =
  86          {
  87                  sizeof(USB_ENDPOINT_DESCRIPTOR),
  88                  USB_ENDPOINT_DESCRIPTOR_TYPE,
  89                  0x1,
  90                  USB_ENDPOINT_TYPE_INTERRUPT,
  91                  SWAP(EP1_PACKET_SIZE),
  92                  10
  93          };
  94          
  95          code USB_ENDPOINT_DESCRIPTOR EP2_TXDescr =
  96          {
  97                  sizeof(USB_ENDPOINT_DESCRIPTOR),
  98                  USB_ENDPOINT_DESCRIPTOR_TYPE,
  99                  0x82,
 100                  USB_ENDPOINT_TYPE_BULK,
 101                  SWAP(EP2_PACKET_SIZE),
 102                  10
 103          };
 104          
 105          code USB_ENDPOINT_DESCRIPTOR EP2_RXDescr =
 106          {
 107                  sizeof(USB_ENDPOINT_DESCRIPTOR),
 108                  USB_ENDPOINT_DESCRIPTOR_TYPE,
 109                  0x2,
 110                  USB_ENDPOINT_TYPE_BULK,
 111                  SWAP(EP2_PACKET_SIZE),
 112                  10
 113          };
 114          
 115          /*
 116             //*************************************************************************
 117             // USB Protocol Layer
C51 COMPILER V7.02b   XXGCHAP9                                                             03/17/2005 23:11:51 PAGE 3   

 118             //*************************************************************************
 119          */
 120          
 121          void reserved(void)
 122          {
 123   1              stall_ep0();
 124   1      }
 125          
 126          /*
 127             //*************************************************************************
 128             // USB standard device requests
 129             //*************************************************************************
 130          */
 131          
 132          void get_status(void)
 133          {
 134   1              unsigned char endp, txdat[2];
 135   1              unsigned char bRecipient = ControlData.DeviceRequest.bmRequestType & USB_RECIPIENT;
 136   1              unsigned char c;
 137   1      
 138   1              if (bRecipient == USB_RECIPIENT_DEVICE) {
 139   2                      if(bEPPflags.bits.remote_wakeup == 1)
 140   2                              txdat[0] = 3;
 141   2                      else
 142   2                              txdat[0] = 1;
 143   2                      txdat[1]=0;
 144   2                      single_transmit(txdat, 2);
 145   2              } else if (bRecipient == USB_RECIPIENT_INTERFACE) {
 146   2                      txdat[0]=0;
 147   2                      txdat[1]=0;
 148   2                      single_transmit(txdat, 2);
 149   2              } else if (bRecipient == USB_RECIPIENT_ENDPOINT) {
 150   2                      endp = (unsigned char)(ControlData.DeviceRequest.wIndex & MAX_ENDPOINTS);
 151   2                      if (ControlData.DeviceRequest.wIndex & (unsigned char)USB_ENDPOINT_DIRECTION_MASK)
 152   2                              c = D12_SelectEndpoint(endp*2 + 1);     /* Control-in */
 153   2      
 154   2      
 155   2                      else
 156   2                              c = D12_SelectEndpoint(endp*2); /* Control-out */
 157   2                      if(c & D12_STALL)
 158   2                              txdat[0] = 1;
 159   2                      else
 160   2                              txdat[0] = 0;
 161   2                      txdat[1] = 0;
 162   2                      single_transmit(txdat, 2);
 163   2              } else
 164   1                      stall_ep0();
 165   1      }
 166          
 167          void clear_feature(void)
 168          {
 169   1              unsigned char endp;
 170   1              unsigned char bRecipient = ControlData.DeviceRequest.bmRequestType & USB_RECIPIENT;
 171   1      
 172   1              if (bRecipient == USB_RECIPIENT_DEVICE
 173   1                      && ControlData.DeviceRequest.wValue == USB_FEATURE_REMOTE_WAKEUP) {
 174   2                      DISABLE;
 175   2                      bEPPflags.bits.remote_wakeup = 0;
 176   2                      ENABLE;
 177   2                      single_transmit(0, 0);
 178   2              }
 179   1              else if (bRecipient == USB_RECIPIENT_ENDPOINT
C51 COMPILER V7.02b   XXGCHAP9                                                             03/17/2005 23:11:51 PAGE 4   

 180   1                      && ControlData.DeviceRequest.wValue == USB_FEATURE_ENDPOINT_STALL) {
 181   2                      endp = (unsigned char)(ControlData.DeviceRequest.wIndex & MAX_ENDPOINTS);

⌨️ 快捷键说明

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