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

USB编程

开发平台:

C/C++

  1. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 10:05:13 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          //***********************************************************************
  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       :       Kernel.c                                      *
  14.    9          //      Author          :       Albert Goh                                                                                    *
  15.   10          //      Created         :       3 March 2000                                    *
  16.   11          //                                                                         *
  17.   12          //***********************************************************************
  18.   13          //***********************************************************************
  19.   14          //                                                                      *
  20.   15          // Kernel.c is the control centre for this evaluation firmware. It will *
  21.   16          // control where should the firmware branch through via the selection   *
  22.   17          // of the UART port of the 8051. if not via the UART, it will be from   *
  23.   18          // the selection of the code defintion                                  *
  24.   19          //                                                                      *
  25.   20          //***********************************************************************
  26.   21          //***********************************************************************
  27.   22          //                                                                      *
  28.   23          //  Module History                                                                                                                          *  
  29.   24          //  **************                                                                                                                          *
  30.   25          //                                                                                                                                                                *
  31.   26          //  Date        Version                 Author                          Changes                                       *
  32.   27          //  ====        =======                 ======                          =======                                          *
  33.   28          //  030300        0.1                   Albert                          Created                                       *
  34.   29          //                                                                      *
  35.   30          //                                                                      *
  36.   31          //***********************************************************************
  37.   32          //***********************************************************************
  38.   33          //*                                                                                                                                                            *
  39.   34          //*                          Include Files Definition                                              *
  40.   35          //*                                                                                                                                                            *
  41.   36          //***********************************************************************
  42.   37          
  43.   38          #include "standard.h"
  44.   39          #include "Kernel.h"
  45.   40          #include "D14.h"
  46.   41          #include "zlg7290.h"
  47.   42          #include "VIIC_C51.h"
  48.   43          
  49.   44          #define uchar unsigned char
  50.   45          
  51.   46          //***********************************************************************
  52.   47          //*                                                                                                                                                            *
  53.   48          //*                      External routine Definition                                                  *
  54.   49          //*                                                                                                                                                            *
  55.   50          //***********************************************************************
  56.   51          
  57.   52          extern Init_Main();
  58.   53          extern USB_Debug_Mode();
  59.   54          extern DMA_Debug_Mode();
  60.   55          extern USB_INT_FLAG USB_Int_Flag;
  61. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 10:05:13 PAGE 2   
  62.   56          extern DMA_INT_FLAG DMA_Int_Flag;
  63.   57          extern USB_DEVICE USB_Device;
  64.   58          extern  D14_CNTRL_REG   volatile xdata   D14_Cntrl_Reg;
  65.   59          extern void Check_Busy(void);
  66.   60          extern void Init_D14(void);
  67.   61          extern void Init_Endpoint(void);
  68.   62          extern void Init_Device(void);
  69.   63          extern void Get_PIDVID(void);
  70.   64          //extern unsigned int read_endpoint(unsigned char endp,unsigned int len,unsigned char *buf);
  71.   65          //extern unsigned int write_endpoint(unsigned char endp,unsigned int len,unsigned char *buf);
  72.   66          extern UC VID[2],PID[2];
  73.   67          extern UC       idata Endpt_FIFO[MAX_BUF];
  74.   68          extern Set_USB(void);
  75.   69          extern TIMER    Timer;
  76.   70          extern UC       timecouter;
  77.   71          //***********************************************************************
  78.   72          //*                                                                                                                                                            *
  79.   73          //*                      Prototype routine Definition                                              *
  80.   74          //*                                                                                                                                                            *
  81.   75          //***********************************************************************
  82.   76          
  83.   77          void Start_mSEC_Timer(Data);
  84.   78          void Start_SEC_Timer(Data);
  85.   79          uchar DelayNS(uchar no);
  86.   80          
  87.   81          //***********************************************************************
  88.   82          //*                                                                                                                                                            *
  89.   83          //*                          Variable Definition                                                              *
  90.   84          //*                                                                                                                                                            *
  91.   85          //***********************************************************************
  92.   86          
  93.   87          UI      Temp;
  94.   88          KERNEL Kernel_Flag;
  95.   89          uchar code disp_buf[8]={0,0,0,0,0,0,0,0};               //LED初始化值
  96.   90          //UC key=0xff;
  97.   91          //***********************************************************************
  98.   92          //*                                                                                                                                                            *
  99.   93          //*                          Routine Definition                                                            *
  100.   94          //*                                                                                                                                                            *
  101.   95          //***********************************************************************
  102.   96          
  103.   97          //***********************************************************************
  104.   98          //*                                                                                                                                                    *
  105.   99          //*     Routine         :  Main                                                            *
  106.  100          //*     Input           :  None                                                                                             *
  107.  101          //*     Output   :      None                                                                       *
  108.  102          //*     Function        :       main loop                                                             *
  109.  103          //*                                                                                                                                                            *
  110.  104          //***********************************************************************
  111.  105          
  112.  106          void Main(void)
  113.  107          {
  114.  108   1              DelayNS(5);
  115.  109   1      
  116.  110   1          DelayNS(5);
  117.  111   1              //Initialization routine
  118.  112   1              //初始化子程序
  119.  113   1              ZLG7290_SendBuf(disp_buf,8);
  120.  114   1              Init_Main();                    
  121.  115   1              
  122.  116   1              //enable device and reset the device address
  123.  117   1              D14_Cntrl_Reg.D14_MODE.BITS.SOFTCT = 1; 
  124. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 10:05:13 PAGE 3   
  125.  118   1              
  126.  119   1              do
  127.  120   1              {               
  128.  121   2                      //USB routine
  129.  122   2                      USB_Debug_Mode();
  130.  123   2                      
  131.  124   2                      //Generic DMA routine
  132.  125   2                      DMA_Debug_Mode();
  133.  126   2      
  134.  127   2              }
  135.  128   1              while(1);
  136.  129   1      }
  137.  130          
  138.  131          /*********************************************************************************************************
  139.  132          ** 函数名称:    DelayNS
  140.  133          ** 功能描述:    长软件延时
  141.  134          ** 输 入: no : 延时参数,值越大时延时越久
  142.  135          **         
  143.  136          ** 输 出: 0 :  OK;
  144.  137          **         1 :  FAIL;
  145.  138          ** 全局变量:    无
  146.  139          ** 调用模块:    无
  147.  140          **
  148.  141          ** 作 者: 叶皓贲
  149.  142          ** 日 期: 2003-3-4
  150.  143          **-------------------------------------------------------------------------------------------------------
  151.  144          ** 修改人:
  152.  145          ** 日 期:
  153.  146          **------------------------------------------------------------------------------------------------------
  154.  147          ********************************************************************************************************/
  155.  148          uchar DelayNS(uchar no)
  156.  149          { 
  157.  150   1              uchar i,j;                                      //延时参数
  158.  151   1      
  159.  152   1              for(; no>0; no--)
  160.  153   1              { 
  161.  154   2                      for(i=0; i<100; i++)
  162.  155   2                      for(j=0; j<100; j++);
  163.  156   2              }
  164.  157   1              return 0; 
  165.  158   1      }
  166.  159          
  167.  160          //***********************************************************************
  168.  161          //*                                                                                                                                                    *
  169.  162          //*     Routine         : Start_mSEC_Timer(Delay)                                       *
  170.  163          //*     Input           : Delay in milli second                                                                          *  
  171.  164          //*     Output          : Start timer operation                                                    *
  172.  165          //*     Function        : To start the timeout operation based on the delay i/p  *
  173.  166          //*                                                                                                                                                            *
  174.  167          //***********************************************************************
  175.  168          
  176.  169          void Start_mSEC_Timer(Data)
  177.  170          {
  178.  171   1              
  179.  172   1              
  180.  173   1              do
  181.  174   1              {
  182.  175   2                      
  183.  176   2                      //calculate timer value
  184.  177   2                      Temp = Timer.mSEC_Scale;                
  185.  178   2                      Temp = 0xffff - Temp;
  186.  179   2                      
  187. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 10:05:13 PAGE 4   
  188.  180   2                      ET0 = 1;
  189.  181   2                      
  190.  182   2                      //calculate timer value
  191.  183   2                      //initialize timer 0 counter
  192.  184   2                      Temp >>= 8;
  193.  185   2                      TH0 = (UC) Temp;
  194.  186   2                      Temp = Timer.mSEC_Scale;                
  195.  187   2                      Temp = 0xffff - Temp;
  196.  188   2                      TL0 = (UC) Temp;
  197.  189   2                      
  198.  190   2                      //start timer count
  199.  191   2                      TR0 = 1;                                                        
  200.  192   2                      
  201.  193   2                      Kernel_Flag.BITS.Timer_Expired = 0;
  202.  194   2                      while(!Kernel_Flag.BITS.Timer_Expired);
  203.  195   2                      Kernel_Flag.BITS.Timer_Expired = 0;
  204.  196   2                      
  205.  197   2                      
  206.  198   2                      //stop timer
  207.  199   2                      TR0 = 0;                                                        
  208.  200   2                      ET0 = 0;
  209.  201   2                      
  210.  202   2                      Data--;
  211.  203   2              }
  212.  204   1              while(Data != 0);
  213.  205   1      }
  214.  206          
  215.  207          
  216. MODULE INFORMATION:   STATIC OVERLAYABLE
  217.    CODE SIZE        =    195    ----
  218.    CONSTANT SIZE    =      8    ----
  219.    XDATA SIZE       =   ----    ----
  220.    PDATA SIZE       =   ----    ----
  221.    DATA SIZE        =      6       5
  222.    IDATA SIZE       =   ----    ----
  223.    BIT SIZE         =   ----    ----
  224. END OF MODULE INFORMATION.
  225. C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)