STM32 - Nerviger Bug in "stm32f4xx.h"

OP (Firma: EleLa - www.elela.de) #2700761
Lesenswert?

In der Orgiginaldatei ist die Struktur "GPIO_TypeDef" so definiert:
1
typedef struct
2
{
3
  __IO uint32_t MODER;    /*!< GPIO port mode register,               Address offset: 0x00      */
4
  __IO uint32_t OTYPER;   /*!< GPIO port output type register,        Address offset: 0x04      */
5
  __IO uint32_t OSPEEDR;  /*!< GPIO port output speed register,       Address offset: 0x08      */
6
  __IO uint32_t PUPDR;    /*!< GPIO port pull-up/pull-down register,  Address offset: 0x0C      */
7
  __IO uint32_t IDR;      /*!< GPIO port input data register,         Address offset: 0x10      */
8
  __IO uint32_t ODR;      /*!< GPIO port output data register,        Address offset: 0x14      */
9
  __IO uint16_t BSRRL;    /*!< GPIO port bit set/reset low register,  Address offset: 0x18      */
10
  __IO uint16_t BSRRH;    /*!< GPIO port bit set/reset high register, Address offset: 0x1A      */
11
  __IO uint32_t LCKR;     /*!< GPIO port configuration lock register, Address offset: 0x1C      */
12
  __IO uint32_t AFR[2];   /*!< GPIO alternate function registers,     Address offset: 0x20-0x24 */
13
} GPIO_TypeDef;

Aber das BSRRL / BSRRH ist wenig Aussagekräftig und passen zudem auch 
nicht zu den nachfolgenden Definitionen:
1
#define GPIO_BSRR_BR_0                       ((uint32_t)0x00010000)
Denn man kann keine 32 Bit Variable auf eine 16 Bit Deklaration 
schreiben.
Das ganze ist somit entweder ein Bug oder nicht richtig durchdacht.

Somit meine Änderung der Datenstruktur:
1
typedef struct
2
{
3
  __IO uint32_t MODER;    /*!< GPIO port mode register,               Address offset: 0x00      */
4
  __IO uint32_t OTYPER;   /*!< GPIO port output type register,        Address offset: 0x04      */
5
  __IO uint32_t OSPEEDR;  /*!< GPIO port output speed register,       Address offset: 0x08      */
6
  __IO uint32_t PUPDR;    /*!< GPIO port pull-up/pull-down register,  Address offset: 0x0C      */
7
  __IO uint32_t IDR;      /*!< GPIO port input data register,         Address offset: 0x10      */
8
  __IO uint32_t ODR;      /*!< GPIO port output data register,        Address offset: 0x14      */
9
  union
10
  {
11
    __IO uint32_t BSRR;   /*!< GPIO port bit set/reset register,      Address offset: 0x18      */
12
    struct
13
    {
14
      __IO uint16_t BS;   /*!< GPIO port bit set/reset low register,  Address offset: 0x18      */
15
      __IO uint16_t BR;   /*!< GPIO port bit set/reset high register, Address offset: 0x1A      */
16
    };
17
  };
18
  __IO uint32_t LCKR;     /*!< GPIO port configuration lock register, Address offset: 0x1C      */
19
  __IO uint32_t AFR[2];   /*!< GPIO alternate function registers,     Address offset: 0x20-0x24 */
20
} GPIO_TypeDef;

Damit hat man 32 Bit Zugriff sowie auch 16 Bit Zugriff auf die Set/Reset 
Register. Und das ganze ist jetzt auch so benahmt wie in der Doku RM0090 
beschrieben.

Leider habe ich jetzt keine Mailadresse von ST, sonst hätte ich das 
denen geschrieben.
Kann das jemand für mich machen?

Grüße Markus.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren