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

USB编程

开发平台:

C/C++

  1. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 10:27:49 PAGE 1   
  2. C51 COMPILER V7.06, COMPILATION OF MODULE KERNEL
  3. OBJECT MODULE PLACED IN kernel.OBJ
  4. COMPILER INVOKED BY: C:KEILC51BINC51.EXE kernel.c OPTIMIZE(2,SPEED) BROWSE DEBUG OBJECTEXTEND
  5. stmt level    source
  6.    1          /****************************************Copyright (c)**************************************************
  7.    2          **                               广州周立功单片机发展有限公司
  8.    3          **                                     研    究    所
  9.    4          **                                 http://www.zlgmcu.com
  10.    5          **--------------当前版本修订------------------------------------------------------------------------------
  11.    6          ** 修改人: 刘英斌
  12.    7          ** 日 期:2003-03-13
  13.    8          ** 描 述:ISP1581 V1.0
  14.    9          **------------------------------------------------------------------------------------------------------
  15.   10          ********************************************************************************************************/
  16.   11          
  17.   12          #include "standard.h"
  18.   13          #include "Kernel.h"
  19.   14          #include "D14.h"
  20.   15          
  21.   16          //***********************************************************************
  22.   17          //*                                                                                                                                                            *
  23.   18          //*                      External routine Definition                                                  *
  24.   19          //*                                                                                                                                                            *
  25.   20          //***********************************************************************
  26.   21          
  27.   22          extern Init_Main();
  28.   23          extern USB_Debug_Mode();
  29.   24          extern DMA_Debug_Mode();
  30.   25          extern USB_INT_FLAG USB_Int_Flag;
  31.   26          extern DMA_INT_FLAG DMA_Int_Flag;
  32.   27          extern USB_DEVICE USB_Device;
  33.   28          extern volatile D14_CNTRL_REG   xdata   D14_Cntrl_Reg;
  34.   29          extern void Check_Busy(void);
  35.   30          extern void Init_D14(void);
  36.   31          extern void Init_Endpoint(void);
  37.   32          extern void Init_Device(void);
  38.   33          extern void Get_PIDVID(void);
  39.   34          extern unsigned int read_endpoint(unsigned char endp,unsigned int len,unsigned char *buf);
  40.   35          extern unsigned int write_endpoint(unsigned char endp,unsigned int len,unsigned char *buf);
  41.   36          
  42.   37          
  43.   38          extern UC VID[2],PID[2];
  44.   39          extern UC       idata Endpt_FIFO[MAX_BUF];
  45.   40          extern Set_USB(void);
  46.   41          extern TIMER    Timer;
  47.   42          
  48.   43          //***********************************************************************
  49.   44          //*                                                                                                                                                            *
  50.   45          //*                      Prototype routine Definition                                              *
  51.   46          //*                                                                                                                                                            *
  52.   47          //***********************************************************************
  53.   48          
  54.   49          void Start_mSEC_Timer(Data);
  55.   50          void Start_SEC_Timer(Data);
  56.   51          
  57.   52          //***********************************************************************
  58.   53          //*                                                                                                                                                            *
  59.   54          //*                          Variable Definition                                                              *
  60.   55          //*                                                                                                                                                            *
  61. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 10:27:49 PAGE 2   
  62.   56          //***********************************************************************
  63.   57          
  64.   58          UI      Temp;
  65.   59          KERNEL Kernel_Flag;
  66.   60          
  67.   61          
  68.   62          //***********************************************************************
  69.   63          //*                                                                                                                                                            *
  70.   64          //*                          Routine Definition                                                            *
  71.   65          //*                                                                                                                                                            *
  72.   66          //***********************************************************************
  73.   67          
  74.   68          //***********************************************************************
  75.   69          //*                                                                                                                                                    *
  76.   70          //*     Routine         :  Main                                                            *
  77.   71          //*     Input           :  None                                                                                             *
  78.   72          //*     Output   :      None                                                                       *
  79.   73          //*     Function        :       main loop                                                             *
  80.   74          //*                                                                                                                                                            *
  81.   75          //***********************************************************************
  82.   76          
  83.   77          void Main(void)
  84.   78          {
  85.   79   1              unsigned int a;
  86.   80   1              unsigned char b[16];
  87.   81   1              
  88.   82   1              //Initialization routine
  89.   83   1              //初始化子程序
  90.   84   1              Init_Main();                    
  91.   85   1              
  92.   86   1              //enable device and reset the device address
  93.   87   1              D14_Cntrl_Reg.D14_MODE.BITS.SOFTCT = 1; 
  94.   88   1              
  95.   89   1              do
  96.   90   1              {
  97.   91   2                      
  98.   92   2                      
  99.   93   2                      //USB routine
  100.   94   2                      USB_Debug_Mode();
  101.   95   2                      
  102.   96   2                      //Generic DMA routine
  103.   97   2                      DMA_Debug_Mode();       
  104.   98   2      
  105.   99   2                      if (USB_Int_Flag.BITS.EP1RX)
  106.  100   2                      {
  107.  101   3                              USB_Int_Flag.BITS.EP1RX = 0;
  108.  102   3                              a=read_endpoint(0x02,8,b);
  109.  103   3                              b[0]=0;
  110.  104   3                              b[1]=0x12;
  111.  105   3                              b[2]=0x12;
  112.  106   3                              b[3]=0x12;
  113.  107   3                      }
  114.  108   2                      a=write_endpoint(0x03,4,b);
  115.  109   2      
  116.  110   2      
  117.  111   2                      
  118.  112   2              }
  119.  113   1              while(1);
  120.  114   1              
  121.  115   1      }
  122.  116          
  123.  117          
  124. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 10:27:49 PAGE 3   
  125.  118          
  126.  119          //***********************************************************************
  127.  120          //*                                                                                                                                                    *
  128.  121          //*     Routine         : Start_mSEC_Timer(Delay)                                       *
  129.  122          //*     Input           : Delay in milli second                                                                          *  
  130.  123          //*     Output          : Start timer operation                                                    *
  131.  124          //*     Function        : To start the timeout operation based on the delay i/p  *
  132.  125          //*                                                                                                                                                            *
  133.  126          //***********************************************************************
  134.  127          
  135.  128          void Start_mSEC_Timer(Data)
  136.  129          {
  137.  130   1              
  138.  131   1              
  139.  132   1              do
  140.  133   1              {
  141.  134   2                      
  142.  135   2                      //calculate timer value
  143.  136   2                      Temp = Timer.mSEC_Scale;                
  144.  137   2                      Temp = 0xffff - Temp;
  145.  138   2                      
  146.  139   2                      ET0 = 1;
  147.  140   2                      
  148.  141   2                      //calculate timer value
  149.  142   2                      //initialize timer 0 counter
  150.  143   2                      Temp >>= 8;
  151.  144   2                      TH0 = (UC) Temp;
  152.  145   2                      Temp = Timer.mSEC_Scale;                
  153.  146   2                      Temp = 0xffff - Temp;
  154.  147   2                      TL0 = (UC) Temp;
  155.  148   2                      
  156.  149   2                      //start timer count
  157.  150   2                      TR0 = 1;                                                        
  158.  151   2                      
  159.  152   2                      Kernel_Flag.BITS.Timer_Expired = 0;
  160.  153   2                      while(!Kernel_Flag.BITS.Timer_Expired);
  161.  154   2                      Kernel_Flag.BITS.Timer_Expired = 0;
  162.  155   2                      
  163.  156   2                      
  164.  157   2                      //stop timer
  165.  158   2                      TR0 = 0;                                                        
  166.  159   2                      ET0 = 0;
  167.  160   2                      
  168.  161   2                      Data--;
  169.  162   2              }
  170.  163   1              while(Data != 0);
  171.  164   1      }
  172.  165          
  173.  166          
  174. MODULE INFORMATION:   STATIC OVERLAYABLE
  175.    CODE SIZE        =    198    ----
  176.    CONSTANT SIZE    =   ----    ----
  177.    XDATA SIZE       =   ----    ----
  178.    PDATA SIZE       =   ----    ----
  179.    DATA SIZE        =      6      20
  180.    IDATA SIZE       =   ----    ----
  181.    BIT SIZE         =   ----    ----
  182. END OF MODULE INFORMATION.
  183. C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)