/* 以下定义是将PA0管脚所涉及到的IDR输入寄存器的状态值取出来,该寄存器是只读的寄存器 */
/* 通过查看IDR寄存器就可以判断按键是否按下了 */
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
#define MEM_ADDR(addr) *((volatile unsigned long *)(addr))
#define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum))
#define PAin(n) BIT_ADDR(GPIOA_IDR_Addr,n)
#define KEY15 PAin(15) //定义PA0
ARM7
------解决方案--------------------
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2)) // addr地址偏移计算,具体做什么用没太看出来
#define MEM_ADDR(addr) *((volatile unsigned long *)(addr)) 这个是获得add的地址的unsigned long型值
#define BIT_ADDR(addr, bitnum) MEM_ADDR(BITBAND(addr, bitnum)) 上两个函数的组合
#define PAin(n) BIT_ADDR(GPIOA_IDR_Addr,n) 获取第n个管脚
#define KEY15 PAin(15) //定义PA0 定义15管脚为KEY15