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

📄 kernel.c

📁 是ISP1581 单片机 应用源码
💻 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"
#include "init.h"
#include "global.h"
#include "chap_9.h"


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

uchar code td[5]={0x00,0x12,0x48,0x30,0x12};   //8563初始化值
uchar code disp_buf[8]={0,0,0,0,0,0,0,0};		//LED初始化值


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

void Main(void)
{
	unsigned char time_send;

	DelayNS(5);
	ISendStr(0xa2,0,td,0x5);
	ZLG7289_Rest();		// 复位ZLG7289
    DelayNS(5);
	//Initialization routine
	//初始化子程序
	ZLG7289_SendBuf(disp_buf);
	Init_Main();			

	time_send = 0;
	
	//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();	
		if(	USB_Int_Flag.BITS.EP2RX==1)    //接受数据并显示
		{
			read_endpoint(4 /*2 by xdkui*/,8,Endpt_FIFO);
			ZLG7289_SendBuf(Endpt_FIFO);
			USB_Int_Flag.BITS.EP2RX=0;
		}
		if(timecouter > 30  && Device_Config_Value > 0 )                //定时读取键值,并发送时间(82ms,12MHz,6CLOCK)
		{
			EA_DISABLE;
			Endpt_FIFO[0]=ZLG7289_GetKey();
			//IRcvStr(0xa2,0x02,&Endpt_FIFO[1],0x3);
			//Endpt_FIFO[3]=Endpt_FIFO[3]&0x3f;
			Endpt_FIFO[1]=1;
			Endpt_FIFO[2]=2;
			Endpt_FIFO[3]=3;
			write_endpoint(5/*3* by xdkui*/,4,Endpt_FIFO);
			timecouter=20;	
			time_send=1;
			EA_ENABLE;
		}
	}
	while(1);
}

/*********************************************************************************************************
** 函数名称: 	DelayNS
** 功能描述: 	长软件延时
** 输 入: no :	延时参数,值越大时延时越久
**         
** 输 出: 0 :	OK;
**         1 :	FAIL;
** 全局变量:	无
** 调用模块: 	无
**
** 作 者: 叶皓贲
** 日 期: 2003-3-4
**-------------------------------------------------------------------------------------------------------
** 修改人:
** 日 期:
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
UC DelayNS(UC 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(UL 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 + -