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