void check_P0(void)
{
asm("di"); // disable interrupt
*(volatile unsigned char *)0x5080 = 0x03; //Enable PCLK supply
PO_IEN = Ox10; // Enable P04 Input port
PO_OEN = 0xEF; // 1110 1111 P00,P01,P02,P03 , P05,P06,P07 set to output port
PO_OUT = 0x00; // except p04 port ,others output Low
PO_PU = 0xFF; // 1111 1111 set P04 port to pull-up
PO_EDGE = 0X0F; // 1 Falling edge; 0 rising edge
PO_IFLG = 0xFF; // reset flag
asm("ei"); // enable interrupt
test_pm = (*(volatile unsigned char *)0x5200)&0x10; //read P04 satus
// when P04
*(volatile unsigned char *)0x5080 = 0x00; //Disable PLCK supply
}
注:输入配置的优先级大于输出的配置