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

📄 usb_isr.c

📁 文件包含了开发motorola mc9s12uf32单片机一些源码。  1、USB device 实现  2、CF卡读取  3、SD卡读取  4、ATA硬盘读取
💻 C
字号:
/******************************************************************************
*                                                  
*  (c) copyright Freescale Semiconductor Hong Kong Ltd 2004
*  ALL RIGHTS RESERVED
*                                                                       
*******************************************************************************  
** THIS  CODE IS ONLY INTENDED AS AN EXAMPLE FOR DEMONSTRATING THE FREESCALE **
** MICROCONTROLLERS.  IT  HAS ONLY BEEN GIVEN A MIMIMUM LEVEL OF TEST. IT IS **
** PROVIDED  'AS  SEEN'  WITH  NO  GUARANTEES  AND  NO  PROMISE  OF SUPPORT. **
*******************************************************************************  
*                                                                           
* FILE:        usb_isr.c	 REVISION 0.1
*  
* DESCRIPTION: This module handles the USB Interrupt Service Routine
*              applicaton tasks for the system
*
* NOTES:       All modules remain at their reset addresses
*                                                  
* UPDATED HISTORY:
*
* REV   YYYY.MM.DD  AUTHOR        DESCRIPTION OF CHANGE
* ---   ----------  ------        --------------------- 
* 0.0   2003.03.01  Vincent Ko    Initial version
* 0.1   2004.04.12  Derek Lau     Demo version
*
******************************************************************************/                                                                        
/* Freescale  is  not  obligated  to  provide  any  support, upgrades or new */
/* releases  of  the Software. Freescale may make changes to the Software at */
/* any time, without any obligation to notify or provide updated versions of */
/* the  Software  to you. Freescale expressly disclaims any warranty for the */
/* Software.  The  Software is provided as is, without warranty of any kind, */
/* either  express  or  implied,  including, without limitation, the implied */
/* warranties  of  merchantability,  fitness  for  a  particular purpose, or */
/* non-infringement.  You  assume  the entire risk arising out of the use or */
/* performance of the Software, or any systems you design using the software */
/* (if  any).  Nothing  may  be construed as a warranty or representation by */
/* Freescale  that  the  Software  or  any derivative work developed with or */
/* incorporating  the  Software  will  be  free  from  infringement  of  the */
/* intellectual property rights of third parties. In no event will Freescale */
/* be  liable,  whether in contract, tort, or otherwise, for any incidental, */
/* special,  indirect, consequential or punitive damages, including, but not */
/* limited  to,  damages  for  any loss of use, loss of time, inconvenience, */
/* commercial loss, or lost profits, savings, or revenues to the full extent */
/* such  may be disclaimed by law. The Software is not fault tolerant and is */
/* not  designed,  manufactured  or  intended by Freescale for incorporation */
/* into  products intended for use or resale in on-line control equipment in */
/* hazardous, dangerous to life or potentially life-threatening environments */
/* requiring  fail-safe  performance,  such  as  in the operation of nuclear */
/* facilities,  aircraft  navigation  or  communication systems, air traffic */
/* control,  direct  life  support machines or weapons systems, in which the */
/* failure  of  products  could  lead  directly to death, personal injury or */
/* severe  physical  or  environmental  damage  (High  Risk Activities). You */
/* specifically  represent and warrant that you will not use the Software or */
/* any  derivative  work of the Software for High Risk Activities.           */
/* Freescale  and the Freescale logos are registered trademarks of Freescale */
/* Semiconductor Inc.                                                        */ 
/*****************************************************************************/


#include	"FreescaleDef.h"			// Get my definitions (Constants & Macros)
#include	"UF32reg.h"			// Get the UF32 registers.
#include	"mk_extern.h"		// Get Mini-Kernel global prototypes
#include	"usb_extern.h"		// Get External variable
#include	"usb_includes.h"	// Get my module Configuration
#include	"usbms_extern.h"
#include	"utl_includes.h"
#include	"app_extern.h"


//============================================================
// The following codes are ISRs for dedicated IRQs.
#pragma CODE_SEG	DEFAULT
#pragma TRAP_PROC


// ===========================================================
//   USB_StatusChgISR() -
//  
//		USB Status Change interrupt service routine.
//
// ===========================================================
void USB_StatusChgISR(void)  
{

	// Check if Suspend status Change
	if(mCheckBit(USSC, UMSR1)) {
		
		UMSR1 = (1<<USSC);
/*
		if mCheckBit(USD, UMSR1) {


			mClearBit(PLLSEL, CLKSEL);		// Select OSC clock as system clock
			mSetBit(SPHY, UMCR);			// Suspend PHY
			mSetBit(RESUMEIE, UIMR);		// Enable resume interrupt mask			EnableInterrupts;				// Clear I bit

			// Light SUSPEND LED
			mSetBit(SUSPEND_LED, PORTI);
//			EnterSTOP;

//			mClearBit(RESUMEIE, UIMR);		// Disable resume interrupt mask
			
		} else {

			mClearBit(RESUMEIE, UIMR);		// Disable resume interrupt mask
			if (mCheckBit(PLLSEL, CLKSEL)==0) {

				mClearBit(SPHY, UMCR);		// Clear Suspend PHY bit
				while (mCheckBit(LOCK,CRGFLG)==0x00);
				mSetBit(PLLSEL, CLKSEL);	// Select PHY clock as system clock				

				// Dark SUSPEND LED		
				mClearBit(SUSPEND_LED, PORTI);
			};
		};		
*/
	} else {
		// Check if Reset status Change
		if(mCheckBit(URSC, UMSR1)) {
		
			if mCheckBit(URD, UMSR1) {
				while (mCheckBit(URD,UMSR1));
				gUSBDebug = UMSR1;
				if (mCheckBit(FULLSPD,UMSR1))
					gUSBFullSpeed = 1;
				else
					gUSBFullSpeed = 0;	
//				mSetBit(MRST, UMCR);	// RESET Module
				USB_ModuleInit();					// Reinit Module
				USB_InitBulkOnlyTransport();		// Reinit Bulk Only transport
			};					
			UMSR1 = (1<<URSC);
								
		} else {
			// Light ERROR LED
			mSetBit(ERROR_LED, PORTT);
		
		};
	};
	

};

#pragma CODE_SEG	DEFAULT
 
#pragma TRAP_PROC

// ===========================================================
//   USB_StartFrameISR() -
//  
//		USB Start Frame interrupt service routine.
//
// ===========================================================
void USB_StartFrameISR(void) 
{

	// Check if Reset status Change
	if(mCheckBit(SOF, UMSR1))
	{
		UMSR1 = (1<<SOF);		
		mSetBit(USSCIE, UIMR);				// Traffic is confirmed, enable USSC interrupt
		mClearBit(SOFIE, UIMR);			// Disable SOF interrupt
	
	} else {
	
		// Light ERROR LED
		mSetBit(ERROR_LED, PORTT);
	};

};

#pragma TRAP_PROC

// ===========================================================
//   USB_SetupISR() -
//  
//		USB Setup interrupt service routine.
//		Setup command involved GET_DESCRIPTOR, class specific
//      or vendor specific command.
//
// ===========================================================
void USB_SetupISR(void) 
{

	if(mCheckBit(SETOVR, UMSR1))
	{					// SETUP override ?
		UMSR1 = (1<<SETOVR);
		USB_DecodeSETUP(&USTB);						// Decode SETUP packet
	}
	else
	{
		if(mCheckBit(SETUP, UMSR1))
		{				// SETUP command ?
			UMSR1 = (1<<SETUP);
			USB_DecodeSETUP(&USTB);					// Decode SETUP packet
		}
	}
	
}

#pragma TRAP_PROC

// ===========================================================
//   USB_SetConfigISR() -
//  
//		USB SET_CONFIGURATION command detected interrupt service routine.
//
// ===========================================================
void USB_SetConfigISR(void) 
{

	if(mCheckBit(SETECR, UCCSR))				// Set_Configuration ?
	{	

		if (mCheckBit(CFGVALID, UCCSR)) {		// Valid Configuration #
			mSetBit(DONEECRU, UCCSR);
			return;
		};

		if (mCheckBit(INTFVALID, UCCSR)) {		// Valid Interface #
			mSetBit(DONEECRU, UCCSR);
			return;
		}

	} else {
	
		// Light ERROR LED
		mSetBit(ERROR_LED, PORTT);
	};


};

#pragma TRAP_PROC

// ===========================================================
//   IsrUsbEnd0IN() -
//  
//		USB Endpoint 0 IN interrupt service routine.
//
// ===========================================================
void USB_EP0INISR(void) 
{

	// Check if Endpoint 0 IN packet detected
	if(mCheckBit(TFRC, UEPCSR0))
	{
	
		UEPCSR0 = 0x3000;			// Clear DVALID, Clear TFRC
		
	} else {
	
		// Light ERROR LED
		mSetBit(ERROR_LED, PORTT);
	};


};

#pragma TRAP_PROC

// ===========================================================
//   USB_EP0OUTISR() -
//  
//		USB Endpoint 0 OUT interrupt service routine.
//
// ===========================================================
void USB_EP0OUTISR(void) 
{

	// Check if Endpoint 0 OUT packet detected
	if(mCheckBit(TFRC, UEPCSR1))
	{
	
		UEPCSR1 = 0x3000;			// Clear DVALID, Clear TFRC

	} else {
	
		// Light ERROR LED
		mSetBit(ERROR_LED, PORTT);
	};

};

#pragma TRAP_PROC

// ===========================================================
//   USB_PhyEP2ISR() -
//  
//		USB Physical Endpoint 2 interrupt service routine.
//
// ===========================================================
void USB_PhyEP2ISR(void) 
{

	// Check if Physical Endpoint 2 packet detected
	if(mCheckBit(TFRC, UEPCSR2))
	{
	
		UEPCSR2 = 0x3000;			// Clear DVALID, Clear TFRC

	} else {
	
		// Light ERROR LED
		mSetBit(ERROR_LED, PORTT);
	};

};

#pragma TRAP_PROC

// ===========================================================
//   USB_PhyEP3ISR() -
//  
//		USB Physical Endpoint 3 interrupt service routine.
//
// ===========================================================
void USB_PhyEP3ISR(void) 
{

	// Check if Physical Endpoint 3 packet detected
	if(mCheckBit(TFRC, UEPCSR3))
	{
	
	} else {
	
		// Light ERROR LED
//		mSetBit(ERROR_LED, PORTI);
	};

};

#pragma TRAP_PROC

// ===========================================================
//   USB_PEndpoint6ISR() -
//  
//		USB Physical Endpoint 6 interrupt service routine.
//
// ===========================================================
void USB_PhyEP6ISR(void) 
{

	// Check if Physical Endpoint 6 acket detected
	if(mCheckBit(TFRC, UEPCSR6))
	{
	
	} else {
	
		// Light ERROR LED
//		mSetBit(ERROR_LED, PORTI);
	};

};



//
// The end of file usb_Isr.c 
// *********************************************************************************

⌨️ 快捷键说明

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