Cortex-M4 库文件的GPIO的bug

在stm32f4xxx.h文件中,使用直接操作寄存器的方法控制GPIO,发现置位和复位寄存器BSRR在GPIO_TypeDef中分开为两个uint16_t定义的,分别为BSRRH、BSRRL。但是在后面的位定义却是以BSRR这个32位的寄存器来定义的,这是一个bug,改成下面这样就好了。

typedef struct

{

__IO uint32_t MODER;    /*!< GPIO port mode register,              Address offset: 0x00      */

__IO uint32_t OTYPER;  /*!< GPIO port output type register,        Address offset: 0x04      */

__IO uint32_t OSPEEDR;  /*!< GPIO port output speed register,      Address offset: 0x08      */

__IO uint32_t PUPDR;    /*!< GPIO port pull-up/pull-down register,  Address offset: 0x0C      */

__IO uint32_t IDR;      /*!< GPIO port input data register,        Address offset: 0x10      */

__IO uint32_t ODR;      /*!< GPIO port output data register,        Address offset: 0x14      */

__IO uint32_t BSRR;   /*!< GPIO port bit set/reset register,  Address offset: 0x18      */

//__IO uint16_t BSRRL;    /*!< GPIO port bit set/reset low register,  Address offset: 0x18      */

//__IO uint16_t BSRRH;    /*!< GPIO port bit set/reset high register, Address offset: 0x1A      */

__IO uint32_t LCKR;    /*!< GPIO port configuration lock register, Address offset: 0x1C      */

__IO uint32_t AFR[2];  /*!< GPIO alternate function registers,    Address offset: 0x20-0x24 */

} GPIO_TypeDef;

你可能感兴趣的:(Cortex-M4 库文件的GPIO的bug)