chap_9.LST
上传用户:ids068
上传日期:2013-04-04
资源大小:639k
文件大小:77k
源码类别:

USB编程

开发平台:

C/C++

  1. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 1   
  2. C51 COMPILER V7.06, COMPILATION OF MODULE CHAP_9
  3. OBJECT MODULE PLACED IN chap_9.OBJ
  4. COMPILER INVOKED BY: C:KEILC51BINC51.EXE chap_9.c OPTIMIZE(2,SPEED) BROWSE DEBUG OBJECTEXTEND
  5. stmt level    source
  6.    1          //***********************************************************************
  7.    2          //                                                                                                                                                        *
  8.    3          //                P H I L I P S   P R O P R I E T A R Y                            *
  9.    4          //                                                                      *
  10.    5          //          COPYRIGHT (c)   1999 BY PHILIPS SINGAPORE (APIC).                      *
  11.    6          //                    --  ALL RIGHTS RESERVED  --                               *       
  12.    7          //                                                                      *
  13.    8          //      File Name       :       USBDebug.c                                    *
  14.    9          //      Author          :       Albert Goh                                                                                    *
  15.   10          //      Created         :       3 March 2000                                    *
  16.   11          //                                                                         *
  17.   12          //***********************************************************************
  18.   13          //***********************************************************************
  19.   14          //                                                                      *
  20.   15          // USBDebug has the ability to test the USB core in Bus enumeration or  *
  21.   16          // in CBI/bulk mode.                                                    *
  22.   17          //                                                                      *
  23.   18          //***********************************************************************
  24.   19          //***********************************************************************
  25.   20          //                                                                      *
  26.   21          //  Module History                                                                                                                          *
  27.   22          //  **************                                                                                                                          *
  28.   23          //                                                                                                                                                                *
  29.   24          //  Date        Version                 Author                          Changes                                       *
  30.   25          //  ====           =======                      ======                          =======                                       *
  31.   26          //  030300        0.1                   Albert                          Created                                       *
  32.   27          //                                                                      *
  33.   28          //***********************************************************************
  34.   29          
  35.   30          //***********************************************************************
  36.   31          //*                                                                                                                                                            *
  37.   32          //*                          Include Files Definition                                              *
  38.   33          //*                                                                                                                                                            *
  39.   34          //***********************************************************************
  40.   35          
  41.   36          #include "standard.h"
  42.   37          #include "Kernel.h"
  43.   38          #include "D14.h"
  44.   39          #include "usb.h"
  45.   40          #include "viic_c51.h"
  46.   41          
  47.   42          extern  D14_CNTRL_REG volatile xdata  D14_Cntrl_Reg;
  48.   43          extern void Init_D14(void);
  49.   44          extern UC code Standard_Device_Descriptor[];
  50.   45          extern UC code Bulk_Interface_Descriptor[];
  51.   46          extern UC code Iso_Interface_Descriptor[];
  52.   47          extern UC code Standard_Config_Descriptor[];
  53.   48          extern UC code Standard_Manufacturer_String[];
  54.   49          extern UC code Standard_Product_String[];
  55.   50          extern UC code Standard_String_ID[];
  56.   51          extern UC code Bulk_In_Descriptor[];
  57.   52          extern UC code Bulk_Out_Descriptor[];
  58.   53          extern UC code Int_In_Descriptor[];
  59.   54          extern UC code Int_Out_Descriptor[];
  60.   55          extern UC code Iso_In_Descriptor[];
  61. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 2   
  62.   56          extern UC code Iso_Out_Descriptor[];
  63.   57          extern UC code Iso_In_Zero_Descriptor[];
  64.   58          extern UC code Iso_Out_Zero_Descriptor[];
  65.   59          extern UC code HS_Device_Descriptor[];
  66.   60          extern UC code HS_Device_Qualifier[];
  67.   61          extern UC code HS_Bulk_Interface_Descriptor[];
  68.   62          extern UC code HS_Bulk_In_Descriptor[];
  69.   63          extern UC code HS_Bulk_Out_Descriptor[];
  70.   64          extern UC code HS_Int_In_Descriptor[];
  71.   65          extern UC code HS_Int_Out_Descriptor[];
  72.   66          extern UC code Other_Speed_Config_Descriptor[];
  73.   67          extern UI count;
  74.   68          extern void Start_mSEC_Timer(Data);
  75.   69          extern void Start_SEC_Timer(Data);
  76.   70          extern void Check_Busy(void);
  77.   71          extern void TaskFile_Update(void);
  78.   72          extern UI Temp;
  79.   73          extern UC Device_Config_Value;
  80.   74          extern KERNEL Kernel_Flag;
  81.   75          extern DMA_INT_FLAG DMA_Int_Flag;
  82.   76          extern USB_INT_FLAG USB_Int_Flag;
  83.   77          extern USBCBW USB_CBW;
  84.   78          extern void Init_Device(void);
  85.   79          extern UC code Test_Packet[];
  86.   80          extern void Init_Endpoint(void);
  87.   81          extern void Init_Device(void);
  88.   82          extern void Set_USB(void);
  89.   83          extern void ZLG7290_SendBuf(unsigned char * disp_buf,unsigned char num);
  90.   84          
  91.   85          //***********************************************************************
  92.   86          //*                                                                                                                                                            *
  93.   87          //*                      Prototype Routine Definition                                              *
  94.   88          //*                                                                                                                                                            *
  95.   89          //***********************************************************************
  96.   90          unsigned int read_endpoint(unsigned char endp,unsigned int len,unsigned char *buf);
  97.   91          void USB_Setup(void);
  98.   92          void reserved(void);
  99.   93          void Send_Device_Status(void);
  100.   94          void Send_Interface_Status(void);
  101.   95          void Send_Endpoint_Status(void);
  102.   96          
  103.   97          void Vendor_Specific_Command(void);
  104.   98          void Send_Status(unsigned char tran_status);
  105.   99          
  106.  100          void Set_Interface_Value(void);
  107.  101          void Get_Interface_Value(void);
  108.  102          void Process_Synch_Frame(void);
  109.  103          
  110.  104          void get_status(void);
  111.  105          void clear_feature(void);
  112.  106          void set_feature(void);
  113.  107          void set_address(void);
  114.  108          void get_descriptor(void);
  115.  109          void get_config(void);
  116.  110          void set_config(void);
  117.  111          void get_interface(void);
  118.  112          void set_interface(void);
  119.  113          
  120.  114          void Set_Descriptor(void);
  121.  115          void reserved(void);
  122.  116          
  123.  117          void ep0in_ack(void);
  124. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 3   
  125.  118          void ep0out_ack(void);
  126.  119          void wait_ep0tx(void);
  127.  120          void wait_ep0rx(void);
  128.  121          
  129.  122          //***********************************************************************
  130.  123          //*                                                                                                                                                            *
  131.  124          //*                          Variable Definition                                                              *
  132.  125          //*                                                                                                                                                            *
  133.  126          //***********************************************************************
  134.  127          
  135.  128          USB_INT_FLAG  USB_Int_Flag;
  136.  129          USB_DEVICE_REQ  idata   USB_Device_Request;
  137.  130          USB_DEVICE              USB_Device;
  138.  131          
  139.  132          UC code disp_buf0[8]={0,0,0,0,0,0,0,0};         //LED初始化值
  140.  133          UC code disp_buf1[8]={1,1,1,1,1,1,1,1};         //LED初始化值
  141.  134          
  142.  135          UC      code    *Descriptor_Ptr;
  143.  136          
  144.  137          UC      idata Endpt_FIFO[MAX_BUF];
  145.  138          UI      FIFO_Count;
  146.  139          UC VID[2],PID[2];
  147.  140          FILESIZE FileSize;
  148.  141          UI PIO_Count;
  149.  142          UC      File_Number;
  150.  143          UC      Current_File,bytecouter;
  151.  144          ULI bytecount;
  152.  145          
  153.  146          //USB标准请求
  154.  147          code void (*StandardDeviceRequest[])(void) =
  155.  148          {
  156.  149                  get_status,
  157.  150                  clear_feature,
  158.  151                  reserved,
  159.  152                  set_feature,
  160.  153                  reserved,
  161.  154                  set_address,
  162.  155                  get_descriptor,
  163.  156                  reserved,
  164.  157                  get_config,
  165.  158                  set_config,
  166.  159                  get_interface,
  167.  160                  set_interface,
  168.  161                  reserved,
  169.  162                  reserved,
  170.  163                  reserved,
  171.  164                  reserved
  172.  165          };
  173.  166          
  174.  167          
  175.  168          
  176.  169          //***********************************************************************
  177.  170          //*                                                                                                                                                            *
  178.  171          //*                          Routine Definition                                                            *
  179.  172          //*                                                                                                                                                            *
  180.  173          //***********************************************************************
  181.  174          
  182.  175          //***********************************************************************
  183.  176          //*                                                                                                                                                    *
  184.  177          //*     Routine         :  USB Debug Mode                                                  *
  185.  178          //*     Input           :  USB Interrupt Register                                                                        *
  186.  179          //*     Output  :  None                                                                    *
  187. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 4   
  188.  180          //*     Function        :  Branch to respective ISR                                        *
  189.  181          //*                                                                                                                                                            *
  190.  182          //***********************************************************************
  191.  183          
  192.  184          void USB_Debug_Mode(void)
  193.  185          {
  194.  186   1              //端点0接收到setup包处理      
  195.  187   1              if(USB_Int_Flag.BITS.EP0SETUP)
  196.  188   1              {
  197.  189   2                      EA_DISABLE;
  198.  190   2                      USB_Setup();
  199.  191   2                      EA_ENABLE;
  200.  192   2              }
  201.  193   1              
  202.  194   1              //挂起处理
  203.  195   1              if(USB_Int_Flag.BITS.SUSP)
  204.  196   1              {               
  205.  197   2                      //清除挂起标志
  206.  198   2                      EA_DISABLE;
  207.  199   2                      USB_Int_Flag.BITS.SUSP = 0;
  208.  200   2                      EA_ENABLE;
  209.  201   2                      //ISP1581进入挂起状态           
  210.  202   2                      D14_Cntrl_Reg.D14_MODE.BITS.GOSUSP = 1;
  211.  203   2                      D14_Cntrl_Reg.D14_MODE.BITS.GOSUSP = 0;
  212.  204   2              }
  213.  205   1              
  214.  206   1              //挂起恢复处理
  215.  207   1              if(USB_Int_Flag.BITS.RESUME)
  216.  208   1              {
  217.  209   2                      //清除恢复标志
  218.  210   2                      EA_DISABLE;
  219.  211   2                      USB_Int_Flag.BITS.RESUME = 0;         
  220.  212   2                      EA_ENABLE;
  221.  213   2                      //产生一个恢复信号
  222.  214   2                      D14_Cntrl_Reg.D14_MODE.BITS.SNDRSU = 1;
  223.  215   2                      D14_Cntrl_Reg.D14_MODE.BITS.SNDRSU = 0;
  224.  216   2              }
  225.  217   1              
  226.  218   1              //高速状态
  227.  219   1              if(USB_Int_Flag.BITS.HS_STAT)
  228.  220   1              {
  229.  221   2                      //清除高速状态标志
  230.  222   2                      EA_DISABLE;
  231.  223   2                      USB_Int_Flag.BITS.HS_STAT = 0;
  232.  224   2                      EA_ENABLE;
  233.  225   2                      if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
  234.  226   2                      {
  235.  227   3                              //切换高速指示
  236.  228   3                              HS_FS_LED = HIGH_SPEED_LED;
  237.  229   3                              //设置高速模式状态
  238.  230   3                              Kernel_Flag.BITS.HS_FS_State = HIGH_SPEED;
  239.  231   3                              //重新配置高速端点
  240.  232   3                              Init_Endpoint();
  241.  233   3      
  242.  234   3      //                      PIO_Count = 64;
  243.  235   3                              PIO_Count = 512;
  244.  236   3                      }
  245.  237   2              }
  246.  238   1      }
  247.  239          
  248.  240          
  249.  241          //***********************************************************************
  250. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 5   
  251.  242          //*                                                                                                                                     *
  252.  243          //*     Routine         :                                                               *
  253.  244          //*     Input           : None                                                                                  *
  254.  245          //*     Output          : None                                                                  *
  255.  246          //*     Function        :                                                               *
  256.  247          //*                                                                                                                                             *
  257.  248          //***********************************************************************
  258.  249          //建立包处理
  259.  250          void USB_Setup(void)
  260.  251          {
  261.  252   1              unsigned char type, req;
  262.  253   1      
  263.  254   1              //清除EP0SETUP中断标志
  264.  255   1              USB_Int_Flag.BITS.EP0SETUP = 0;   
  265.  256   1              //清除总线复位标志
  266.  257   1              Kernel_Flag.BITS.Bus_Reset = 0;
  267.  258   1              //选择端点0SETUP缓冲区
  268.  259   1              D14_Cntrl_Reg.D14_ENDPT_INDEX = 0x20;
  269.  260   1              
  270.  261   1              //读取USB请求
  271.  262   1              //读取请求类型
  272.  263   1              USB_Device_Request.bmRequestType =  D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  273.  264   1              //读取请求号
  274.  265   1              USB_Device_Request.bRequest = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  275.  266   1              //读取16bit请求数据
  276.  267   1              USB_Device_Request.wValue = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  277.  268   1              USB_Device_Request.wValue <<= 8;
  278.  269   1              USB_Device_Request.wValue |= D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  279.  270   1              //读取16bit请求索引
  280.  271   1              USB_Device_Request.wIndex = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  281.  272   1              USB_Device_Request.wIndex <<= 8;
  282.  273   1              USB_Device_Request.wIndex |= D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  283.  274   1              //读取16bit长度
  284.  275   1              USB_Device_Request.wLength = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  285.  276   1              USB_Device_Request.wLength <<= 8;
  286.  277   1              USB_Device_Request.wLength |= D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  287.  278   1              
  288.  279   1              //长度处理(高低8位对调)
  289.  280   1              Temp = USB_Device_Request.wLength;
  290.  281   1              USB_Device_Request.wLength = 0;
  291.  282   1              USB_Device_Request.wLength = (UC) Temp;
  292.  283   1              USB_Device_Request.wLength <<= 8;
  293.  284   1              Temp >>= 8;
  294.  285   1              USB_Device_Request.wLength |= Temp;
  295.  286   1              
  296.  287   1              type = USB_Device_Request.bmRequestType & 0x60;
  297.  288   1              req = USB_Device_Request.bRequest & 0x0f;
  298.  289   1      
  299.  290   1              //厂商请求
  300.  291   1              if (type == 0x40)
  301.  292   1              {
  302.  293   2                      Vendor_Specific_Command();//厂商请求处理
  303.  294   2              }
  304.  295   1              else if (type == 0x00)
  305.  296   1                      (*StandardDeviceRequest[req])();//调用标准请求
  306.  297   1      }
  307.  298          
  308.  299          //***********************************************************************
  309.  300          //*                                                                                                                                     *
  310.  301          //*     Routine         :                                                               *
  311.  302          //*     Input           : None                                                                                  *
  312.  303          //*     Output          : None                                                                  *
  313. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 6   
  314.  304          //*     Function        :                                                               *
  315.  305          //*                                                                                                                                             *
  316.  306          //***********************************************************************
  317.  307          //厂商请求处理
  318.  308          void Vendor_Specific_Command(void)
  319.  309          {
  320.  310   1              if(USB_Device_Request.bRequest == 0x0C)
  321.  311   1              {
  322.  312   2                      switch (USB_Device_Request.wIndex)
  323.  313   2                      {
  324.  314   3                      case GET_FIRMWARE_VERSION  ://获取固件版本
  325.  315   3                              if(USB_Device_Request.wLength == 1)
  326.  316   3                              {
  327.  317   4                                      //select endpoint
  328.  318   4                                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  329.  319   4                                      //set the data length to 1 byte
  330.  320   4                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 1;
  331.  321   4                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
  332.  322   4                                      //sent 0x21 as data
  333.  323   4                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = 0x22;//版本号
  334.  324   4                                      wait_ep0tx();
  335.  325   4                                      ep0out_ack();
  336.  326   4      //                              ep0in_ack();
  337.  327   4                                      break;
  338.  328   4                              }
  339.  329   3                              
  340.  330   3                      case SETUP_DMA_REQUEST :
  341.  331   3                              //Out Token Ack detected
  342.  332   3                              wait_ep0rx();
  343.  333   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
  344.  334   3                              //
  345.  335   3                              FileSize.Size.Address[0] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  346.  336   3                              FileSize.Size.Address[1] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  347.  337   3                              FileSize.Size.Address[2] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  348.  338   3                              //读取传输字节数
  349.  339   3                              Temp = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  350.  340   3                              bytecount = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  351.  341   3                              bytecount <<= 8;
  352.  342   3                              bytecount |= Temp;
  353.  343   3                              //读取传输方式
  354.  344   3                              FileSize.Size.DIR = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  355.  345   3                              ep0in_ack();
  356.  346   3                              Kernel_Flag.BITS.Transfer_Start = 1;//标志传输数据开始
  357.  347   3                              break;
  358.  348   3                      
  359.  349   3                      case GET_SET_EEPROM_REQUEST  ://对EEPROM操作的请求
  360.  350   3                              //Out Token Ack detected
  361.  351   3                              wait_ep0rx();
  362.  352   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
  363.  353   3                              //
  364.  354   3                              FileSize.Size.Address[0] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  365.  355   3                              FileSize.Size.Address[1] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  366.  356   3                              FileSize.Size.Address[2] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  367.  357   3                              //读取传输字节数
  368.  358   3                              Temp = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  369.  359   3                              bytecount = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  370.  360   3                              bytecount <<= 8;
  371.  361   3                              bytecount |= Temp;
  372.  362   3                              bytecouter=(UC)bytecount;
  373.  363   3                              //读取传输方式
  374.  364   3                              FileSize.Size.DIR = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
  375.  365   3                              ep0in_ack();
  376. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 7   
  377.  366   3                              Kernel_Flag.BITS.Transfer_Start = 1;//标志传输数据开始
  378.  367   3                              break;
  379.  368   3                      default :
  380.  369   3                              if(USB_Device_Request.bmRequestType == 0xC0)
  381.  370   3                              {
  382.  371   4                                      ep0in_ack();
  383.  372   4                                      break;                          
  384.  373   4                              }
  385.  374   3                              if(USB_Device_Request.bmRequestType == 0x40)
  386.  375   3                              {       
  387.  376   4                                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
  388.  377   4                                      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
  389.  378   4                                      while(!USB_Int_Flag.BITS.EP0SETUP)
  390.  379   4                                      {
  391.  380   5                                              //读取ISP1581中断寄存器
  392.  381   5                                              USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
  393.  382   5                                              //回写ISP1581中断寄存器
  394.  383   5                                              D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
  395.  384   5                                              if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
  396.  385   5                                                      return;
  397.  386   5                                      }
  398.  387   4                                      USB_Int_Flag.BITS.EP0TX = 0;
  399.  388   4                                      break;                          
  400.  389   4                              }
  401.  390   3                      }
  402.  391   2              }
  403.  392   1      }
  404.  393          
  405.  394          //***********************************************************************
  406.  395          //*                                                                                                                                     *
  407.  396          //*     Routine         :                                                               *
  408.  397          //*     Input           : None                                                                                  *
  409.  398          //*     Output          : None                                                                  *
  410.  399          //*     Function        :                                                               *
  411.  400          //*                                                                                                                                             *
  412.  401          //***********************************************************************
  413.  402          
  414.  403          void    reserved(void)
  415.  404          {
  416.  405   1      }
  417.  406          
  418.  407          
  419.  408          //Get_Descriptor()获取描述符
  420.  409          void get_descriptor(void)
  421.  410          {
  422.  411   1      
  423.  412   1              switch(USB_Device_Request.wValue)
  424.  413   1              {
  425.  414   2              case  1://设备描述符
  426.  415   2                      //选择描述符
  427.  416   2                      if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
  428.  417   2                              Descriptor_Ptr = &Standard_Device_Descriptor[0];        //set pointer to device descriptor
  429.  418   2                      if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
  430.  419   2                              Descriptor_Ptr = &HS_Device_Descriptor[0];      //set pointer to device descriptor
  431.  420   2                      count = *Descriptor_Ptr;                                                        //read in descriptor length
  432.  421   2                      //选择端点号
  433.  422   2                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  434.  423   2                      //写下发送字节数
  435.  424   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 0x12;
  436.  425   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
  437.  426   2                      //send descriptor
  438.  427   2                      //发送描述符
  439. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 8   
  440.  428   2                      while(count != 0)
  441.  429   2                      {
  442.  430   3                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  443.  431   3                              count--;
  444.  432   3                              Descriptor_Ptr++;
  445.  433   3                      }
  446.  434   2                      wait_ep0tx();
  447.  435   2                      ep0out_ack();
  448.  436   2                      break;
  449.  437   2                      
  450.  438   2              case  2        :  //获取配置描述符
  451.  439   2                      USB_Int_Flag.BITS.EP0RX = 0;
  452.  440   2                      Temp = 64;
  453.  441   2                      Descriptor_Ptr = &Standard_Config_Descriptor[0];        //set pointer to configuration descriptor
  454.  442   2                      count = *Descriptor_Ptr;                                                        //get configuration Descriptor length
  455.  443   2                      //选择端点号1
  456.  444   2                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  457.  445   2                      //check if only configuration descriptor required
  458.  446   2                      //检查描述符长度,决定是只发送配置描述符还是描述符集合
  459.  447   2                      if(count >= USB_Device_Request.wLength)                         //Send only Configuration descriptor
  460.  448   2                      {
  461.  449   3                              //写入发送字节数
  462.  450   3                              D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) USB_Device_Request.wLength;
  463.  451   3                              D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (USB_Device_Request.wLength >> 8);
  464.  452   3                              //send descriptor
  465.  453   3                              //发送描述符
  466.  454   3                              for(count = 0 ; count < USB_Device_Request.wLength ; count++)
  467.  455   3                              {
  468.  456   4                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  469.  457   4                                      Descriptor_Ptr++;
  470.  458   4                              }
  471.  459   3                              wait_ep0tx();
  472.  460   3                              ep0out_ack();
  473.  461   3                      }
  474.  462   2                      else //send Configuration,Interface and Endpoint descriptor
  475.  463   2                      {
  476.  464   3                              //发送描述符集合(配置+接口+端点)
  477.  465   3                              if(USB_Device_Request.wLength >= 32)
  478.  466   3                              {
  479.  467   4                                      //写入配置描述符
  480.  468   4                                      while(count != 0)
  481.  469   4                                      {
  482.  470   5                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  483.  471   5                                              count--;
  484.  472   5                                              Descriptor_Ptr++;
  485.  473   5                                      }
  486.  474   4                                      //选择高速还是全速接口描述符
  487.  475   4                                      if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
  488.  476   4                                              Descriptor_Ptr = &Bulk_Interface_Descriptor[0]; //set pointer to interface descriptor
  489.  477   4                                      if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
  490.  478   4                                              Descriptor_Ptr = &HS_Bulk_Interface_Descriptor[0]; //set pointer to interface descriptor
  491.  479   4                                      count = *Descriptor_Ptr;        //get the descriptor count
  492.  480   4                                      //写入接口描述符
  493.  481   4                                      while(count != 0)
  494.  482   4                                      {
  495.  483   5                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  496.  484   5                                              count--;
  497.  485   5                                              Descriptor_Ptr++;
  498.  486   5                                      }
  499.  487   4                                      //选择高速还是全速端点1IN描述符
  500.  488   4                                      if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
  501.  489   4                                              Descriptor_Ptr = &Int_In_Descriptor[0]; //set pointer to interface descriptor
  502. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 9   
  503.  490   4                                      if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
  504.  491   4                                              Descriptor_Ptr = &HS_Int_In_Descriptor[0]; //set pointer to interface descriptor
  505.  492   4                                      count = *Descriptor_Ptr;        //read in descriptor length
  506.  493   4                                      //写入端点1IN描述符
  507.  494   4                                      while(count != 0)
  508.  495   4                                      {
  509.  496   5                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  510.  497   5                                              count--;
  511.  498   5                                              Descriptor_Ptr++;
  512.  499   5                                      }
  513.  500   4                                      //选择高速还是全速端点1OUT描述符
  514.  501   4                                      if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
  515.  502   4                                              Descriptor_Ptr = &Int_Out_Descriptor[0]; //set pointer to interface descriptor
  516.  503   4                                      if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
  517.  504   4                                              Descriptor_Ptr = &HS_Int_Out_Descriptor[0]; //set pointer to interface descriptor
  518.  505   4                                      count = *Descriptor_Ptr;        //read in descriptor length
  519.  506   4                                      //写入端点1OUT描述符
  520.  507   4                                      while(count != 0)
  521.  508   4                                      {
  522.  509   5                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  523.  510   5                                              count--;
  524.  511   5                                              Descriptor_Ptr++;
  525.  512   5                                      }
  526.  513   4                                      //选择高速还是全速端点2IN描述符
  527.  514   4                                      if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
  528.  515   4                                              Descriptor_Ptr = &Bulk_In_Descriptor[0]; //set pointer to interface descriptor
  529.  516   4                                      if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
  530.  517   4                                              Descriptor_Ptr = &HS_Bulk_In_Descriptor[0]; //set pointer to interface descriptor
  531.  518   4                                      count = *Descriptor_Ptr;        //read in descriptor length
  532.  519   4                                      //写入端点2IN描述符
  533.  520   4                                      while(count != 0)
  534.  521   4                                      {
  535.  522   5                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  536.  523   5                                              count--;
  537.  524   5                                              Descriptor_Ptr++;
  538.  525   5                                      }
  539.  526   4                                      //选择高速还是全速端点2OUT描述符
  540.  527   4                                      if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
  541.  528   4                                              Descriptor_Ptr = &Bulk_Out_Descriptor[0]; //set pointer to interface descriptor
  542.  529   4                                      if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
  543.  530   4                                              Descriptor_Ptr = &HS_Bulk_Out_Descriptor[0]; //set pointer to interface descriptor
  544.  531   4                                      count = *Descriptor_Ptr;        //read in descriptor length
  545.  532   4                                      //写入端点2OUT描述符
  546.  533   4                                      while(count != 0)
  547.  534   4                                      {
  548.  535   5                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  549.  536   5                                              count--;
  550.  537   5                                              Descriptor_Ptr++;
  551.  538   5                                      }
  552.  539   4                              }
  553.  540   3                              //使端点有效
  554.  541   3                              D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.VENDP = 1;      //validate FIFO
  555.  542   3                              wait_ep0tx();
  556.  543   3                              ep0out_ack();
  557.  544   3                      }
  558.  545   2                      break;
  559.  546   2                      
  560.  547   2                      case  3:  //获取字符串描述符
  561.  548   2                              Descriptor_Ptr = &Standard_String_ID[0];                //set pointer to interface descriptor
  562.  549   2                              count = *Descriptor_Ptr;                //get length
  563.  550   2                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  564.  551   2                              if(USB_Device_Request.wLength < count)
  565. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 10  
  566.  552   2                                      count = USB_Device_Request.wLength;                     //get the remaining length
  567.  553   2                              D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = count;
  568.  554   2                              D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
  569.  555   2                              //send string ID
  570.  556   2                              while(count != 0)
  571.  557   2                              {
  572.  558   3                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;      //fill up FIFO
  573.  559   3                                      Descriptor_Ptr++;
  574.  560   3                                      count--;
  575.  561   3                              }
  576.  562   2                              wait_ep0tx();
  577.  563   2                              ep0out_ack();
  578.  564   2                              break;
  579.  565   2                              
  580.  566   2                              
  581.  567   2                      case  4:  
  582.  568   2                              reserved();
  583.  569   2                              break;
  584.  570   2                              
  585.  571   2                      case  5:  //获取端点描述符
  586.  572   2                              Temp = 0;
  587.  573   2                              if((USB_Device_Request.wValue & 0x00ff) > 0x0001)
  588.  574   2                              {
  589.  575   3                                      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
  590.  576   3                                      while(!USB_Int_Flag.BITS.EP0SETUP)
  591.  577   3                                      {
  592.  578   4                                              //读取ISP1581中断寄存器
  593.  579   4                                              USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
  594.  580   4                                              //回写ISP1581中断寄存器
  595.  581   4                                              D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
  596.  582   4                                              if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
  597.  583   4                                                      return;
  598.  584   4                                      }
  599.  585   3                                      USB_Int_Flag.BITS.EP0TX = 0;
  600.  586   3                              }
  601.  587   2                              else
  602.  588   2                              {
  603.  589   3                                      Descriptor_Ptr = &Bulk_Out_Descriptor[0]; //set pointer to Bulk Out endpoint descriptor
  604.  590   3                                      count = *Descriptor_Ptr;        //read in descriptor length
  605.  591   3                                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  606.  592   3                                      if(count >= USB_Device_Request.wLength)
  607.  593   3                                      {
  608.  594   4                                              Temp = USB_Device_Request.wLength;
  609.  595   4                                              //send endpoint descriptor
  610.  596   4                                              D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) Temp;
  611.  597   4                                              D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (Temp >> 8);
  612.  598   4                                              for(count = 0 ; count < USB_Device_Request.wLength ; count++)
  613.  599   4                                              {
  614.  600   5                                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  615.  601   5                                                      Descriptor_Ptr++;
  616.  602   5                                              }
  617.  603   4                                              wait_ep0tx();
  618.  604   4                                              ep0out_ack();
  619.  605   4                                      }
  620.  606   3                                      else
  621.  607   3                                      {
  622.  608   4                                              USB_Device_Request.wLength -= count; //send Endpoint descriptor
  623.  609   4                                              Temp += count;
  624.  610   4                                              while(count != 0)
  625.  611   4                                              {
  626.  612   5                                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  627.  613   5                                                      count--;
  628. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 11  
  629.  614   5                                                      Descriptor_Ptr++;
  630.  615   5                                              }
  631.  616   4                                              Descriptor_Ptr = &Bulk_In_Descriptor[0]; //set pointer to Bulk In endpoint descriptor
  632.  617   4                                              count = *Descriptor_Ptr;        //read in descriptor length
  633.  618   4                                              if(count >= USB_Device_Request.wLength)
  634.  619   4                                              {
  635.  620   5                                                      Temp += USB_Device_Request.wLength;
  636.  621   5                                                      //send endpoint descriptor
  637.  622   5                                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) Temp;
  638.  623   5                                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (Temp >> 8);
  639.  624   5                                                      for(count = 0 ; count < USB_Device_Request.wLength ; count++)
  640.  625   5                                                      {
  641.  626   6                                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  642.  627   6                                                              Descriptor_Ptr++;
  643.  628   6                                                      }
  644.  629   5                                                      wait_ep0tx();
  645.  630   5                                                      ep0out_ack();
  646.  631   5                                              }
  647.  632   4                                              else
  648.  633   4                                              {
  649.  634   5                                                      USB_Device_Request.wLength -= count; //send Endpoint descriptor
  650.  635   5                                                      Temp += count;
  651.  636   5                                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) Temp;
  652.  637   5                                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (Temp >> 8);
  653.  638   5                                                      while(count != 0)
  654.  639   5                                                      {
  655.  640   6                                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  656.  641   6                                                              count--;
  657.  642   6                                                              Descriptor_Ptr++;
  658.  643   6                                                      }
  659.  644   5                                                      wait_ep0tx();
  660.  645   5                                                      ep0out_ack();
  661.  646   5                                              }       
  662.  647   4                                      }                                       
  663.  648   3                              }
  664.  649   2                              break;
  665.  650   2                              
  666.  651   2                      case  6:  //获取设备限制描述符
  667.  652   2                              Descriptor_Ptr = &HS_Device_Qualifier[0];               //set pointer to High Speed device descriptor
  668.  653   2                              count = *Descriptor_Ptr;                                                        //read in descriptor length
  669.  654   2                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  670.  655   2                              if(USB_Device_Request.wLength < count)
  671.  656   2                              {
  672.  657   3                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) USB_Device_Request.wLength;
  673.  658   3                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
  674.  659   3                                      count = USB_Device_Request.wLength;
  675.  660   3                              }
  676.  661   2                              else
  677.  662   2                              {
  678.  663   3                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = count;
  679.  664   3                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
  680.  665   3                              }
  681.  666   2                              while(count != 0)
  682.  667   2                              {
  683.  668   3                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;      //fill up FIFO
  684.  669   3                                      Descriptor_Ptr++;
  685.  670   3                                      count--;
  686.  671   3                              };
  687.  672   2                              wait_ep0tx();
  688.  673   2                              ep0out_ack();
  689.  674   2                              break;
  690.  675   2                              
  691. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 12  
  692.  676   2                      case  7  ://获取速度配置描述符
  693.  677   2                              Temp = 64;
  694.  678   2                              Descriptor_Ptr = &Other_Speed_Config_Descriptor[0];     //set pointer to configuration descriptor
  695.  679   2                              count = *Descriptor_Ptr;                                                        //get configuration Descriptor length
  696.  680   2                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  697.  681   2                              if(count >= USB_Device_Request.wLength)                         //Send only Configuration descriptor
  698.  682   2                              {
  699.  683   3                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) USB_Device_Request.wLength;
  700.  684   3                                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (USB_Device_Request.wLength >> 8);
  701.  685   3                                      for(count = 0 ; count < USB_Device_Request.wLength ; count++)
  702.  686   3                                      {
  703.  687   4                                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  704.  688   4                                              Descriptor_Ptr++;
  705.  689   4                                      }
  706.  690   3                                      wait_ep0tx();
  707.  691   3                                      ep0out_ack();
  708.  692   3                              }
  709.  693   2                              else //send Configuration,Interface and Endpoint descriptor
  710.  694   2                              {
  711.  695   3                                      if(USB_Device_Request.wLength >= 32)
  712.  696   3                                      {
  713.  697   4                                              while(count != 0)
  714.  698   4                                              {
  715.  699   5                                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  716.  700   5                                                      count--;
  717.  701   5                                                      Descriptor_Ptr++;
  718.  702   5                                              }
  719.  703   4                                              Descriptor_Ptr = &Bulk_Interface_Descriptor[0]; //set pointer to interface descriptor
  720.  704   4                                              count = *Descriptor_Ptr;        //get the descriptor count
  721.  705   4                                              while(count != 0)
  722.  706   4                                              {
  723.  707   5                                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  724.  708   5                                                      count--;
  725.  709   5                                                      Descriptor_Ptr++;
  726.  710   5                                              }
  727.  711   4                                              Descriptor_Ptr = &Int_In_Descriptor[0]; //set pointer to interface descriptor
  728.  712   4                                              count = *Descriptor_Ptr;        //read in descriptor length
  729.  713   4                                              while(count != 0)
  730.  714   4                                              {
  731.  715   5                                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  732.  716   5                                                      count--;
  733.  717   5                                                      Descriptor_Ptr++;
  734.  718   5                                              }
  735.  719   4                                              Descriptor_Ptr = &Int_Out_Descriptor[0]; //set pointer to interface descriptor
  736.  720   4                                              count = *Descriptor_Ptr;        //read in descriptor length
  737.  721   4                                              while(count != 0)
  738.  722   4                                              {
  739.  723   5                                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  740.  724   5                                                      count--;
  741.  725   5                                                      Descriptor_Ptr++;
  742.  726   5                                              }
  743.  727   4                                              Descriptor_Ptr = &Bulk_In_Descriptor[0]; //set pointer to interface descriptor
  744.  728   4                                              count = *Descriptor_Ptr;        //read in descriptor length
  745.  729   4                                              while(count != 0)
  746.  730   4                                              {
  747.  731   5                                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  748.  732   5                                                      count--;
  749.  733   5                                                      Descriptor_Ptr++;
  750.  734   5                                              }
  751.  735   4                                              Descriptor_Ptr = &Bulk_Out_Descriptor[0]; //set pointer to interface descriptor
  752.  736   4                                              count = *Descriptor_Ptr;        //read in descriptor length
  753.  737   4                                              while(count != 0)
  754. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 13  
  755.  738   4                                              {
  756.  739   5                                                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
  757.  740   5                                                      count--;
  758.  741   5                                                      Descriptor_Ptr++;
  759.  742   5                                              }
  760.  743   4                                      }                                       
  761.  744   3                                      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.VENDP = 1;      //validate FIFO
  762.  745   3                                      wait_ep0tx();
  763.  746   3                                      ep0out_ack();
  764.  747   3                              }
  765.  748   2                              break;
  766.  749   2                              
  767.  750   2                      case  8:  
  768.  751   2                              break;
  769.  752   2                              
  770.  753   2                      default  :
  771.  754   2                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  772.  755   2                              D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
  773.  756   2                              while(!USB_Int_Flag.BITS.EP0SETUP)
  774.  757   2                              {
  775.  758   3                                      //读取ISP1581中断寄存器
  776.  759   3                                      USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
  777.  760   3                                      //回写ISP1581中断寄存器
  778.  761   3                                      D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
  779.  762   3                                      if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
  780.  763   3                                              return;
  781.  764   3                              }
  782.  765   2                              USB_Int_Flag.BITS.EP0TX = 0;
  783.  766   2                              break;
  784.  767   2              }
  785.  768   1      }       
  786.  769          
  787.  770          //Set_Address设置地址
  788.  771          void set_address(void)
  789.  772          {
  790.  773   1              USB_Int_Flag.BITS.EP0RX = 0;
  791.  774   1              D14_Cntrl_Reg.D14_ADDRESS.BITS.DEVADDR = (USB_Device_Request.wValue >> 8);//设置地址
  792.  775   1              //状态响应
  793.  776   1              ep0in_ack();
  794.  777   1      }
  795.  778          
  796.  779          //Set_Config设置配置
  797.  780          void set_config(void)
  798.  781          {
  799.  782   1              USB_Int_Flag.BITS.EP0RX = 0;
  800.  783   1              
  801.  784   1              if(USB_Device_Request.wValue == 0)
  802.  785   1              {
  803.  786   2                      Device_Config_Value = 0;
  804.  787   2                      ep0in_ack();
  805.  788   2              }
  806.  789   1              else if (USB_Device_Request.wValue ==  0x0100)
  807.  790   1          {
  808.  791   2                      //配置设备
  809.  792   2                      Device_Config_Value = (UC) (USB_Device_Request.wValue >> 8);
  810.  793   2      //              USB_Device.BITS.State = USB_Configured;
  811.  794   2                      ep0in_ack();
  812.  795   2              }
  813.  796   1              else
  814.  797   1              {
  815.  798   2                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  816.  799   2                      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
  817. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 14  
  818.  800   2                      while(!USB_Int_Flag.BITS.EP0SETUP)
  819.  801   2                      {
  820.  802   3                              //读取ISP1581中断寄存器
  821.  803   3                              USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
  822.  804   3                              //回写ISP1581中断寄存器
  823.  805   3                              D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
  824.  806   3                              if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
  825.  807   3                                      return;
  826.  808   3                      }
  827.  809   2                      USB_Int_Flag.BITS.EP0TX = 0;
  828.  810   2              }
  829.  811   1      }
  830.  812          
  831.  813          
  832.  814          //Get_Config获取配置
  833.  815          void get_config(void)
  834.  816          {
  835.  817   1              D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  836.  818   1              D14_Cntrl_Reg.D14_DATA_PORT_LSB = Device_Config_Value;
  837.  819   1              D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.VENDP = 1;
  838.  820   1              wait_ep0tx();
  839.  821   1              ep0out_ack();
  840.  822   1      }       
  841.  823          
  842.  824          //Clear_Feature特性清除
  843.  825          void clear_feature(void)
  844.  826          {
  845.  827   1              unsigned char bRecipient = USB_Device_Request.bmRequestType & 0x0f;
  846.  828   1              //端点
  847.  829   1              if(bRecipient == 0x02 &&USB_Device_Request.wValue == 0x0000)
  848.  830   1              {
  849.  831   2                      switch(USB_Device_Request.wIndex)
  850.  832   2                      {
  851.  833   3                      case  0x8000   :
  852.  834   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  853.  835   3                              break;
  854.  836   3                      case  0x0000   :
  855.  837   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
  856.  838   3                              break;
  857.  839   3                      case  0x8100   :
  858.  840   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 3;
  859.  841   3                              break;
  860.  842   3                      case  0x0100   :
  861.  843   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 2;
  862.  844   3                              break;
  863.  845   3                      case  0x8200   :
  864.  846   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 5;
  865.  847   3                              break;
  866.  848   3                      case  0x0200   :
  867.  849   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 4;
  868.  850   3                              break;
  869.  851   3                      case  0x8300   :
  870.  852   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 7;
  871.  853   3                              break;
  872.  854   3                      case  0x0300   :
  873.  855   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 6;
  874.  856   3                              break;
  875.  857   3                      case  0x8400   :
  876.  858   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 9;
  877.  859   3                              break;
  878.  860   3                      case  0x0400   :
  879.  861   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 8;
  880. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 15  
  881.  862   3                              break;
  882.  863   3                      case  0x8500   :
  883.  864   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 11;
  884.  865   3                              break;
  885.  866   3                      case  0x0500   :
  886.  867   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 10;
  887.  868   3                              break;
  888.  869   3                      case  0x8600   :
  889.  870   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 13;
  890.  871   3                              break;
  891.  872   3                      case  0x0600   :
  892.  873   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 12;
  893.  874   3                              break;
  894.  875   3                      case  0x8700   :
  895.  876   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 15;
  896.  877   3                              break;
  897.  878   3                      case  0x0700   :
  898.  879   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 14;
  899.  880   3                              break;
  900.  881   3                      default        :  
  901.  882   3                              break;
  902.  883   3                      }                                                                                                      
  903.  884   2                      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 0;
  904.  885   2                      Kernel_Flag.BITS.Endpt_Stall = 0;
  905.  886   2                      D14_Cntrl_Reg.D14_ENDPT_TYPE.BITS.ENABLE = OFF;                 //disable FIFO
  906.  887   2                      D14_Cntrl_Reg.D14_ENDPT_TYPE.BITS.ENABLE = ON;                  //disable FIFO
  907.  888   2                      ep0in_ack();
  908.  889   2                      USB_Device.BITS.Halt = 0;
  909.  890   2              }                                                                                       
  910.  891   1              else if(bRecipient == 0x00 && USB_Device_Request.wValue == 0x0100)
  911.  892   1              {       //远程唤醒
  912.  893   2                      USB_Device.BITS.Remote_Wakeup = 0;
  913.  894   2                      ep0in_ack();
  914.  895   2              }
  915.  896   1              else
  916.  897   1              {
  917.  898   2                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  918.  899   2                      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
  919.  900   2                      while(!USB_Int_Flag.BITS.EP0SETUP)
  920.  901   2                      {
  921.  902   3                              //读取ISP1581中断寄存器
  922.  903   3                              USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
  923.  904   3                              //回写ISP1581中断寄存器
  924.  905   3                              D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
  925.  906   3                              if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
  926.  907   3                                      return;
  927.  908   3                      }
  928.  909   2                      USB_Int_Flag.BITS.EP0TX = 0;
  929.  910   2              }
  930.  911   1      }       
  931.  912          
  932.  913          //Get_Status获取设备状态
  933.  914          void get_status(void)
  934.  915          {
  935.  916   1              if(USB_Device_Request.bmRequestType == 0x80)
  936.  917   1              {
  937.  918   2                      //端点0IN返回0x01,0x00两字节
  938.  919   2                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  939.  920   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 2;
  940.  921   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
  941.  922   2                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = 1;
  942.  923   2                      D14_Cntrl_Reg.D14_DATA_PORT_MSB = 0;
  943. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 16  
  944.  924   2                      //等待发送完毕
  945.  925   2                      wait_ep0tx();
  946.  926   2                      ep0out_ack();
  947.  927   2              }
  948.  928   1      
  949.  929   1              if(USB_Device_Request.bmRequestType == 0x81)
  950.  930   1              {
  951.  931   2                      //端点0IN返回0x00,0x00两字节
  952.  932   2                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  953.  933   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 2;
  954.  934   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
  955.  935   2                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = 0;
  956.  936   2                      D14_Cntrl_Reg.D14_DATA_PORT_MSB = 0;
  957.  937   2                      wait_ep0tx();
  958.  938   2                      ep0out_ack();
  959.  939   2              }
  960.  940   1      
  961.  941   1              if(USB_Device_Request.bmRequestType == 0x82)
  962.  942   1              {
  963.  943   2                      Temp = 0;
  964.  944   2                      Temp = USB_Device.BITS.Halt;
  965.  945   2                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  966.  946   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 2;
  967.  947   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
  968.  948   2                      D14_Cntrl_Reg.D14_DATA_PORT_LSB = (UC) Temp;
  969.  949   2                      D14_Cntrl_Reg.D14_DATA_PORT_MSB = (UC) (Temp >> 8);
  970.  950   2                      wait_ep0tx();
  971.  951   2                      ep0out_ack();
  972.  952   2              }
  973.  953   1      }       
  974.  954          
  975.  955          
  976.  956          
  977.  957          //Set_Feature特性设置
  978.  958          //不支持测试模式
  979.  959          void set_feature(void)
  980.  960          {
  981.  961   1              unsigned char bRecipient = USB_Device_Request.bmRequestType & 0x0f;
  982.  962   1              //端点
  983.  963   1              if(bRecipient == 0x02 && USB_Device_Request.wValue == 0x0000)
  984.  964   1              {
  985.  965   2                      switch(USB_Device_Request.wIndex)
  986.  966   2                      {
  987.  967   3                      case  0x8000   :
  988.  968   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  989.  969   3                              break;
  990.  970   3                      case  0x0000   :
  991.  971   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
  992.  972   3                              break;
  993.  973   3                      case  0x8100   :
  994.  974   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 3;
  995.  975   3                              break;
  996.  976   3                      case  0x0100   :
  997.  977   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 2;
  998.  978   3                              break;
  999.  979   3                      case  0x8200   :
  1000.  980   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 5;
  1001.  981   3                              break;
  1002.  982   3                      case  0x0200   :
  1003.  983   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 4;
  1004.  984   3                              break;
  1005.  985   3                      case  0x8300   :
  1006. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 17  
  1007.  986   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 7;
  1008.  987   3                              break;
  1009.  988   3                      case  0x0300   :
  1010.  989   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 6;
  1011.  990   3                              break;
  1012.  991   3                      case  0x8400   :
  1013.  992   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 9;
  1014.  993   3                              break;
  1015.  994   3                      case  0x0400   :
  1016.  995   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 8;
  1017.  996   3                              break;
  1018.  997   3                      case  0x8500   :
  1019.  998   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 11;
  1020.  999   3                              break;
  1021. 1000   3                      case  0x0500   :
  1022. 1001   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 10;
  1023. 1002   3                              break;
  1024. 1003   3                      case  0x8600   :
  1025. 1004   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 13;
  1026. 1005   3                              break;
  1027. 1006   3                      case  0x0600   :
  1028. 1007   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 12;
  1029. 1008   3                              break;
  1030. 1009   3                      case  0x8700   :
  1031. 1010   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 15;
  1032. 1011   3                              break;
  1033. 1012   3                      case  0x0700   :
  1034. 1013   3                              D14_Cntrl_Reg.D14_ENDPT_INDEX = 14;
  1035. 1014   3                              break;
  1036. 1015   3                      default        :  
  1037. 1016   3                              break;
  1038. 1017   3                      }                                                                                                      
  1039. 1018   2                      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
  1040. 1019   2                      Kernel_Flag.BITS.Endpt_Stall = 1;
  1041. 1020   2                      D14_Cntrl_Reg.D14_ENDPT_TYPE.BITS.ENABLE = OFF;                 //disable FIFO
  1042. 1021   2                      //D14_Cntrl_Reg.D14_ENDPT_TYPE.BITS.ENABLE = ON;                        //disable FIFO
  1043. 1022   2                      ep0in_ack();
  1044. 1023   2                      USB_Device.BITS.Halt = 0;
  1045. 1024   2              }                                                                                       
  1046. 1025   1              else if(bRecipient == 0x00 && USB_Device_Request.wValue == 0x0100)
  1047. 1026   1              {       //远程唤醒
  1048. 1027   2                      USB_Device.BITS.Remote_Wakeup = 1;
  1049. 1028   2                      ep0in_ack();
  1050. 1029   2              }
  1051. 1030   1              else
  1052. 1031   1              {
  1053. 1032   2                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  1054. 1033   2                      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
  1055. 1034   2                      while(!USB_Int_Flag.BITS.EP0SETUP)
  1056. 1035   2                      {
  1057. 1036   3                              //读取ISP1581中断寄存器
  1058. 1037   3                              USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
  1059. 1038   3                              //回写ISP1581中断寄存器
  1060. 1039   3                              D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
  1061. 1040   3                              if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
  1062. 1041   3                                      return;
  1063. 1042   3                      }
  1064. 1043   2                      USB_Int_Flag.BITS.EP0TX = 0;
  1065. 1044   2              }
  1066. 1045   1      }
  1067. 1046          
  1068. 1047          
  1069. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 18  
  1070. 1048          //Get_Interface 获取接口状态
  1071. 1049          void get_interface(void)
  1072. 1050          {
  1073. 1051   1              if(USB_Device_Request.wValue != 0)
  1074. 1052   1              {
  1075. 1053   2                      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
  1076. 1054   2                      while(!USB_Int_Flag.BITS.EP0SETUP)
  1077. 1055   2                      {
  1078. 1056   3                              //读取ISP1581中断寄存器
  1079. 1057   3                              USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
  1080. 1058   3                              //回写ISP1581中断寄存器
  1081. 1059   3                              D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
  1082. 1060   3                              if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
  1083. 1061   3                                      return;
  1084. 1062   3                      }
  1085. 1063   2                      USB_Int_Flag.BITS.EP0TX = 0;
  1086. 1064   2              }
  1087. 1065   1              else
  1088. 1066   1              {
  1089. 1067   2                      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  1090. 1068   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 1;
  1091. 1069   2                      D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
  1092. 1070   2                      if(!USB_Device.BITS.Alter_Interface)
  1093. 1071   2                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = 0;
  1094. 1072   2                      else
  1095. 1073   2                              D14_Cntrl_Reg.D14_DATA_PORT_LSB = 1;
  1096. 1074   2                      wait_ep0tx();
  1097. 1075   2                      ep0in_ack();
  1098. 1076   2              }
  1099. 1077   1      }
  1100. 1078          
  1101. 1079          
  1102. 1080          //Set_Interface 设置接口状态
  1103. 1081          void set_interface(void)
  1104. 1082          {
  1105. 1083   1              if(USB_Device_Request.wIndex == 0 && USB_Device_Request.wValue == 0x0100)
  1106. 1084   1                      USB_Device.BITS.Alter_Interface = 1;
  1107. 1085   1              
  1108. 1086   1              if(USB_Device_Request.wIndex == 0x0100 && USB_Device_Request.wValue == 0)
  1109. 1087   1                      USB_Device.BITS.Alter_Interface = 0;
  1110. 1088   1              
  1111. 1089   1              if(USB_Device_Request.wIndex == 0 && USB_Device_Request.wValue == 0)
  1112. 1090   1                      USB_Device.BITS.Alter_Interface = 0;
  1113. 1091   1      
  1114. 1092   1              ep0in_ack();
  1115. 1093   1      }
  1116. 1094          
  1117. 1095          
  1118. 1096          
  1119. 1097          //端点0IN状态响应
  1120. 1098          void ep0in_ack(void)
  1121. 1099          {
  1122. 1100   1              D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
  1123. 1101   1              D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STATUS = 1;
  1124. 1102   1              wait_ep0tx();
  1125. 1103   1      }
  1126. 1104          
  1127. 1105          //端点0IN状态响应
  1128. 1106          void wait_ep0tx(void)
  1129. 1107          {
  1130. 1108   1              //end of status stage
  1131. 1109   1              while(!USB_Int_Flag.BITS.EP0TX)
  1132. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 19  
  1133. 1110   1              {
  1134. 1111   2                      //读取ISP1581中断寄存器
  1135. 1112   2                      USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
  1136. 1113   2                      //回写ISP1581中断寄存器
  1137. 1114   2                      D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
  1138. 1115   2                      if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
  1139. 1116   2                              return;
  1140. 1117   2              }
  1141. 1118   1              USB_Int_Flag.BITS.EP0TX = 0;
  1142. 1119   1      }
  1143. 1120          
  1144. 1121          //端点0OUT状态响应
  1145. 1122          void ep0out_ack(void)
  1146. 1123          {
  1147. 1124   1              //设置状态响应
  1148. 1125   1              //acknowledge status stage
  1149. 1126   1              D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
  1150. 1127   1              D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STATUS = 1;
  1151. 1128   1      //      D14_Cntrl_Reg.D14_CONTROL_FUNCTION.VALUE = 2;
  1152. 1129   1              wait_ep0rx();
  1153. 1130   1      }
  1154. 1131          
  1155. 1132          //端点0OUT状态响应
  1156. 1133          void wait_ep0rx(void)
  1157. 1134          {
  1158. 1135   1              while(!USB_Int_Flag.BITS.EP0RX)
  1159. 1136   1              {
  1160. 1137   2                      //读取ISP1581中断寄存器
  1161. 1138   2                      USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
  1162. 1139   2                      //回写ISP1581中断寄存器
  1163. 1140   2                      D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
  1164. 1141   2                      if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
  1165. 1142   2                              return;
  1166. 1143   2              }               
  1167. 1144   1              USB_Int_Flag.BITS.EP0RX = 0;
  1168. 1145   1      }
  1169. 1146          
  1170. 1147          #pragma disable
  1171. 1148          /*
  1172. 1149          unsigned int read_endpoint(unsigned char endp,unsigned int len,unsigned char *buf)
  1173. 1150          {
  1174. 1151                  unsigned int datalen;
  1175. 1152                  D14_Cntrl_Reg.D14_ENDPT_INDEX = endp;
  1176. 1153                  len = D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB;
  1177. 1154                  len <<= 8;
  1178. 1155                  len += D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB;
  1179. 1156                  datalen=len;
  1180. 1157                  while(datalen-- != 0)
  1181. 1158                  {
  1182. 1159                          *buf = D14_Cntrl_Reg.D14_DATA_PORT_LSB; //fill up FIFO
  1183. 1160                          buf++;
  1184. 1161                  }
  1185. 1162                  return len;
  1186. 1163          }
  1187. 1164          
  1188. 1165          unsigned int write_endpoint(unsigned char endp,unsigned int len,unsigned char *buf)
  1189. 1166          {
  1190. 1167                  unsigned int datalen;
  1191. 1168                  D14_Cntrl_Reg.D14_ENDPT_INDEX = endp;
  1192. 1169                  D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (unsigned char) len;
  1193. 1170                  D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (unsigned char) (len>>8);
  1194. 1171                  datalen=len;
  1195. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 20  
  1196. 1172                  while(datalen-- != 0)
  1197. 1173                  {
  1198. 1174                          D14_Cntrl_Reg.D14_DATA_PORT_LSB = *buf; //fill up FIFO
  1199. 1175                          buf++;
  1200. 1176                  }
  1201. 1177                  return len;
  1202. 1178                  
  1203. 1179          }*/
  1204. 1180          void delay()
  1205. 1181          {
  1206. 1182   1              UC i,j;
  1207. 1183   1              for(i=0;i<200;i++)
  1208. 1184   1                      for(j=0;j<200;j++);
  1209. 1185   1      }
  1210. 1186          void rt2_process()
  1211. 1187          {
  1212. 1188   1              UC  i,j;
  1213. 1189   1              if(USB_Device_Request.wIndex==GET_SET_EEPROM_REQUEST)
  1214. 1190   1              {
  1215. 1191   2                      USB_Device_Request.wValue=USB_Device_Request.wValue>>8;
  1216. 1192   2                      if(bytecouter>8)
  1217. 1193   2                      {
  1218. 1194   3                              j=bytecouter/8;
  1219. 1195   3                              for(i=0;i<j;i++)
  1220. 1196   3                              {
  1221. 1197   4                                      ISendStr(0xa0,((UC)(USB_Device_Request.wValue+(i*8))),&Endpt_FIFO[i*8],8);
  1222. 1198   4                                      delay();
  1223. 1199   4                              }
  1224. 1200   3                              j=bytecouter%8;
  1225. 1201   3                              ISendStr(0xa0,((UC)(USB_Device_Request.wValue+(i*8))),&Endpt_FIFO[i*8],j);
  1226. 1202   3                              delay();
  1227. 1203   3                      }
  1228. 1204   2                      else
  1229. 1205   2                              ISendStr(0xa0,(UC)USB_Device_Request.wValue,Endpt_FIFO,bytecouter);
  1230. 1206   2                              delay();
  1231. 1207   2              }
  1232. 1208   1              for(i=0;i<64;i++)
  1233. 1209   1                      Endpt_FIFO[i]=0;
  1234. 1210   1              ZLG7290_SendBuf(disp_buf1,8);
  1235. 1211   1              delay();
  1236. 1212   1      }
  1237. 1213          void tt2_process()
  1238. 1214          {
  1239. 1215   1              if(USB_Device_Request.wIndex==GET_SET_EEPROM_REQUEST)
  1240. 1216   1              {
  1241. 1217   2                      USB_Device_Request.wValue=USB_Device_Request.wValue>>8;
  1242. 1218   2                      IRcvStr(0xa0,(UC)USB_Device_Request.wValue,Endpt_FIFO,bytecouter);
  1243. 1219   2                      delay();
  1244. 1220   2                      ZLG7290_SendBuf(disp_buf0,8);
  1245. 1221   2                      delay();
  1246. 1222   2              }               
  1247. 1223   1      }
  1248. 1224          
  1249. MODULE INFORMATION:   STATIC OVERLAYABLE
  1250.    CODE SIZE        =   5293    ----
  1251.    CONSTANT SIZE    =     64    ----
  1252.    XDATA SIZE       =   ----    ----
  1253.    PDATA SIZE       =   ----    ----
  1254.    DATA SIZE        =     33       8
  1255.    IDATA SIZE       =     72    ----
  1256. C51 COMPILER V7.06   CHAP_9                                                                07/02/2003 10:05:13 PAGE 21  
  1257.    BIT SIZE         =   ----    ----
  1258. END OF MODULE INFORMATION.
  1259. C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)