www.pudn.com > Source_program.rar > Eint.c


#include  
#include "..\Target\44b.h" 
#include "..\Target\44blib.h" 
#include "eint.h" 
 
void __irq Eint4567Isr(void); 
 
volatile char which_int=0; 
 
void Test_Eint(void) 
{ 
    unsigned int save_G,save_PG; 
 
    Uart_Printf("\n[External Interrupt Test]\n"); 
    Uart_Printf("Note:Because Keyboard's pressing exist shake,many times\n"); 
    Uart_Printf("of interrupt maybe triggered.\n"); 
/***Vectored interrupt test***/ 
    rINTCON=0x1;//disable fiq, enable irq 
 
    pISR_EINT4567=(int)Eint4567Isr; 
     
//    rINTMSK=~(BIT_GLOBAL|BIT_EINT4567);   
 
    Uart_Printf("...Select the trigger:\n" 
	"  1. Falling trigger\n" 
	"  2. Rising trigger\n" 
	"  3. Both Edge trigger\n"  
	"  4. Low level trigger\n" 
	"  5. High level trigger\n"); 
 
    save_G=rPCONG; 
    save_PG=rPUPG; 
    rPCONG=0xffff;	//EINT7~0 
    rPUPG=0x0;		//pull up enable	     
 
    switch(Uart_Getch()) 
    { 
	case '1': 
	    rEXTINT=0x22222222; //Falling edge mode  
	    break; 
	case '2': 
	    rEXTINT=0x44444444; //Rising edge mode 
	    break; 
	case '3': 
	    rEXTINT=0x77777777; //Both edge mode 
	    break; 
	case '4': 
	    rEXTINT=0x0;	//"0" level mode 
	    break; 
	case '5': 
	    Uart_Printf("In this board EINT2 and EINT5 are pulled up\n");//rEXTINT=0x11111111; //"1" level mode 
	    which_int=10; 
	    break; 
	default: 
	    rPCONG=save_G; 
	    rPUPG=save_PG; 
	    return; 
    } 
 
//    Uart_Printf("\nDEMO B/D push buttons may have glitch noise problem.\n"); 
    Uart_Printf("Press the EINT buttons!!!\n"); 
    rINTMSK=~(BIT_GLOBAL|BIT_EINT2|BIT_EINT4567);   
 
    while(!which_int); 
 
    switch(which_int) 
    { 
	case 1: 
	    Uart_Printf("EINT4 had been occured...\n"); 
	    break; 
	case 2: 
	    Uart_Printf("EINT5 had been occured...\n"); 
	    break; 
	case 4: 
	    Uart_Printf("EINT6 had been occured...\n"); 
	    break; 
	case 8: 
	    Uart_Printf("EINT7 had been occured...\n"); 
	    break; 
	case 9: 
	    Uart_Printf("EINT2 had been occured...\n"); 
	    break; 
	default : 
	    Uart_Printf("which_int=%d\n",which_int); 
	    break; 
    } 
 
    rINTMSK=BIT_GLOBAL; 
    rPCONG=save_G; 
    rPUPG=save_PG; 
    which_int=0; 
     
    //Uart_Printf("\nrINTCON=0x%x\n",rINTCON); 
    rINTCON=0x5; 
} 
 
 
void __irq Eint4567Isr(void) 
{ 
    which_int=rEXTINTPND; 
    rEXTINTPND=0x0f;		//clear EXTINTPND reg.		 
    rI_ISPC=BIT_EINT4567;	//clear pending_bit 
}