extint.c

来自「arm7s3c44b0x0里ps2口和lcd口驱动编程实例」· C语言 代码 · 共 64 行

C
64
字号
/*========================================================*/
//Destription: External Interrupt Test
/*========================================================*/
 
#include <string.h>
#include "\inc\define.h"
#include "\inc\drives.h"
#include "\inc\extint.h"

void __irq ExtInt4567Isr(void);
volatile char which_int=0;

/*=======================================================*/
//ExtIntInit() initialize the registers and port
/*=======================================================*/
void ExtIntInit(void)                                       
{ 
	rPCONG = 0xffff;					//EINT7~0
    rPUPG = 0x0;    
    rINTMSK &= ~BIT_EINT4567;      
    rEXTINT=0x22222222; 				//Falling edge mode        
    pISR_EINT4567=(int)ExtInt4567Isr;	    
    puts("       \nPlease press the four buttons on the board!\n       ");    
}


/*=======================================================*/
//ExtIntRpt() report the external interrupt information
/*=======================================================*/
void ExtIntRpt(void)
{
	switch(which_int)
    {
	case 1:
	    puts("EINT4 had been occured...\n");
	    which_int = 0;   
	    break;
	case 2:
	    puts("EINT5 had been occured...\n");
	    which_int = 0;   
	    break;
	case 4:
	    puts("EINT6 had been occured...\n");
	    which_int = 0;   
	    break;
	case 8:
	    puts("EINT7 had been occured...\n");
	    which_int = 0;   
	    break;	
	default :	    
	    break;
    }    
}

/*=======================================================*/
//__irq Eint4567Isr() is the ISR of external interrupt 4567
/*=======================================================*/
void __irq ExtInt4567Isr(void)
{
    which_int = rEXTINTPND;
    rEXTINTPND = 0x0f;				//clear EXTINTPND reg.		
    rI_ISPC = BIT_EINT4567;			//clear pending_bit
}

⌨️ 快捷键说明

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