本帖最后由 yzzly 于 2024-11-26 14:40 编辑
#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 GPIOA_ODR_Addr (GPIOA_BASE+20) //0x40020014
#define GPIOB_ODR_Addr (GPIOB_BASE+20) //0x40020414
#define GPIOC_ODR_Addr (GPIOC_BASE+20) //0x40020814
#define GPIOD_ODR_Addr (GPIOD_BASE+20) //0x40020C14
#define GPIOE_ODR_Addr (GPIOE_BASE+20) //0x40021014
#define GPIOF_ODR_Addr (GPIOF_BASE+20) //0x40021414
#define GPIOG_ODR_Addr (GPIOG_BASE+20) //0x40021814
#define GPIOH_ODR_Addr (GPIOH_BASE+20) //0x40021C14
#define GPIOI_ODR_Addr (GPIOI_BASE+20) //0x40022014
#define GPIOA_IDR_Addr (GPIOA_BASE+16) //0x40020010
#define GPIOB_IDR_Addr (GPIOB_BASE+16) //0x40020410
#define GPIOC_IDR_Addr (GPIOC_BASE+16) //0x40020810
#define GPIOD_IDR_Addr (GPIOD_BASE+16) //0x40020C10
#define GPIOE_IDR_Addr (GPIOE_BASE+16) //0x40021010
#define GPIOF_IDR_Addr (GPIOF_BASE+16) //0x40021410
#define GPIOG_IDR_Addr (GPIOG_BASE+16) //0x40021810
#define GPIOH_IDR_Addr (GPIOH_BASE+16) //0x40021C10
#define GPIOI_IDR_Addr (GPIOI_BASE+16) //0x40022010
//-----------------------------------------------------
#define PA0Out BIT_ADDR(GPIOA_ODR_Addr, 0) //Êä³ö
#define PA1Out BIT_ADDR(GPIOA_ODR_Addr, 1) //Êä³ö
#define PA2Out BIT_ADDR(GPIOA_ODR_Addr, 2) //Êä³ö
#define PA3Out BIT_ADDR(GPIOA_ODR_Addr, 3) //Êä³ö
#define PA4Out BIT_ADDR(GPIOA_ODR_Addr, 4) //Êä³ö
#define PA5Out BIT_ADDR(GPIOA_ODR_Addr, 5) //Êä³ö
#define PA6Out BIT_ADDR(GPIOA_ODR_Addr, 6) //Êä³ö
#define PA7Out BIT_ADDR(GPIOA_ODR_Addr, 7) //Êä³ö
#define PA8Out BIT_ADDR(GPIOA_ODR_Addr, 8) //Êä³ö
#define PA9Out BIT_ADDR(GPIOA_ODR_Addr, 9) //Êä³ö
#define PA10Out BIT_ADDR(GPIOA_ODR_Addr, 10)//Êä³ö
#define PA11Out BIT_ADDR(GPIOA_ODR_Addr, 11)//Êä³ö
#define PA12Out BIT_ADDR(GPIOA_ODR_Addr, 12)//Êä³ö
#define PA13Out BIT_ADDR(GPIOA_ODR_Addr, 13)//Êä³ö
#define PA14Out BIT_ADDR(GPIOA_ODR_Addr, 14)//Êä³ö
#define PA15Out BIT_ADDR(GPIOA_ODR_Addr, 15)//Êä³ö
#define PA0In BIT_ADDR(GPIOA_IDR_Addr, 0) //ÊäÈë
#define PA1In BIT_ADDR(GPIOA_IDR_Addr, 1) //ÊäÈë
#define PA2In BIT_ADDR(GPIOA_IDR_Addr, 2) //ÊäÈë
#define PA3In BIT_ADDR(GPIOA_IDR_Addr, 3) //ÊäÈë
#define PA4In BIT_ADDR(GPIOA_IDR_Addr, 4) //ÊäÈë
#define PA5In BIT_ADDR(GPIOA_IDR_Addr, 5) //ÊäÈë
#define PA6In BIT_ADDR(GPIOA_IDR_Addr, 6) //ÊäÈë
#define PA7In BIT_ADDR(GPIOA_IDR_Addr, 7) //ÊäÈë
#define PA8In BIT_ADDR(GPIOA_IDR_Addr, 8) //ÊäÈë
#define PA9In BIT_ADDR(GPIOA_IDR_Addr, 9) //ÊäÈë
#define PA10In BIT_ADDR(GPIOA_IDR_Addr, 10)//ÊäÈë
#define PA11In BIT_ADDR(GPIOA_IDR_Addr, 11)//ÊäÈë
#define PA12In BIT_ADDR(GPIOA_IDR_Addr, 12)//ÊäÈë
#define PA13In BIT_ADDR(GPIOA_IDR_Addr, 13)//ÊäÈë
#define PA14In BIT_ADDR(GPIOA_IDR_Addr, 14)//ÊäÈë
#define PA15In BIT_ADDR(GPIOA_IDR_Addr, 15)//ÊäÈë
#define UABFt PA0In
#define DYFT PA1In
#define TXD2 PA2Out
#define RXD2 PA3In
#define RadioD3 PA4In
#define NULL1 PA5Out //1
#define CON7606 PA6Out
#define RadioVT PA7In
#define Lamp2 PA8Out //2
#define TXD1 PA9Out
#define RXD1 PA10In
#define Close PA11Out
#define Open PA12Out
#define TMS PA13Out
#define TCK PA14Out
#define OverCurrentLed PA15Out
以上为位操作的定义,至于寄存器操作,只要对寄存器名直接读写就可以。
|