Page 1 of 1

GPIO_TypeDef unusable from ST lib

Posted: Sun Feb 16, 2014 9:12 pm
by lilvinz
Hi,

when refactoring large projects, it is often feasible to do a step by step transition.
I have had the opportunity to replace FreeRTOS / ST lib by ChibiOS and came
across an issue with the ChibiOS modification in ST's chip header file.
e.g. stm32f4xx.h
There the GPIO_TypeDef struct has been removed and thus makes it impossible to use
ST libs gpio functions. This in turn renders legacy drivers unusable and makes a step by step
transition very hard.
I think it is not necessary to completely remove this struct but fix it while preserving compatibility with ST lib:

Code: Select all

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      */
  union {
    struct {
      __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      */
    };
    volatile union {
        __IO uint32_t W;
      struct {
        __IO uint16_t set;
        __IO uint16_t clear;
      } H;
    } BSRR;
  };
  __IO uint32_t LCKR;     /*!< GPIO port configuration lock register, Address offset: 0x1C      */
  union {
    __IO uint32_t AFR[2]; /*!< GPIO alternate function registers,     Address offset: 0x20-0x24 */
    struct {
      __IO uint32_t AFRL;
      __IO uint32_t AFRH;
    };
  };
} GPIO_TypeDef;


Of course the corresponsing declaration then has to be removed from STM32/GPIOv2/pal_lld.h.
What do you think?

Best regards,

Vinz

Re: GPIO_TypeDef unusable from ST lib

Posted: Sun Feb 16, 2014 9:20 pm
by Giovanni
That would make the PAL driver non functional.

The conflict has been addressed in ChibiOS3.0 but will not be backported officially in 2.6.x. You may start using 3.0 or backport the 3.0 PAL driver in 2.6.

Giovanni

Re: GPIO_TypeDef unusable from ST lib

Posted: Mon Feb 17, 2014 2:44 pm
by lilvinz
Thanks for the quick response. I will look at the 3.0 implementation.
I would very much appreciate to know why my proposed solution won't work.

Thanks again and cheers,

Vinz

Re: GPIO_TypeDef unusable from ST lib

Posted: Mon Feb 17, 2014 3:20 pm
by Giovanni
Hi,

It is because some compilers complain about anonymous structs and unions, those are not standard constructs.

Of course you can use them in your project.

Giovanni