|
U8 key;
U8 Key_Scan( void )
{
Delay( 80 ) ;
if( (rGPGDAT&(1<< 0)) == 0 )
return 1 ;
else if( (rGPGDAT&(1<< 3)) == 0 )
return 2;
else if( (rGPGDAT&(1<< 5)) == 0 )
return 3 ;
else if( (rGPGDAT&(1<< 6)) == 0 )
return 4 ;
else if( (rGPGDAT&(1<< 7)) == 0 )
return 5 ;
else if( (rGPGDAT&(1<<11)) == 0 )
return 6 ;
}
static void __irq Key_ISR(void)
{
U32 r;
EnterCritical(&r);
if(rINTPND==BIT_EINT8_23) {
ClearPending(BIT_EINT8_23);
if(rEINTPEND&(1<<8)) {
//Uart_Printf("eint11\n");
rEINTPEND |= 1<< 8;
}
if(rEINTPEND&(1<<11)) {
//Uart_Printf("eint11\n");
rEINTPEND |= 1<< 11;
}
if(rEINTPEND&(1<<13)) {
//Uart_Printf("eint11\n");
rEINTPEND |= 1<< 13;
}
if(rEINTPEND&(1<<14)) {
//Uart_Printf("eint11\n");
rEINTPEND |= 1<< 14;
}
if(rEINTPEND&(1<<15)) {
//Uart_Printf("eint11\n");
rEINTPEND |= 1<< 15;
}
if(rEINTPEND&(1<<19)) {
// Uart_Printf("eint19\n");
rEINTPEND |= 1<< 19;
}
}
key=Key_Scan();
ExitCritical(&r);
}
void KeyScan_Test(void)
{
Uart_Printf("\nKey Scan Test, press ESC key to exit !\n");
rGPGCON = rGPGCON & (~((3<<22)|(3<<6)|(3<<0)|(3<<10)|(3<<12)|(3<<14))) |
((2<<22)|(2<<6)|(2<<0)|(2<<10)|(2<<12)|(2<<14)) ; //GPG11,3 set EINT
rEXTINT1 &= ~(7|(7<<0));
rEXTINT1 |= (2|(0<<0)); //set eint8 falling edge int
rEXTINT1 &= ~(7<<12);
rEXTINT1 |= (2<<12); //set eint11 falling edge int
rEXTINT1 &= ~(7<<20);
rEXTINT1 |= (2<<20); //set eint13 falling edge int
rEXTINT1 &= ~(7<<24);
rEXTINT1 |= (2<<24); //set eint14 falling edge int
rEXTINT1 &= ~(7<<28);
rEXTINT1 |= (2<<28); //set eint15 falling edge int
rEXTINT2 &= ~(0xf<<12);
rEXTINT2 |= (2<<12); //set eint19 falling edge int
rEINTPEND |= (1<<8)|(1<<11)|(1<<13)|(1<<14)|(1<<15)|(1<<19); //clear eint 11,19
rEINTMASK &= ~((1<<8)|(1<<11)|(1<<13)|(1<<14)|(1<<15)|(1<<19)); //enable eint11,19
ClearPending(BIT_EINT8_23);
pISR_EINT8_23 = (U32)Key_ISR;
EnableIrq(BIT_EINT0|BIT_EINT2|BIT_EINT8_23);
}
为什么在主函数测KEY的值是255
|
|