Skip to content

stm32/gpio: Remove duplicate prototypes#3671

Open
kasjer wants to merge 2 commits into
apache:masterfrom
kasjer:kasjer/stm32-gpio-fun
Open

stm32/gpio: Remove duplicate prototypes#3671
kasjer wants to merge 2 commits into
apache:masterfrom
kasjer:kasjer/stm32-gpio-fun

Conversation

@kasjer
Copy link
Copy Markdown
Contributor

@kasjer kasjer commented Jun 4, 2026

One function:

int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t od);

has many instances of prototype now only one stays

Convenience function int hal_gpio_init_fun(uint32_t pin) added.

Function will allow easy configuration pin with function with single value from syscfg.

i.e.

   STM32_QSPI_FLASH_CS_PIN: MCU_AFIO_GPIO_PP(MCU_GPIO_PORTC(2), 10, 0, 0)

could be used and later pin can be configured like this

    hal_gpio_init_fun(MYNEWT_VAL_STM32_QSPI_FLASH_CS_PIN);

Before function AF number has to be configured in separate syscfg value of hardcoded (which was OK for some functions but may not be OK for many others)

@github-actions github-actions Bot added STM STM32 related size/m labels Jun 4, 2026
@kasjer kasjer force-pushed the kasjer/stm32-gpio-fun branch 5 times, most recently from c755309 to 21ad874 Compare June 7, 2026 10:26
kasjer added 2 commits June 8, 2026 22:23
Function hal_gpio_init_af() has only one implementation
but every MCU had it's own prototype of same function.

Now prototype is move to common place and redundant
versions are removed
There is hal_gpio_init_af() function that configures
pin function.

Now additional function hal_gpio_init_fun() is added
that has only one argument instead of 4.
Pin number, AF number pull-up/down and open drain specification
is combined in one uint32_t value.

This will make it easy to have pin function configuration
in syscfg as single value created with new macro:
MCU_AFIO_GPIO_PP()

Before that if pin for some was configurable in syscfg
additionally AF number could be needed for some function
that has different AF numbers for same function on different
pins.

i.e.
STM32_QSPI_FLASH_CS_PIN: MCU_AFIO_GPIO_PP(MCU_GPIO_PORTC(2), 10, 0, 0)

could be used and later pin can be configured like this

hal_gpio_init_fun(MYNEWT_VAL_STM32_QSPI_FLASH_CS_PIN)

No need to extract additional information from syscfg

Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
@kasjer kasjer force-pushed the kasjer/stm32-gpio-fun branch from 21ad874 to 765835b Compare June 8, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m STM STM32 related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants