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

📄 intrpt.c

📁 ISP1583 Mass Storgae Firmware
💻 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"

extern KERNEL Kernel_Flag;
extern volatile D14_CNTRL_REG	xdata	D14_Cntrl_Reg;

extern DMA_INT_FLAG DMA_Int_Flag;
extern USB_INT_FLAG USB_Int_Flag;
extern void Init_D14(void);
extern UC ATAPI_State;
extern DRIVE_CONFIG	Drive_Setup;
extern UI Temp;
extern void Init_Endpoint(void);
extern USB_DEVICE USB_Device;

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

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

void Int_2(void) interrupt 2 using 0
{
	EX1 = 0;

	if(USB_Device.BITS.Remote_Wakeup)
		{

		D14_Cntrl_Reg.D14_UNLOCK_DEVICE_LSB = 0x37;
		D14_Cntrl_Reg.D14_UNLOCK_DEVICE_MSB = 0xAA;

		D14_Cntrl_Reg.D14_MODE.BITS.SNDRSU = 1;
		D14_Cntrl_Reg.D14_MODE.BITS.SNDRSU = 0;
		}
}

void Int_3(void) interrupt 3 using 0
{
}

void Int_4(void) interrupt 4 using 0
{
}

void Int_5(void) interrupt 5 using 0
{
}

//***********************************************************************
//*										    							               *
//*	Routine 	: Int_Timer0                                      		   *
//*	Input		: Timer 0 overflow  									            *
//*	Output		: Set time up flag                    					   *
//*	Function	: To set the time up flag                   			      *
//*																		               *
//***********************************************************************

void Int_Timer0(void) interrupt 1 using 0
{

	Kernel_Flag.BITS.Timer_Expired = 1;
}

//***********************************************************************
//*										    							               *
//*	Routine 	:  Int Ext 0                                       		*
//*	Input		:  External Interrupt from ISP1581                       *
//*	Output	:  None                                 					   *
//*	Function	:  To read and keep a copy of the interrupt source of    *
//*				   ISP1581														      *
//***********************************************************************

void Int_Ext_0(void) interrupt 0 using 1
{
   //unlock Device
   D14_Cntrl_Reg.D14_UNLOCK_DEVICE_LSB = 0x37;
   D14_Cntrl_Reg.D14_UNLOCK_DEVICE_MSB = 0xAA;

   //read in USB interrupt register and keep a copy
   USB_Int_Flag.VALUE |= (D14_Cntrl_Reg.D14_INT.VALUE & D14_Cntrl_Reg.D14_INT_ENABLE.VALUE);

   //read in DMA interrupt register and keep a copy
   //then clear interrupt source
   DMA_Int_Flag.VALUE |= (D14_Cntrl_Reg.D14_DMA_INT.VALUE & 0x1E02);
   D14_Cntrl_Reg.D14_DMA_INT.VALUE = DMA_Int_Flag.VALUE;		
         
   //clear interrupt
	D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;	      	

   //check for INTRQ if seen clear INTRQ
   if(DMA_Int_Flag.BITS.INTRQ_SEEN && DMA_Int_Flag.BITS.CMD_INTRQ_OK)
	   Temp = D14_Cntrl_Reg.D14_CMD_STATUS_TASKFILE;

   //check if bus reset has occur               
	if(USB_Int_Flag.BITS.RESET)
	{

    
   
      //check if the IDe device is in read or write phase
      //if bus reset occur during that phase,error has occur
      //this is used for error recovery
      USB_Int_Flag.BITS.RESET = 0;
      USB_Int_Flag.BITS.SUSP = 0;
      USB_Int_Flag.BITS.RESUME = 0;
      Kernel_Flag.BITS.Bus_Reset = 1;
      Kernel_Flag.BITS.Device_Init = 0;
                                                
      //turn off high speed LED                           
		HS_FS_LED = FULL_SPEED_LED;

      //reset device to full speed state
		Kernel_Flag.BITS.HS_FS_State = FULL_SPEED;


	D14_Cntrl_Reg.D14_MODE.BITS.DMACLKON = 1;
	//set all interrupt source to mode 1
   	D14_Cntrl_Reg.D14_INT_CONFIG.VALUE = 0x54;			


	D14_Cntrl_Reg.D14_INT_ENABLE.VALUE = 0xF9090000;	


   	//initialize the config and hardware register to
   	//set ISP1581 to ATAPI bridge mode
	D14_Cntrl_Reg.D14_DMA_CONFIG.VALUE = 0x0122;
   
   	//enable DMA interrupt
	D14_Cntrl_Reg.D14_DMA_INT_ENABLE.VALUE = 0x1E02;      

	Init_Endpoint();

   }
   
	if(USB_Int_Flag.BITS.DMA)
		USB_Int_Flag.BITS.DMA = 0;
      
      
   if(USB_Int_Flag.BITS.VBUS && Kernel_Flag.BITS.Drive_Detected)
   {
      USB_Int_Flag.BITS.VBUS = 0;
      USB_Int_Flag.BITS.SUSP = 0;
      USB_Int_Flag.BITS.RESUME = 0;
      D14_Cntrl_Reg.D14_MODE.BITS.SOFTCT = 1;
   }
   
   if(USB_Int_Flag.BITS.SUSP && USB_Int_Flag.BITS.RESUME)
   {
      USB_Int_Flag.BITS.SUSP = 0;
      USB_Int_Flag.BITS.RESUME = 0;
   }
            

}	

⌨️ 快捷键说明

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