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

USB编程

开发平台:

C/C++

  1. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 09:29:11 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 09:29:11 PAGE 2   
  62.   56          extern DMA_INT_FLAG DMA_Int_Flag;
  63.   57          extern USB_DEVICE USB_Device;
  64.   58          extern volatile D14_CNTRL_REG   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 td[5]={0x00,0x12,0x48,0x30,0x12};   //8563初始化值
  96.   90          uchar code disp_buf[8]={0,0,0,0,0,0,0,0};               //LED初始化值
  97.   91          //UC key=0xff;
  98.   92          //***********************************************************************
  99.   93          //*                                                                                                                                                            *
  100.   94          //*                          Routine Definition                                                            *
  101.   95          //*                                                                                                                                                            *
  102.   96          //***********************************************************************
  103.   97          
  104.   98          //***********************************************************************
  105.   99          //*                                                                                                                                                    *
  106.  100          //*     Routine         :  Main                                                            *
  107.  101          //*     Input           :  None                                                                                             *
  108.  102          //*     Output   :      None                                                                       *
  109.  103          //*     Function        :       main loop                                                             *
  110.  104          //*                                                                                                                                                            *
  111.  105          //***********************************************************************
  112.  106          
  113.  107          void Main(void)
  114.  108          {
  115.  109   1              
  116.  110   1              //ISendStr(0xa2,0,td,0x5);
  117.  111   1              //ZLG7289_Rest();               // 复位ZLG7289
  118.  112   1          DelayNS(5);
  119.  113   1              //Initialization routine
  120.  114   1              //初始化子程序
  121.  115   1              ZLG7290_SendBuf(disp_buf,8);
  122.  116   1              Init_Main();                    
  123.  117   1              
  124. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 09:29:11 PAGE 3   
  125.  118   1              //enable device and reset the device address
  126.  119   1              D14_Cntrl_Reg.D14_MODE.BITS.SOFTCT = 1; 
  127.  120   1              
  128.  121   1              do
  129.  122   1              {               
  130.  123   2                      //USB routine
  131.  124   2                      USB_Debug_Mode();
  132.  125   2                      
  133.  126   2                      //Generic DMA routine
  134.  127   2                      DMA_Debug_Mode();       
  135.  128   2                      if(     USB_Int_Flag.BITS.EP1RX==1)    //接受数据并显示
  136.  129   2                      {
  137.  130   3                              read_endpoint(2,8,Endpt_FIFO);
  138.  131   3                              DelayNS(1);
  139.  132   3                              ZLG7290_SendBuf(Endpt_FIFO,8);
  140.  133   3                              USB_Int_Flag.BITS.EP1RX=0;
  141.  134   3                      }
  142.  135   2                      if(timecouter==30 )                //定时读取键值,并发送时间(82ms,12MHz,6CLOCK)
  143.  136   2                      {       
  144.  137   3                              DelayNS(1);
  145.  138   3                              Endpt_FIFO[0]=ZLG7290_GetKey();
  146.  139   3                              if(Endpt_FIFO[0]==0) Endpt_FIFO[0]=0xff;
  147.  140   3                              else Endpt_FIFO[0]--;
  148.  141   3                              DelayNS(1);
  149.  142   3                              IRcvStr(0xa2,0x02,&Endpt_FIFO[1],0x3);
  150.  143   3                              Endpt_FIFO[3]=Endpt_FIFO[3]&0x3f;
  151.  144   3                              write_endpoint(3,4,Endpt_FIFO);
  152.  145   3                              timecouter=20;  
  153.  146   3                      }
  154.  147   2              }
  155.  148   1              while(1);
  156.  149   1      }
  157.  150          
  158.  151          /*********************************************************************************************************
  159.  152          ** 函数名称:    DelayNS
  160.  153          ** 功能描述:    长软件延时
  161.  154          ** 输 入: no : 延时参数,值越大时延时越久
  162.  155          **         
  163.  156          ** 输 出: 0 :  OK;
  164.  157          **         1 :  FAIL;
  165.  158          ** 全局变量:    无
  166.  159          ** 调用模块:    无
  167.  160          **
  168.  161          ** 作 者: 叶皓贲
  169.  162          ** 日 期: 2003-3-4
  170.  163          **-------------------------------------------------------------------------------------------------------
  171.  164          ** 修改人:
  172.  165          ** 日 期:
  173.  166          **------------------------------------------------------------------------------------------------------
  174.  167          ********************************************************************************************************/
  175.  168          uchar DelayNS(uchar no)
  176.  169          { 
  177.  170   1              uchar i,j;                                      //延时参数
  178.  171   1      
  179.  172   1              for(; no>0; no--)
  180.  173   1              { 
  181.  174   2                      for(i=0; i<100; i++)
  182.  175   2                      for(j=0; j<100; j++);
  183.  176   2              }
  184.  177   1              return 0; 
  185.  178   1      }
  186.  179          
  187. C51 COMPILER V7.06   KERNEL                                                                07/02/2003 09:29:11 PAGE 4   
  188.  180          //***********************************************************************
  189.  181          //*                                                                                                                                                    *
  190.  182          //*     Routine         : Start_mSEC_Timer(Delay)                                       *
  191.  183          //*     Input           : Delay in milli second                                                                          *  
  192.  184          //*     Output          : Start timer operation                                                    *
  193.  185          //*     Function        : To start the timeout operation based on the delay i/p  *
  194.  186          //*                                                                                                                                                            *
  195.  187          //***********************************************************************
  196.  188          
  197.  189          void Start_mSEC_Timer(Data)
  198.  190          {
  199.  191   1              
  200.  192   1              
  201.  193   1              do
  202.  194   1              {
  203.  195   2                      
  204.  196   2                      //calculate timer value
  205.  197   2                      Temp = Timer.mSEC_Scale;                
  206.  198   2                      Temp = 0xffff - Temp;
  207.  199   2                      
  208.  200   2                      ET0 = 1;
  209.  201   2                      
  210.  202   2                      //calculate timer value
  211.  203   2                      //initialize timer 0 counter
  212.  204   2                      Temp >>= 8;
  213.  205   2                      TH0 = (UC) Temp;
  214.  206   2                      Temp = Timer.mSEC_Scale;                
  215.  207   2                      Temp = 0xffff - Temp;
  216.  208   2                      TL0 = (UC) Temp;
  217.  209   2                      
  218.  210   2                      //start timer count
  219.  211   2                      TR0 = 1;                                                        
  220.  212   2                      
  221.  213   2                      Kernel_Flag.BITS.Timer_Expired = 0;
  222.  214   2                      while(!Kernel_Flag.BITS.Timer_Expired);
  223.  215   2                      Kernel_Flag.BITS.Timer_Expired = 0;
  224.  216   2                      
  225.  217   2                      
  226.  218   2                      //stop timer
  227.  219   2                      TR0 = 0;                                                        
  228.  220   2                      ET0 = 0;
  229.  221   2                      
  230.  222   2                      Data--;
  231.  223   2              }
  232.  224   1              while(Data != 0);
  233.  225   1      }
  234.  226          
  235.  227          
  236. MODULE INFORMATION:   STATIC OVERLAYABLE
  237.    CODE SIZE        =    324    ----
  238.    CONSTANT SIZE    =     13    ----
  239.    XDATA SIZE       =   ----    ----
  240.    PDATA SIZE       =   ----    ----
  241.    DATA SIZE        =      6       5
  242.    IDATA SIZE       =   ----    ----
  243.    BIT SIZE         =   ----    ----
  244. END OF MODULE INFORMATION.
  245. C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)