This is an automated email from the ASF dual-hosted git repository. kasjer pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 03c95ee0f2fc8c6ddd04bea8ac624f2efd32b239 Author: Jerzy Kasenberg <[email protected]> AuthorDate: Thu Jun 4 22:34:01 2026 +0200 stm32/gpio: Remove duplicate prototypes 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 --- hw/drivers/lwip/stm32_eth/src/stm32_eth.c | 1 + hw/mcu/stm/stm32_common/include/stm32_common/mcu.h | 13 +++++++++++++ hw/mcu/stm/stm32_common/src/hal_i2c.c | 1 + hw/mcu/stm/stm32f0xx/include/mcu/stm32f0_bsp.h | 5 ----- hw/mcu/stm/stm32f1xx/include/mcu/stm32f1_bsp.h | 6 ------ hw/mcu/stm/stm32f3xx/include/mcu/stm32f3_bsp.h | 6 ------ hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h | 6 ------ hw/mcu/stm/stm32f7xx/include/mcu/stm32f7_bsp.h | 6 ------ hw/mcu/stm/stm32g0xx/include/mcu/stm32g0_bsp.h | 5 ----- hw/mcu/stm/stm32g4xx/include/mcu/stm32g4_bsp.h | 5 ----- hw/mcu/stm/stm32h7xx/include/mcu/stm32h7_bsp.h | 6 ------ hw/mcu/stm/stm32l0xx/include/mcu/stm32l0_bsp.h | 6 ------ hw/mcu/stm/stm32l1xx/include/mcu/stm32l1_bsp.h | 6 ------ hw/mcu/stm/stm32l4xx/include/mcu/stm32l4_bsp.h | 6 ------ hw/mcu/stm/stm32u5xx/include/mcu/stm32u5_bsp.h | 5 ----- hw/mcu/stm/stm32wbxx/include/mcu/stm32wb_bsp.h | 6 ------ 16 files changed, 15 insertions(+), 74 deletions(-) diff --git a/hw/drivers/lwip/stm32_eth/src/stm32_eth.c b/hw/drivers/lwip/stm32_eth/src/stm32_eth.c index 2e3298fd5..a896ca34e 100644 --- a/hw/drivers/lwip/stm32_eth/src/stm32_eth.c +++ b/hw/drivers/lwip/stm32_eth/src/stm32_eth.c @@ -23,6 +23,7 @@ #include <hal/hal_timer.h> #include <mcu/cmsis_nvic.h> #include <stm32_common/stm32_hal.h> +#include <mcu/mcu.h> #if MYNEWT_VAL(MCU_STM32F4) #include <bsp/stm32f4xx_hal_conf.h> diff --git a/hw/mcu/stm/stm32_common/include/stm32_common/mcu.h b/hw/mcu/stm/stm32_common/include/stm32_common/mcu.h index a6c67fe21..f7fd8246b 100644 --- a/hw/mcu/stm/stm32_common/include/stm32_common/mcu.h +++ b/hw/mcu/stm/stm32_common/include/stm32_common/mcu.h @@ -24,6 +24,7 @@ extern "C" { #endif +#include <hal/hal_gpio.h> /* * Note that not all processors have support for all ports. * @@ -108,6 +109,18 @@ extern "C" { void stm32_start_bootloader(void); +/** + * Init alternate function on specified pin + * + * @param pin pin specified by MCU_GPIO_PORTx(pin) macro + * @param af_type - alternate function number 0-15 + * @param pull - whether to add pull-up or pull-down resistor + * @param od - if 1 - enable open drain + * + * @return 0 on success -1 on failure + */ +int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t od); + #if MYNEWT_VAL_STM32_WFI_FROM_RAM extern void stm32_wfi_from_ram(void); #define STM32_WFI stm32_wfi_from_ram diff --git a/hw/mcu/stm/stm32_common/src/hal_i2c.c b/hw/mcu/stm/stm32_common/src/hal_i2c.c index 59d1bf1d1..71eea766c 100644 --- a/hw/mcu/stm/stm32_common/src/hal_i2c.c +++ b/hw/mcu/stm/stm32_common/src/hal_i2c.c @@ -27,6 +27,7 @@ #include <hal/hal_gpio.h> #include <mcu/stm32_hal.h> +#include <stm32_common/mcu.h> #if MYNEWT_VAL(I2C_3) #define HAL_I2C_MAX_DEVS 4 diff --git a/hw/mcu/stm/stm32f0xx/include/mcu/stm32f0_bsp.h b/hw/mcu/stm/stm32f0xx/include/mcu/stm32f0_bsp.h index 880482476..0cda01d0e 100644 --- a/hw/mcu/stm/stm32f0xx/include/mcu/stm32f0_bsp.h +++ b/hw/mcu/stm/stm32f0xx/include/mcu/stm32f0_bsp.h @@ -42,11 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32f0xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t od); - struct hal_flash; extern const struct hal_flash stm32f0_flash_dev; diff --git a/hw/mcu/stm/stm32f1xx/include/mcu/stm32f1_bsp.h b/hw/mcu/stm/stm32f1xx/include/mcu/stm32f1_bsp.h index 59fdd969f..3fb0ef7fb 100644 --- a/hw/mcu/stm/stm32f1xx/include/mcu/stm32f1_bsp.h +++ b/hw/mcu/stm/stm32f1xx/include/mcu/stm32f1_bsp.h @@ -42,12 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32f1xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, - uint8_t od); - struct hal_flash; extern struct hal_flash stm32f1_flash_dev; diff --git a/hw/mcu/stm/stm32f3xx/include/mcu/stm32f3_bsp.h b/hw/mcu/stm/stm32f3xx/include/mcu/stm32f3_bsp.h index f04ce098d..78fb13ee4 100644 --- a/hw/mcu/stm/stm32f3xx/include/mcu/stm32f3_bsp.h +++ b/hw/mcu/stm/stm32f3xx/include/mcu/stm32f3_bsp.h @@ -42,12 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32f3xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t -od); - struct hal_flash; struct hal_flash* stm32f3_flash_dev(void); diff --git a/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h b/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h index 136696992..82a097af5 100644 --- a/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h +++ b/hw/mcu/stm/stm32f4xx/include/mcu/stm32f4_bsp.h @@ -42,12 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32f4xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t -od); - struct hal_flash; extern const struct hal_flash stm32f4_flash_dev; diff --git a/hw/mcu/stm/stm32f7xx/include/mcu/stm32f7_bsp.h b/hw/mcu/stm/stm32f7xx/include/mcu/stm32f7_bsp.h index b722eb846..7cd44e545 100644 --- a/hw/mcu/stm/stm32f7xx/include/mcu/stm32f7_bsp.h +++ b/hw/mcu/stm/stm32f7xx/include/mcu/stm32f7_bsp.h @@ -42,12 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32f7xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t -od); - struct hal_flash; extern struct hal_flash stm32f7_flash_dev; diff --git a/hw/mcu/stm/stm32g0xx/include/mcu/stm32g0_bsp.h b/hw/mcu/stm/stm32g0xx/include/mcu/stm32g0_bsp.h index c1649dd0a..41868fb0c 100644 --- a/hw/mcu/stm/stm32g0xx/include/mcu/stm32g0_bsp.h +++ b/hw/mcu/stm/stm32g0xx/include/mcu/stm32g0_bsp.h @@ -42,11 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32g0xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t od); - struct hal_flash; extern struct hal_flash stm32g0_flash_dev; diff --git a/hw/mcu/stm/stm32g4xx/include/mcu/stm32g4_bsp.h b/hw/mcu/stm/stm32g4xx/include/mcu/stm32g4_bsp.h index c6ac716d3..52a6dae9c 100644 --- a/hw/mcu/stm/stm32g4xx/include/mcu/stm32g4_bsp.h +++ b/hw/mcu/stm/stm32g4xx/include/mcu/stm32g4_bsp.h @@ -42,11 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32u5xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t od); - struct hal_flash; extern struct hal_flash stm32g4_flash_dev; diff --git a/hw/mcu/stm/stm32h7xx/include/mcu/stm32h7_bsp.h b/hw/mcu/stm/stm32h7xx/include/mcu/stm32h7_bsp.h index b22a4ba7a..6284fbb38 100644 --- a/hw/mcu/stm/stm32h7xx/include/mcu/stm32h7_bsp.h +++ b/hw/mcu/stm/stm32h7xx/include/mcu/stm32h7_bsp.h @@ -42,12 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32f7xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t - od); - struct hal_flash; extern struct hal_flash stm32f7_flash_dev; diff --git a/hw/mcu/stm/stm32l0xx/include/mcu/stm32l0_bsp.h b/hw/mcu/stm/stm32l0xx/include/mcu/stm32l0_bsp.h index 00a10f016..05b3ea08f 100644 --- a/hw/mcu/stm/stm32l0xx/include/mcu/stm32l0_bsp.h +++ b/hw/mcu/stm/stm32l0xx/include/mcu/stm32l0_bsp.h @@ -42,12 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32l0xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t -od); - struct hal_flash; extern struct hal_flash stm32l0_flash_dev; diff --git a/hw/mcu/stm/stm32l1xx/include/mcu/stm32l1_bsp.h b/hw/mcu/stm/stm32l1xx/include/mcu/stm32l1_bsp.h index 3470aade1..dc96949fb 100644 --- a/hw/mcu/stm/stm32l1xx/include/mcu/stm32l1_bsp.h +++ b/hw/mcu/stm/stm32l1xx/include/mcu/stm32l1_bsp.h @@ -42,12 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32l1xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t -od); - struct hal_flash; extern struct hal_flash stm32l1_flash_dev; diff --git a/hw/mcu/stm/stm32l4xx/include/mcu/stm32l4_bsp.h b/hw/mcu/stm/stm32l4xx/include/mcu/stm32l4_bsp.h index 6dc9e4484..3528ba9c0 100644 --- a/hw/mcu/stm/stm32l4xx/include/mcu/stm32l4_bsp.h +++ b/hw/mcu/stm/stm32l4xx/include/mcu/stm32l4_bsp.h @@ -42,12 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32l4xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t -od); - struct hal_flash; extern struct hal_flash stm32l4_flash_dev; diff --git a/hw/mcu/stm/stm32u5xx/include/mcu/stm32u5_bsp.h b/hw/mcu/stm/stm32u5xx/include/mcu/stm32u5_bsp.h index ef7b88747..0cafcbdf6 100644 --- a/hw/mcu/stm/stm32u5xx/include/mcu/stm32u5_bsp.h +++ b/hw/mcu/stm/stm32u5xx/include/mcu/stm32u5_bsp.h @@ -42,11 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32u5xx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t od); - struct hal_flash; extern struct hal_flash stm32u5_flash_dev; diff --git a/hw/mcu/stm/stm32wbxx/include/mcu/stm32wb_bsp.h b/hw/mcu/stm/stm32wbxx/include/mcu/stm32wb_bsp.h index e45dc67e1..0e2a8d4d9 100644 --- a/hw/mcu/stm/stm32wbxx/include/mcu/stm32wb_bsp.h +++ b/hw/mcu/stm/stm32wbxx/include/mcu/stm32wb_bsp.h @@ -42,12 +42,6 @@ struct stm32_uart_cfg { IRQn_Type suc_irqn; /* NVIC IRQn */ }; -/* - * Internal API for stm32wbxx mcu specific code. - */ -int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, - uint8_t od); - struct hal_flash; extern struct hal_flash stm32wb_flash_dev;
