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

📄 kernel.c

📁 基于USB2.0芯片 ISP1581 的扫描仪固件源码,USB驱动模块
💻 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"

//***********************************************************************
//*																		               *
//*	                 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 volatile D14_CNTRL_REG	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 UC VID[2],PID[2];
extern UC	idata Endpt_FIFO[64];
extern Set_USB(void);
extern TIMER	Timer;
//***********************************************************************
//*																		               *
//*	                 Prototype routine Definition					 	   *
//*																		               *
//***********************************************************************

void Start_mSEC_Timer(Data);
void Start_SEC_Timer(Data);

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

UI	Temp;
KERNEL Kernel_Flag;


//***********************************************************************
//*																		               *
//*	                     Routine Definition								   *
//*																		               *
//***********************************************************************

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

void Main(void)
{

   //Initialization routine
	Init_Main();			

   //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);

}



//***********************************************************************
//*										    							               *
//*	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);
}

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

void Start_SEC_Timer(Data)
{


	Data *= 100;
		
	do
	{

      //calculate timer value
		Temp = Timer.Hundred_mSEC_Scale; 	
		Temp = 0xffff - Temp;


      //set to crystal clocking
		//set to timer mode
		//select 16 bit timer
		TMOD = 0x01;		

		ET0 = 1;

      //calculate timer value
      //initialize timer 0 counter
		Temp >>= 8;
		TH0 = (UC) Temp;
		Temp = Timer.Hundred_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 + -