STM32 GPIO位操作
不多BB,直接上代码
#define GPIOA_IDR_Addr (GPIOA_BASE + 0x08)
#define PAin(n) *(uint32_t *)((GPIOA_IDR_Addr&0xF0000000) + 0x02000000 + ((GPIOA_IDR_Addr&0x00FFFFFF)<<5)+(n<<2))
#define GPIOA_ODR_Addr (GPIOA_BASE + 0x0C)
#define PAout(n) *(uint32_t *)((GPIOA_ODR_Addr&0xF0000000) + 0x02000000 + ((GPIOA_ODR_Addr&0x00FFFFFF)<<5)+(n<<2))
使用方法:
a = PAin(x);
PAout(x) = 0 or 1;