📄 main.c
字号:
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
volatile char which_int=0;
void __irq Key_Int(void)
{
which_int=rEXTINTPND;
rEXTINTPND=0xf; //clear EXTINTPND reg.
rI_ISPC=BIT_EINT4567; //clear pending_bit
switch(which_int)
{
case 1:
Uart_Printf("EINT4 had been occured...\n");
Led_Display(1);
which_int=0;
break;
case 2:
Uart_Printf("EINT5 had been occured...\n");
Led_Display(2);
which_int=0;
break;
case 4:
Uart_Printf("EINT6 had been occured...\n");
Led_Display(4);
which_int=0;
break;
case 8:
Uart_Printf("EINT7 had been occured...\n");
Led_Display(0);
which_int=0;
break;
default :
break;
}
}
void Key_Init(void)
{
rINTCON=0x5;
rINTMOD=0x0; //All=IRQ mode
// rEXTINT=0x22222222; //Falling edge mode
rEXTINT=0x0; //"0" level mode
rPCONG=0xffff; //EINT7~0
rPUPG=0x0; //pull up enable
pISR_EINT4567=(unsigned)Key_Int;
rINTMSK=~(BIT_GLOBAL|BIT_EINT4567); //start 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("\nFS44B0X");
Uart_Printf("\n按键中断演示程序");
Uart_Printf("\n按FS44B0X开发板上的按键 key1 key2 key3 key4!");
Key_Init();
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -