📄 jianpan.c
字号:
#include "2410addr.h"
#include "2410lib.h"
#include "timer.h"
void __irq keyscan()
{
Delay(1000);
if(rINTPND==BIT_EINT8_23)
{
Uart_Printf("coming into the 8_23 \n");
ClearPending(BIT_EINT8_23); //clear EINT8_23 in INTPND and SRCPND
//if((rEINTPEND&(1<<11))&((rGPEDAT&(1<<11))))
if((rEINTPEND&(1<<11)))
{
if((rGPEDAT&(1<<11))==0)
{
Uart_Printf("The key is 4\n");
rEINTPEND |= 1<< 11; //clear EINT11 in EINTPND
Delay(900);
ClearPending(BIT_EINT8_23); //clear EINT8_23 in INTPND and SRCPND
}
if((rGPGDAT&(1<<6))==0)
{
Uart_Printf("The key is 5\n");
rEINTPEND |= 1<< 11; //clear EINT11 in EINTPND
Delay(900);
ClearPending(BIT_EINT8_23); //clear EINT8_23 in INTPND and SRCPND
}
if((rGPEDAT&(1<<13))==0)
{
Uart_Printf("The key is 6\n");
rEINTPEND |= 1<< 11; //clear EINT11 in EINTPND
Delay(900);
ClearPending(BIT_EINT8_23); //clear EINT8_23 in INTPND and SRCPND
}
if((rGPGDAT&(1<<2))==0)
{
Uart_Printf("The key is 14\n");
rEINTPEND |= 1<< 11; //clear EINT11 in EINTPND
Delay(900);
ClearPending(BIT_EINT8_23); //clear EINT8_23 in INTPND and SRCPND
}
}
}
//////////////////////////////////////////////////////////////////////////////////
if(rEINTPEND&(1<<19))
{
if((rGPEDAT&(1<<11))==0)
{
Uart_Printf("The KEY is 1\n");
rEINTPEND |= 1<<19; //clear EINT19 in EINTPND
Delay(900);
ClearPending(BIT_EINT8_23); //clear EINT8_23 in INTPND and SRCPND
}
if((rGPGDAT&(1<<6))==0)
{
Uart_Printf("The KEY is 2\n");
rEINTPEND |= 1<<19; //clear EINT19 in EINTPND
Delay(900);
ClearPending(BIT_EINT8_23); //clear EINT8_23 in INTPND and SRCPND
}
if((rGPEDAT&(1<<13))==0)
{
Uart_Printf("The KEY is 3\n");
rEINTPEND |= 1<<19; //clear EINT19 in EINTPND
Delay(900);
ClearPending(BIT_EINT8_23); //clear EINT8_23 in INTPND and SRCPND
}
if((rGPGDAT&(1<<2))==0)
{
Uart_Printf("The KEY is 13\n");
rEINTPEND |= 1<<19; //clear EINT19 in EINTPND
Delay(900);
ClearPending(BIT_EINT8_23); //clear EINT8_23 in INTPND and SRCPND
}
}
//////////////////////////////////////////////////////////////////////////////////////////
else if(rINTPND==BIT_EINT0)
{
Uart_Printf("coming into the EIT0 \n");
ClearPending(BIT_EINT0); //clear EINT0 in INTPND and SRCPND
//if((rGPEDAT&(1<<11))==0)
if((rGPEDAT&(1<<11))==0)
{
Uart_Printf("The KEY is 10\n");
Delay(900);
}
else if((rGPGDAT&(1<<6))==0)
{
Uart_Printf("The KEY is 11\n");
Delay(900);
}
else if((rGPEDAT&(1<<13))==0)
{
Uart_Printf("The KEY is 12\n");
Delay(900);
}
else if((rGPGDAT&(1<<2))==0)
{
Uart_Printf("The KEY is 16\n");
Delay(900);
}
}
/////////////////////////////////////////////////////////////
else if(rINTPND==BIT_EINT2)
{
Uart_Printf("coming into the EIT2 \n");
ClearPending(BIT_EINT2); //clear EINT2 in INTPND and SRCPND
if((rGPEDAT&(1<<11))==0)
{
Uart_Printf("The KEY is 7\n");
Delay(900);
}
if((rGPGDAT&(1<<6))==0)
{
Uart_Printf("The KEY is 8\n");
Delay(900);
}
if((rGPEDAT&(1<<13))==0)
{
Uart_Printf("The KEY is 9\n");
Delay(900);
}
if((rGPGDAT&(1<<2))==0)
{
Uart_Printf("The KEY is 15\n");
Delay(900);
}
}
////////////////////////////////////////////////////////////////////////////
}
void ent_int()
{
rEXTINT0 = (rEXTINT0 & ~(7<<0))|(2<<0); //EINT0 ->falling edge triggered
rEXTINT0 = (rEXTINT0 & ~(7<<8))|(2<<8); //EINT2 ->falling edge triggered
rEXTINT1 = (rEXTINT1 & ~(7<<12))|(0x2<<12); //EINT11->falling edge triggered
rEXTINT2 = (rEXTINT2 & ~(7<<12))|(0x2<<12); //EINT19->falling edge triggered
rEINTPEND = 0xffffff; //to clear the previous pending states
//rSRCPND |= BIT_EINT0|BIT_EINT2|BIT_EINT8_23;//
//rINTPND |= BIT_EINT0|BIT_EINT2|BIT_EINT8_23;
rEINTMASK=~( (1<<11)|(1<<19) );
rINTMSK=~(BIT_EINT0|BIT_EINT2|BIT_EINT8_23);
}
int Main()
{
SetClockDivider(1, 1);//FLCK:HCLK:PCLK=1:2:4
SetSysFclk(DFT_FCLK_VAL);//Fout=200MHZ
Port_Init();
Uart_Select(0);
Uart_Init(0, UART_BAUD);
Uart_Printf("Please push the key\n");
rGPECON = (rGPECON|(3<<22)) & ~(2<<22);
rGPEUP |= (1<<11);//KEYSCAN0 pull up
rGPECON = (rGPECON|(3<<26)) & ~(2<<26);
rGPEUP |= (1<<13);//KEYSCAN1 pull up
rGPGCON = (rGPGCON|(3<<12)) & ~(2<<12);
rGPGUP |= (1<<6);//KEYSCAN2 pull up
rGPGCON = (rGPGCON|(3<<4)) & ~(2<<4);
rGPGUP |= (1<<2);//KEYSCAN3 pull up
rGPFCON = rGPFCON & ~(3)|(1<<1); //GPF0 设置为EINT0
rGPFCON = rGPFCON & ~(3<<4)|(1<<5); //GPF2 设置为EINT2
rGPGCON = rGPGCON & ~(3<<6)|(1<<7); //GPG3 设置为EINT11
rGPGCON = rGPGCON & ~(3<<22)|(1<<23); //GPG11 设置为EINT19
rGPFUP|=(1<<0); //disable GPF0 pull up
rGPFUP|=(1<<2); //disable GPF2 pull up
rGPGUP|=(1<<3); //disable GPG3 pull up
rGPGUP|=(1<<11); //disable GPG11 pull up
ent_int();
pISR_EINT0=(unsigned)keyscan;
pISR_EINT2=(unsigned)keyscan;
pISR_EINT8_23=(unsigned)keyscan;
while(1)
{
rGPGDAT|=(1<<2)|(1<<6);
rGPEDAT|=(1<<11)|(1<<13);
rGPGDAT=(rGPGDAT&(0<<2))|(1<<6);
Delay(50);
rGPGDAT|=(1<<2)|(1<<6);
rGPEDAT|=(1<<11)|(1<<13);
rGPGDAT=rGPGDAT&(0<<6)|(1<<2);
Delay(50);
rGPGDAT|=(1<<2)|(1<<6);
rGPEDAT|=(1<<11)|(1<<13);
rGPEDAT=rGPEDAT&(0<<11)|(1<<13);
Delay(50);
rGPGDAT|=(1<<2)|(1<<6);
rGPEDAT|=(1<<11)|(1<<13);
rGPEDAT=rGPGDAT&(0<<13)|(1<<11);
Delay(50);;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -