📄 main.c
字号:
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
static void __irq Eint0_ISR(void)
{
ClearPending(BIT_EINT0);
Uart_Printf("EINT0 is occurred.\n");
}
static void __irq Eint2_ISR(void)
{
ClearPending(BIT_EINT2);
Uart_Printf("EINT2 is occurred.\n");
}
static void __irq Eint11_19_ISR(void)
{
if(rEINTPEND & (1<<11))
{
Uart_Printf("EINT11 is occurred.\n");
rEINTPEND=(1<<11);
ClearPending(BIT_EINT8_23);
}
else if(rEINTPEND & (1<<19))
{
Uart_Printf("EINT19 is occurred.\n");
rEINTPEND=(1<<19);
ClearPending(BIT_EINT8_23);
}
else
{
Uart_Printf("others ENTs are occurred\n");
rEINTPEND=0xffffff;
ClearPending(BIT_EINT8_23);
}
}
void xmain(void)
{
ChangeClockDivider(3,1);
ChangeMPllValue(127,2,1); //405MHZ
Isr_Init();
Uart_Init(0, 115200);
Uart_Select(0);
Uart_Printf("the main is running\n");
rGPFCON = (rGPFCON & ~((3<<4)|(3)))|(1<<5)|(1<<1); //GPF0/2 = EINT0/2
rGPGCON = (rGPGCON & ~((3<<22)|(3<<6)))|(1<<23)|(1<<7); //GPG3/11 = EINT11/19
rEXTINT0 = (rEXTINT0 & ~(7<<8))|(2<<8); //EINT0/2=falling edge triggered
rEXTINT0 = (rEXTINT0 & ~(7<<0))|(2<<0);
rEXTINT1 = (rEXTINT1 & ~(7<<12))|(0x2<<12); //EINT11=falling edge triggered
rEXTINT2 = (rEXTINT2 & ~(7<<12))|(0x2<<12); //EINT19=falling edge triggered
pISR_EINT0=(U32)Eint0_ISR;
pISR_EINT2=(U32)Eint2_ISR;
pISR_EINT8_23=(U32)Eint11_19_ISR;
rEINTPEND = 0xffffff;
rSRCPND |= BIT_EINT0|BIT_EINT2|BIT_EINT8_23; //to clear the previous pending states
rINTPND |= BIT_EINT0|BIT_EINT2|BIT_EINT8_23;
rEINTMASK=~( (1<<11)|(1<<19) );
rINTMSK=~(BIT_EINT0|BIT_EINT2|BIT_EINT8_23);
while(1)
{
Uart_Printf("the main is running\n");
Delay(100000);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -