You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2026/06/09 10:34:39 UTC
(mynewt-core) branch master updated (9185ad6c1 -> 1dcb119ed)
This is an automated email from the ASF dual-hosted git repository.
kasjer pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
from 9185ad6c1 net/osdp: Update to 3.2.2 and move to external repo
new 03c95ee0f stm32/gpio: Remove duplicate prototypes
new 1dcb119ed stm32/gpio: Add function to configure pin function
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
hw/drivers/lwip/stm32_eth/src/stm32_eth.c | 1 +
hw/mcu/stm/stm32_common/include/stm32_common/mcu.h | 24 ++++++++++++++++++++++
hw/mcu/stm/stm32_common/src/hal_gpio.c | 12 +++++++++++
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 ------
17 files changed, 38 insertions(+), 74 deletions(-)
(mynewt-core) 01/02: stm32/gpio: Remove duplicate prototypes
Posted by je...@apache.org.
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 <je...@codecoup.pl>
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;
(mynewt-core) 02/02: stm32/gpio: Add function to configure pin function
Posted by je...@apache.org.
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 1dcb119ed88506401fd5283902cfebd00b7c4a97
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Jun 4 22:45:38 2026 +0200
stm32/gpio: Add function to configure pin function
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 <je...@apache.org>
---
hw/mcu/stm/stm32_common/include/stm32_common/mcu.h | 11 +++++++++++
hw/mcu/stm/stm32_common/src/hal_gpio.c | 12 ++++++++++++
2 files changed, 23 insertions(+)
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 f7fd8246b..1a0b58192 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 <stdint.h>
#include <hal/hal_gpio.h>
/*
* Note that not all processors have support for all ports.
@@ -73,6 +74,8 @@ extern "C" {
*/
#define MCU_GPIO_PIN_NONE (0xFFFF)
+#define MCU_AFIO_GPIO_PP(pin, af, pu, od) \
+ (((0x0F & af) << 12) | (0x00FF & pin) | ((3 & pu) << 8) | (1 & od) << 10)
/*
* Mapping of a GPIO pin to an alternate function.
@@ -121,6 +124,14 @@ void stm32_start_bootloader(void);
*/
int hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t od);
+/**
+ * Init alternate function on specified pin
+ * @param pin pin config created by MCU_AFIO_PORTx(pin, af) macro or
+ * MCU_AFIO_GPIO_PP(pin, af, pull, od)
+ * @return 0 on success -1 on failure
+ */
+int hal_gpio_init_fun(uint32_t pin);
+
#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_gpio.c b/hw/mcu/stm/stm32_common/src/hal_gpio.c
index 112c5aa0b..195db2422 100644
--- a/hw/mcu/stm/stm32_common/src/hal_gpio.c
+++ b/hw/mcu/stm/stm32_common/src/hal_gpio.c
@@ -775,6 +775,18 @@ hal_gpio_init_af(int pin, uint8_t af_type, enum hal_gpio_pull pull, uint8_t od)
return hal_gpio_init_stm(pin, &gpio);
}
+/**
+ * gpio init af
+ *
+ * Configure the specified pin for AF.
+ */
+int
+hal_gpio_init_fun(uint32_t pin)
+{
+ return hal_gpio_init_af(pin & 0xFF, (pin >> 12) & 0xF, (pin >> 8) & 3,
+ (pin >> 10) & 1);
+}
+
/**
* Deinitialize the specified pin to revert to default configuration
*