GPIO中断使用说明
GPIO的配置
一共有四组GPIO基址寄存器:
Base Address: GPIO 0: 0xD401_9000(对应GPIO0_31)
Base Address: GPIO 1: 0xD401_9004(对应GPIO32_63)
Base Address: GPIO 2: 0xD401_9008(对应GPIO64_95)
Base Address: GPIO 3: 0xD401_9100(对应GPIO96_127)
需要配置GPIO的三个寄存器:
GPIO Direction Register (GPIO_CDR, offset 0x60)
设置对应GPIO的方向为输入;
GPIO Falling-Edge Detect Enable Register (GPIO_FERx, offset 0x3C)
使能对应GPIO的下降沿触发
Modem ARM*(Seagull) Core Bit-wise Mask of GPIO Edge Detect Register (CPMASK_REG, offset 0xA8)
打开对应GPIO的边沿探测
使用示例(GPIO23,对应的基址寄存器是GPIO 0: 0xD401_9000):
volatile unsigned long * r;
//set GPIO_CDR, set GPIO23 direction as input
r = (volatile unsigned long*)(0xD4019000 + 0x60);
*r = (1 << 23);
//set GPIO_FERx, set GPIO23 Falling-Edge enable
r = (volatile unsigned long*)(0xD4019000 + 0x3C);
*r |= (1<<23);
//set CPMASK_REG, set GPIO23 Edge detects are not masked
r = (volatile unsigned long*)(0xD4019000 + 0xA8);
*r |= (1<<23);
ICU
GPIO中断使用说明 来自淘豆网m.daumloan.com转载请标明出处.