⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kernel.c

📁 周立功dp1581usb2.0实验仪
💻 C
字号:
//***********************************************************************
//									     								                  *
//                P H I L I P S   P R O P R I E T A R Y          		   *
//                                                                      *
//          COPYRIGHT (c)   1999 BY PHILIPS SINGAPORE (APIC).    		   *
//                    --  ALL RIGHTS RESERVED  --                 		*	
//                                                                      *
// 	File Name	:       Kernel.c                                      *
// 	Author		:       Albert Goh					 					      *
// 	Created		:      	3 March 2000                               	*
//                  	                                                   *
//***********************************************************************
//***********************************************************************
//                                                                      *
// Kernel.c is the control centre for this evaluation firmware. It will *
// control where should the firmware branch through via the selection 	*
// of the UART port of the 8051. if not via the UART, it will be from 	*
// the selection of the code defintion                                  *
//                                                                      *
//***********************************************************************
//***********************************************************************
//                                                                      *
//  Module History														            *  
//  **************														            *
//																		                  *
//  Date   	Version			Author				Changes					      *
//  ====	=======			======				=======					         *
//  030300	  0.1 			Albert				Created    				      *
//                                                                      *
//                                                                      *
//***********************************************************************
//***********************************************************************
//*																		               *
//*	                     Include Files Definition						   *
//*																		               *
//***********************************************************************

#include "standard.h"
#include "Kernel.h"
#include "D14.h"
#include "zlg7289.h"
#include "VIIC_C51.h"

//***********************************************************************
//*																		               *
//*	                 External routine Definition					 	      *
//*																		               *
//***********************************************************************

extern Init_Main();
extern USB_Debug_Mode();
extern DMA_Debug_Mode();
extern USB_INT_FLAG USB_Int_Flag;
extern DMA_INT_FLAG DMA_Int_Flag;
extern USB_DEVICE USB_Device;
extern  D14_CNTRL_REG	volatile xdata	 D14_Cntrl_Reg;
extern void Check_Busy(void);
extern void Init_D14(void);
extern void Init_Endpoint(void);
extern void Init_Device(void);
extern void Get_PIDVID(void);
//extern unsigned int read_endpoint(unsigned char endp,unsigned int len,unsigned char *buf);
//extern unsigned int write_endpoint(unsigned char endp,unsigned int len,unsigned char *buf);
extern UC VID[2],PID[2];
extern UC	idata Endpt_FIFO[MAX_BUF];
extern Set_USB(void);
extern TIMER	Timer;
extern UC 	timecouter;
//***********************************************************************
//*																		               *
//*	                 Prototype routine Definition					 	   *
//*																		               *
//***********************************************************************

void Start_mSEC_Timer(Data);
void Start_SEC_Timer(Data);
uchar DelayNS(uchar no);

//***********************************************************************
//*																		               *
//*	                     Variable Definition 							      *
//*																		               *
//***********************************************************************

UI	Temp;
KERNEL Kernel_Flag;
uchar code disp_buf[8]={0,0,0,0,0,0,0,0};		//LED初始化值
//UC key=0xff;
//***********************************************************************
//*																		               *
//*	                     Routine Definition								   *
//*																		               *
//***********************************************************************

//***********************************************************************
//*										    							               *
//*	Routine 	:  Main                                          		   *
//*	Input		:  None            									            *
//*	Output   :	None                                  					   *
//*	Function	:	main loop                                			      *
//*																		               *
//***********************************************************************

void Main(void)
{
	Init_Main();			
	DelayNS(5);
	ZLG7289_Rest();		// 复位ZLG7289
    DelayNS(5);
	//Initialization routine
	//初始化子程序
	ZLG7289_SendBuf(disp_buf);
	
	//enable device and reset the device address
	D14_Cntrl_Reg.D14_MODE.BITS.SOFTCT = 1;	
	
	do
	{		
		//USB routine
		USB_Debug_Mode();
		
		//Generic DMA routine
		DMA_Debug_Mode();

	}
	while(1);
}

/*********************************************************************************************************
** 函数名称: 	DelayNS
** 功能描述: 	长软件延时
** 输 入: no :	延时参数,值越大时延时越久
**         
** 输 出: 0 :	OK;
**         1 :	FAIL;
** 全局变量:	无
** 调用模块: 	无
**
** 作 者: 叶皓贲
** 日 期: 2003-3-4
**-------------------------------------------------------------------------------------------------------
** 修改人:
** 日 期:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
uchar DelayNS(uchar no)
{ 
	uchar i,j;					//延时参数

  	for(; no>0; no--)
  	{ 
		for(i=0; i<100; i++)
     		for(j=0; j<100; j++);
  	}
  	return 0; 
}

//***********************************************************************
//*										    							               *
//*	Routine 	: Start_mSEC_Timer(Delay)                          		*
//*	Input		: Delay in milli second									         *  
//*	Output		: Start timer operation               					   *
//*	Function	: To start the timeout operation based on the delay i/p  *
//*																		               *
//***********************************************************************

void Start_mSEC_Timer(Data)
{
	
   	
	do
	{
		
		//calculate timer value
		Temp = Timer.mSEC_Scale;		
		Temp = 0xffff - Temp;
		
		ET0 = 1;
		
		//calculate timer value
		//initialize timer 0 counter
		Temp >>= 8;
		TH0 = (UC) Temp;
		Temp = Timer.mSEC_Scale;		
		Temp = 0xffff - Temp;
		TL0 = (UC) Temp;
		
		//start timer count
		TR0 = 1;							
		
		Kernel_Flag.BITS.Timer_Expired = 0;
		while(!Kernel_Flag.BITS.Timer_Expired);
		Kernel_Flag.BITS.Timer_Expired = 0;
		
		
		//stop timer
		TR0 = 0;							
		ET0 = 0;
		
		Data--;
	}
	while(Data != 0);
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -