![](https://cos-cdn.shuashuati.com/pipixue-web/2020-1231-2005-12/ti_inject-812ce.png)
在MDK中有以下定义,计算GPIOB_ODR寄存器地址为 . #define PERIPH_BASE ((uint32_t)0x40000000) #define APB2PERIPH_BASE (PERIPH_BASE + 0x10000) #define GPIOB_BASE (APB2PERIPH_BASE + 0x0C00) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) typedef struct { __IO uint32_t CRL; __IO uint32_t CRH; __IO uint32_t IDR; __IO uint32_t ODR; __IO uint32_t BSRR; __IO uint32_t BRR; __IO uint32_t LCKR; } GPIO_TypeDef;