main.c

来自「S3C44B0X 外部中断的开发应用」· C语言 代码 · 共 73 行

C
73
字号
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"

static U32 ExintCnt=0;
static int LedStatus=0;

void __irq Exint_Key(void)
{	
	U32 Exint_Status;

	Exint_Status=rEXTINTPND;
	rEXTINTPND=0xffffffff;
    rI_ISPC=BIT_EINT4567;
	if (ExintCnt++ ==30000)
	{
		ExintCnt=0;
		Exint_Status &=0x0f;
		switch (Exint_Status)
		{
			case	1:
					Uart_Printf("\nKEY0 interrupt... ");
					break;
			case	2:
					Uart_Printf("\nKEY1 interrupt... ");
					break;
			case	4:
					Uart_Printf("\nKEY2 interrupt... ");
					break;
			case	8:
					Uart_Printf("\nKEY3 interrupt... ");
					break;
			default	:
					Uart_Printf("\nKEY interrupt... ");
					break;
		}
	}
    
}
void Inter_Init(void)
{
    rINTCON=0x5;    //Non-vectored,IRQ enable,FIQ disable 
    rINTMOD=0x0;    //All=IRQ mode
    
    pISR_EINT4567=(unsigned)Exint_Key;
    rINTMSK=BIT_GLOBAL;
    rINTMSK=~(BIT_GLOBAL|BIT_EINT4567);	//start timer INT
}

void Main(void)
{
    rSYSCFG=CACHECFG;   // Using 8KB Cache//

    Port_Init();
    Uart_Init(0,57600);
    Delay(10);
    Uart_Select(0); //Select UART0
    Led_Display(0x07);
    
    Uart_Printf("\nSXHC44B0 EXINT INTERRUPT ");
    Uart_Printf("\n外部中断DEMO");
    Uart_Printf("\n请按KEY0到KEY3中的任意键");
    
    Inter_Init();
    while(1)
	{
		Delay(5000);
		Led_Display(LedStatus);
		LedStatus=(~(LedStatus)&0x7);
	}
}

⌨️ 快捷键说明

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