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

📄 eint.c

📁 s3c24a0固件测试代码 ? ? ? ? ?啊 
💻 C
字号:
/*****************************************
  NAME: eint.c
  DESC: External interrupt test
  HISTORY:
  2003.12.30: Baik Seung Woo  ver 0.0
 *****************************************/



#include <string.h>
#include "def.h"
#include "option.h"
#include "24a0addr.h"
#include "24a0lib.h"
#include "24a0slib.h" 
#include "eint.h" 
#include "int.h" 


void * int_func[][2]=
{
	(void *)Test_Eint,				"External Interrupt test",
	(void *)Test_Fiq,				"FIQ Interrupt test",
	(void *)Change_IntPriorities, 	"Change Priority test",
	0,0
};

void Ch6_INTERRUPT_CONTROLLER(void)
{
	while(1)
	{
		int i =0;
  
		while(1)
		{	//display menu
			Uart_Printf("%2d:%s  ",i,int_func[i][1]);
			i++;
			if((int)(int_func[i][0])==0)
			{
				Uart_Printf("\n");
				break;
			}
			if((i%4)==0)
			Uart_Printf("\n");
		}
		
		Uart_Printf("\nSelect (\"-1\" to exit) : ");
		i = Uart_GetIntNum();
		Uart_Printf("\n");
		if(i==-1) break;	 	
		if(i>=0 && (i<(sizeof(int_func)/8)) ) 
		( (void (*)(void)) (int_func[i][0]) )();			
}
}


static void __irq Eint0_1(void)
{
	if(rEINTPEND==(1<<0))
		{
		Uart_Printf("EINT0 interrupt is occured\n");
		rEINTPEND=(1<<0);
		}
	else if(rEINTPEND==(1<<1))
		{
		Uart_Printf("EINT1 interrupt is occured\n");
		rEINTPEND=(1<<1);
		}
	else
		{
		Uart_Printf("rEINTPEND=%x\n",rEINTPEND);
		rEINTPEND=((1<<0)|(1<<1));
		}
	ClearPending(BIT_EINT0_2);
}


static void __irq Eint9(void)
{
	if(rEINTPEND==(1<<9))
		{
		Uart_Printf("EINT9 interrupt is occured\n");
		rEINTPEND=(1<<9);
		}
	else
		{
		Uart_Printf("rEINTPEND=%x\n",rEINTPEND);
		}
	ClearPending(BIT_EINT7_10);
}

static void __irq Eint11(void)
{
	if(rEINTPEND==(1<<11))
		{
		Uart_Printf("EINT11 interrupt is occured\n");
		rEINTPEND=(1<<11);
		}
	else
		{
		Uart_Printf("rEINTPEND=%x\n",rEINTPEND);
		rEINTPEND=(1<<11);
		}
	ClearPending(BIT_EINT11_14);
}


void Test_Eint(void)
{
//    int i;
    char extintMode;

    Uart_Printf("External interrupt test is EINT0/1/9/11\n");
    Uart_Printf("1.L-evel   2.H-evel   3.F-edge   4.R-edge 5.B-edge\n");
    Uart_Printf("Select the external interrupt type.\n");
    extintMode=Uart_Getch();
    Uart_Printf("%c is selected\n",extintMode);

    rGPCON_M = (rGPCON_M & 0xfffc)|(0x2<<0);
    rGPCON_L = (rGPCON_L & 0x33fff0)|(0x2<<18)|(0x2<<2)|(0x2<<0);

	switch(extintMode)
		{
		case '1':
			rEXTINTC0=rEXTINTC0 & ~((7<<4)|(7<<0))|(0x0<<4)|(0x0<<0);
			rEXTINTC1=rEXTINTC1 & ~(7<<24)|(0x0<<24);
			rEXTINTC2=rEXTINTC2 & ~(7<<0)|(0x0<<0);
			rEINTFLT0=rEINTFLT0 &~ (0x7f<<0)|(0x30<<0);
			break;
			
		case '2':
			rEXTINTC0=rEXTINTC0 & ~((7<<4)|(7<<0))|(0x1<<4)|(0x1<<0);
			rEXTINTC1=rEXTINTC1 & ~(7<<24)|(0x1<<24);
			rEXTINTC2=rEXTINTC2 & ~(7<<0)|(0x1<<0);
			rEINTFLT0=rEINTFLT0 &~ (0x7f<<0)|(0x30<<0);
			break;
			
        case '3':
			rEXTINTC0=rEXTINTC0 & ~((7<<4)|(7<<0))|(0x2<<4)|(0x2<<0);
			rEXTINTC1=rEXTINTC1 & ~(7<<24)|(0x2<<24);
			rEXTINTC2=rEXTINTC2 & ~(7<<0)|(0x2<<0);
			rEINTFLT0=rEINTFLT0 &~ (0x7f<<0)|(0x30<<0);
			break;    

        case '4':
			rEXTINTC0=rEXTINTC0 & ~((7<<4)|(7<<0))|(0x4<<4)|(0x4<<0);
			rEXTINTC1=rEXTINTC1 & ~(7<<24)|(0x4<<24);
			rEXTINTC2=rEXTINTC2 & ~(7<<0)|(0x4<<0);
			rEINTFLT0=rEINTFLT0 &~ (0x7f<<0)|(0x30<<0);
			break;

        case '5':
			rEXTINTC0=rEXTINTC0 & ~((7<<4)|(7<<0))|(0x6<<4)|(0x6<<0);
			rEXTINTC1=rEXTINTC1 & ~(7<<24)|(0x6<<24);
			rEXTINTC2=rEXTINTC2 & ~(7<<0)|(0x6<<0);
			rEINTFLT0=rEINTFLT0 &~ (0x7f<<0)|(0x30<<0);
			break;

		default:
			break;
		}

	pISR_EINT0_2=(U32)Eint0_1;
	pISR_EINT7_10=(U32)Eint9;
	pISR_EINT11_14=(U32)Eint11;


	rEINTPEND = 0xffffff;
    rSRCPND = BIT_EINT0_2|BIT_EINT7_10|BIT_EINT11_14; //to clear the previous pending states
    rINTPND = BIT_EINT0_2|BIT_EINT7_10|BIT_EINT11_14;
    
    rEINTMASK=~( (1<<0)|(1<<1)|(1<<9)|(1<<11) );
    rINTMSK=~(BIT_EINT0_2|BIT_EINT7_10|BIT_EINT11_14);
		
    Uart_Getch();
    
    rEINTMASK=0xffffff;
    rINTMSK=BIT_ALLMSK;
}

⌨️ 快捷键说明

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