-
-
Save matrixd/c90d79c5c4b376a494f3 to your computer and use it in GitHub Desktop.
stm32f4xx.h bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There is a bug in stm32f4xx.h file. | |
That file can be found in "Libraries/CMSIS/Device/ST/STM32F4xx/Include/" in packages: | |
"STSW-STM32127" for STM32F401VC | |
"STSW-STM32136" for 32F401CDISCOVERY. | |
Here is a declaration of GPIO_TypeDef structure. | |
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 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; | |
There are two 16 bit registers: BSRRL and BSRRH. | |
But documentation says only about BSRR register. | |
Also all GPIO_BSRR_BSx/BRx have a 32 bit length. | |
/****************** Bits definition for GPIO_BSRR register ******************/ | |
#define GPIO_BSRR_BS_0 ((uint32_t)0x00000001) | |
#define GPIO_BSRR_BS_1 ((uint32_t)0x00000002) | |
#define GPIO_BSRR_BS_2 ((uint32_t)0x00000004) | |
#define GPIO_BSRR_BS_3 ((uint32_t)0x00000008) | |
#define GPIO_BSRR_BS_4 ((uint32_t)0x00000010) | |
#define GPIO_BSRR_BS_5 ((uint32_t)0x00000020) | |
#define GPIO_BSRR_BS_6 ((uint32_t)0x00000040) | |
#define GPIO_BSRR_BS_7 ((uint32_t)0x00000080) | |
#define GPIO_BSRR_BS_8 ((uint32_t)0x00000100) | |
#define GPIO_BSRR_BS_9 ((uint32_t)0x00000200) | |
#define GPIO_BSRR_BS_10 ((uint32_t)0x00000400) | |
#define GPIO_BSRR_BS_11 ((uint32_t)0x00000800) | |
#define GPIO_BSRR_BS_12 ((uint32_t)0x00001000) | |
#define GPIO_BSRR_BS_13 ((uint32_t)0x00002000) | |
#define GPIO_BSRR_BS_14 ((uint32_t)0x00004000) | |
#define GPIO_BSRR_BS_15 ((uint32_t)0x00008000) | |
#define GPIO_BSRR_BR_0 ((uint32_t)0x00010000) | |
#define GPIO_BSRR_BR_1 ((uint32_t)0x00020000) | |
#define GPIO_BSRR_BR_2 ((uint32_t)0x00040000) | |
#define GPIO_BSRR_BR_3 ((uint32_t)0x00080000) | |
#define GPIO_BSRR_BR_4 ((uint32_t)0x00100000) | |
#define GPIO_BSRR_BR_5 ((uint32_t)0x00200000) | |
#define GPIO_BSRR_BR_6 ((uint32_t)0x00400000) | |
#define GPIO_BSRR_BR_7 ((uint32_t)0x00800000) | |
#define GPIO_BSRR_BR_8 ((uint32_t)0x01000000) | |
#define GPIO_BSRR_BR_9 ((uint32_t)0x02000000) | |
#define GPIO_BSRR_BR_10 ((uint32_t)0x04000000) | |
#define GPIO_BSRR_BR_11 ((uint32_t)0x08000000) | |
#define GPIO_BSRR_BR_12 ((uint32_t)0x10000000) | |
#define GPIO_BSRR_BR_13 ((uint32_t)0x20000000) | |
#define GPIO_BSRR_BR_14 ((uint32_t)0x40000000) | |
#define GPIO_BSRR_BR_15 ((uint32_t)0x80000000) | |
So it's reasonable to change | |
__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 */ | |
to | |
__IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment