像51一樣操作STM32的IO
//別名區(qū)
// 把“位段地址+位序號”轉(zhuǎn)換別名地址宏
#define BITBAND(addr, bitnum) ((addr & 0xF0000000)+0x2000000+((addr &0xFFFFF)<<5)+(bitnum<<2))
//把該地址轉(zhuǎn)換成一個指針
#define MEM_ADDR(addr)
#define BIT_ADDR(addr, bitnum)
#define GPIOA_ODR_Addr
#define GPIOB_ODR_Addr
#define GPIOC_ODR_Addr
#define GPIOD_ODR_Addr
#define GPIOE_ODR_Addr
#define GPIOA_IDR_Addr
#define GPIOB_IDR_Addr
#define GPIOC_IDR_Addr
#define GPIOD_IDR_Addr
#define GPIOE_IDR_Addr
//-----------------------------------------------------
#define PA0
#define PA1
#define PA2
#define PA3
#define PA4
#define PA5
#define PA6
#define PA7
#define PA8
#define PA9
#define PA10
#define PA11
#define PA12
#define PA13
#define PA14
#define PA15
#define PA0in
#define PA1in
#define PA2in
#define PA3in
#define PA4in
#define PA5in
#define PA6in
#define PA7in
#define PA8in
#define PA9in
#define PA10in
#define PA11in
#define PA12in
#define PA13in
#define PA14in
#define PA15in
//-----------------------------------------------------
#define PB0
#define PB1
#define PB2
#define PB3
#define PB4
#define PB5
#define PB6
#define PB7
#define PB8
#define PB9
#define PB10
#define PB11
#define PB12
#define PB13
#define PB14
#define PB15
#define PB0in
#define PB1in
#define PB2in
#define PB3in
#define PB4in
#define PB5in
#define PB6in
#define PB7in
#define PB8in
#define PB9in
#define PB10in
#define PB11in
#define PB12in
#define PB13in
#define PB14in
#define PB15in
//----------------------------------------------------
#define PC0
#define PC1
#define PC2
#define PC3
#define PC4
#define PC5
#define PC6
#define PC7
#define PC8
#define PC9
#define PC10
#define PC11
#define PC12
#define PC13
#define PC14
#define PC15
#define PC0in
#define PC1in
#define PC2in
#define PC3in
#define PC4in
#define PC5in
#define PC6in
#define PC7in
#define PC8in
#define PC9in
#define PC10in
#define PC11in
#define PC12in
#define PC13in
#define PC14in
#define PC15in
//----------------------------------------------------
#define PD0
#define PD1
#define PD2
#define PD3
#define PD4
#define PD5
#define PD6
#define PD7
#define PD8
#define PD9
#define PD10
#define PD11
#define PD12
#define PD13
#define PD14
#define PD15
#define PD0in
#define PD1in
#define PD2in
#define PD3in
#define PD4in
#define PD5in
#define PD6in
#define PD7in
#define PD8in
#define PD9in
#define PD10in
#define PD11in
#define PD12in
#define PD13in
#define PD14in
#define PD15in
//----------------------------------------------------
#define PE0
#define PE1
#define PE2
#define PE3
#define PE4
#define PE5
#define PE6
#define PE7
#define PE8
#define PE9
#define PE10
#define PE11
#define PE12
#define PE13
#define PE14
#define PE15
#define PE0in
#define PE1in
#define PE2in
#define PE3in
#define PE4in
#define PE5in
#define PE6in
#define PE7in
#define PE8in
#define PE9in
#define PE10in
#define PE11in
#define PE12in
#define PE13in
#define PE14in
#define PE15in
//舉例:
//輸出
PA0=0;
PA1=1;
//輸入
if(PB0==0)
評論