|
扩展IO口来驱动矩阵键盘 GPG1,3,5,7接列线,作为中断,EXTINT9,11,13,15;
GPE11,13 GPB8,6接行线 相关程序部分如下: 将程序下载到开发板上之后,4×4键盘中只要有一个键按下,就一直产生中断,串口上一直打印eint×,不知道原因?
static void __irq Key_ISR(void)
{U32 r;
EnterCritical(&r);
if(rINTPND==BIT_EINT8_23)
{
Uart_Printf("eint%d\n",county++);
ClearPending(BIT_EINT8_23);
}
// rGPGCON = rGPGCON & (~((3<<14)|(3<<10)|(3<<6)|(3<<2))) | ((2<<14)|(2<<10)|(2<<6)|(2<<2)) ; //eint 9,11,13,15 set EINT
rGPEDAT = rGPEDAT & (~((3<<11)|(3<<13))) | ((0<<11)|(0<<13));
rGPBDAT = rGPBDAT & (~((3<<6)|(3<<8))) | ((0<<6)|(0<<8));
ExitCritical(&r);
}
void KeyScan_Test(void)
{
Uart_Printf("\nKey Scan Test, press ESC key to exit !\n");
rGPBUP = rGPBUP & ~0x01e0|0x01e0; // LED [8:5] => PU En
rGPBCON = rGPBCON & ~0x3d57fd|0x3d57fd; //LED[8:5],GPB0 => OUTPUT ;
rGPECON = rGPECON & (~((3<<26)|(3<<22))) | ((1<<26)|(1<<22)) ; //GPE13,11 set OUTPUT
rGPEUP = rGPEUP & ~0x2800|0x2800; // GPE13,11 => PU En
//rGPGCON = rGPGCON & (~((3<<14)|(3<<10)|(3<<6)|(3<<2))) | ((1<<14)|(1<<10)|(1<<6)|(1<<2));// GPG1,3,5,7 set OUTPUT
//rGPGDAT = rGPGDAT & (~((1<<1)|(1<<5)|(1<<7)))|((1<<1)|(1<<3)|(1<<5)|(1<<7));
rGPEDAT = rGPEDAT & (~((3<<11)|(3<<13))) | ((0<<11)|(0<<13));
rGPBDAT = rGPBDAT & (~((3<<6)|(3<<8))) | ((0<<6)|(0<<8));//GPB8,6 GPE11,13口送0
rEXTINT1 &= ~((7<<4)|(7<<12)|(7<<20)|(7<<28));
rEXTINT1 |= ((7<<4)|(7<<12)|(7<<20)|(7<<28)); //set eint 9,11,13,15 switch level int
rGPGCON = rGPGCON & (~((3<<14)|(3<<10)|(3<<6)|(3<<2))) | ((2<<14)|(2<<10)|(2<<6)|(2<<2)) ;//GPG1,3,5,7 set EINT
rEINTPEND = rEINTPEND|(1<<9)|(1<<11)|(1<<13)|(1<<15); //clear eint 9,11,13,15
rEINTMASK &= ~((1<<9)|(1<<11)|(1<<13)|(1<<15)); //enable eint 9,11,13,15
ClearPending(BIT_EINT8_23);
pISR_EINT8_23 = (U32)Key_ISR;
EnableIrq(BIT_EINT8_23);
while( Uart_GetKey() != ESC_KEY );
DisableIrq(BIT_EINT8_23);
} |
|