1 #define GPIOA_ODR_A (GPIOA_BASE+0x0c)//A口輸出寄存器 ODR 基地址 2 #define GPIOA_IDR_A (GPIOA_BASE+0x08) 3 #define GPIOB_ODR_A (GPIOB_BASE+0x0c) 4 #define GPIOB_IDR_A (GPIOB_BASE+0x08) 5 #define GPIOC_ODR_A (GPIOC_BASE+0x0c) 6 #define GPIOC_IDR_A (GPIOC_BASE+0x08) 7 #define GPIOD_ODR_A (GPIOD_BASE+0x0c) 8 #define GPIOD_IDR_A (GPIOD_BASE+0x08) 9 #define GPIOE_ODR_A (GPIOE_BASE+0x0c) 10 #define GPIOE_IDR_A (GPIOE_BASE+0x08) 11 12 #define BitBand(Addr,BitNum) *((volatile unsigned long *)((Addr&0xF0000000)+0x02000000 + ((Addr&0x000FFFFF)<<5) + (BitNum<<2)))//BitNum=0~15 13 14 #define PAOut(n) BitBand(GPIOA_ODR_A,n) 15 #define PAIn(n) BitBand(GPIOA_IDR_A,n) 16 #define PBOut(n) BitBand(GPIOB_ODR_A,n) 17 #define PBIn(n) BitBand(GPIOB_IDR_A,n) 18 #define PCOut(n) BitBand(GPIOC_ODR_A,n) 19 #define PCIn(n) BitBand(GPIOC_IDR_A,n) 20 #define PDOut(n) BitBand(GPIOD_ODR_A,n) 21 #define PDIn(n) BitBand(GPIOD_IDR_A,n) 22 #define PEOut(n) BitBand(GPIOE_ODR_A,n) 23 #define PEIn(n) BitBand(GPIOE_IDR_A,n)