From dce79a086e6b6d47b3340a4d9b05abb2a62b3a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vegard=20W=C3=A6rp?= Date: Wed, 18 Nov 2026 10:34:20 +0100 Subject: [PATCH] stm: correct alternate functions in six pin tables Checking every I2C, SPI, UART and timer entry in the STM pin tables against ST's pin data (STM32_open_pin_data) found 33 entries in six tables whose alternate function doesn't connect the signal to the pin: - F401, F411, F412Zx, F446: TIM10_CH1 on PB8 and TIM11_CH1 on PB9 are AF3, not AF2, which selects TIM4. - F401: SPI4_NSS isn't available on PB12 (it is on the F411); removed. - L433: USART2_RX on PA15 is AF3, not AF7. - L433, L4R5: TIM15 and TIM16 are AF14, not AF15 (EVENTOUT). - L4R5: UART4 and UART5 are AF8, not AF9. PWMOut on a pin that got one of these timers had no output, and UART4 and UART5 on the L4R5 didn't work. Co-Authored-By: Claude Opus 5.5 --- .../peripherals/stm32f4/stm32f401xe/periph.c | 7 ++-- .../peripherals/stm32f4/stm32f401xe/periph.h | 2 +- .../peripherals/stm32f4/stm32f411xe/periph.c | 4 +-- .../peripherals/stm32f4/stm32f412zx/periph.c | 4 +-- .../peripherals/stm32f4/stm32f446xx/periph.c | 4 +-- .../peripherals/stm32l4/stm32l433xx/periph.c | 14 ++++---- .../peripherals/stm32l4/stm32l4r5xx/periph.c | 34 +++++++++---------- 7 files changed, 34 insertions(+), 35 deletions(-) diff --git a/ports/stm/peripherals/stm32f4/stm32f401xe/periph.c b/ports/stm/peripherals/stm32f4/stm32f401xe/periph.c index a5589c51f4d..dccc23cf9ef 100644 --- a/ports/stm/peripherals/stm32f4/stm32f401xe/periph.c +++ b/ports/stm/peripherals/stm32f4/stm32f401xe/periph.c @@ -67,14 +67,13 @@ const mcu_periph_obj_t mcu_spi_miso_list[8] = { PERIPH(4, 5, &pin_PE13), }; -const mcu_periph_obj_t mcu_spi_nss_list[9] = { +const mcu_periph_obj_t mcu_spi_nss_list[8] = { PERIPH(1, 5, &pin_PA04), PERIPH(1, 5, &pin_PA15), PERIPH(2, 5, &pin_PB09), PERIPH(2, 5, &pin_PB12), PERIPH(3, 6, &pin_PA04), PERIPH(3, 6, &pin_PA15), - PERIPH(4, 6, &pin_PB12), PERIPH(4, 5, &pin_PE04), PERIPH(4, 5, &pin_PE11), }; @@ -132,9 +131,9 @@ const mcu_tim_pin_obj_t mcu_tim_pin_list[44] = { TIM(4, 2, 1, &pin_PB06), TIM(4, 2, 2, &pin_PB07), TIM(4, 2, 3, &pin_PB08), - TIM(10, 2, 1, &pin_PB08), + TIM(10, 3, 1, &pin_PB08), TIM(4, 2, 4, &pin_PB09), - TIM(11, 2, 1, &pin_PB09), + TIM(11, 3, 1, &pin_PB09), TIM(2, 1, 3, &pin_PB10), TIM(3, 2, 1, &pin_PC06), TIM(3, 2, 2, &pin_PC07), diff --git a/ports/stm/peripherals/stm32f4/stm32f401xe/periph.h b/ports/stm/peripherals/stm32f4/stm32f401xe/periph.h index 6aa77eeb8ab..6d7101168e7 100644 --- a/ports/stm/peripherals/stm32f4/stm32f401xe/periph.h +++ b/ports/stm/peripherals/stm32f4/stm32f401xe/periph.h @@ -18,7 +18,7 @@ extern SPI_TypeDef *mcu_spi_banks[4]; extern const mcu_periph_obj_t mcu_spi_sck_list[9]; extern const mcu_periph_obj_t mcu_spi_mosi_list[9]; extern const mcu_periph_obj_t mcu_spi_miso_list[8]; -extern const mcu_periph_obj_t mcu_spi_nss_list[9]; +extern const mcu_periph_obj_t mcu_spi_nss_list[8]; // UART extern USART_TypeDef *mcu_uart_banks[MAX_UART]; diff --git a/ports/stm/peripherals/stm32f4/stm32f411xe/periph.c b/ports/stm/peripherals/stm32f4/stm32f411xe/periph.c index 0b53ae52758..3e170c0be69 100644 --- a/ports/stm/peripherals/stm32f4/stm32f411xe/periph.c +++ b/ports/stm/peripherals/stm32f4/stm32f411xe/periph.c @@ -153,9 +153,9 @@ const mcu_tim_pin_obj_t mcu_tim_pin_list[44] = { TIM(4, 2, 1, &pin_PB06), TIM(4, 2, 2, &pin_PB07), TIM(4, 2, 3, &pin_PB08), - TIM(10, 2, 1, &pin_PB08), + TIM(10, 3, 1, &pin_PB08), TIM(4, 2, 4, &pin_PB09), - TIM(11, 2, 1, &pin_PB09), + TIM(11, 3, 1, &pin_PB09), TIM(2, 1, 3, &pin_PB10), TIM(3, 2, 1, &pin_PC06), TIM(3, 2, 2, &pin_PC07), diff --git a/ports/stm/peripherals/stm32f4/stm32f412zx/periph.c b/ports/stm/peripherals/stm32f4/stm32f412zx/periph.c index caf8247e1a1..2ea6d8c3f7a 100644 --- a/ports/stm/peripherals/stm32f4/stm32f412zx/periph.c +++ b/ports/stm/peripherals/stm32f4/stm32f412zx/periph.c @@ -167,9 +167,9 @@ const mcu_tim_pin_obj_t mcu_tim_pin_list[60] = { TIM(4, 2, 1, &pin_PB06), TIM(4, 2, 2, &pin_PB07), TIM(4, 2, 3, &pin_PB08), - TIM(10, 2, 1, &pin_PB08), + TIM(10, 3, 1, &pin_PB08), TIM(4, 2, 4, &pin_PB09), - TIM(11, 2, 1, &pin_PB09), + TIM(11, 3, 1, &pin_PB09), TIM(2, 1, 3, &pin_PB10), TIM(2, 1, 4, &pin_PB11), TIM(12, 9, 1, &pin_PB14), diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c index 509b302c182..565c3991dc4 100644 --- a/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c @@ -98,9 +98,9 @@ const mcu_tim_pin_obj_t mcu_tim_pin_list[34] = { TIM(4, 2, 1, &pin_PB06), TIM(4, 2, 2, &pin_PB07), TIM(4, 2, 3, &pin_PB08), - TIM(10, 2, 1, &pin_PB08), + TIM(10, 3, 1, &pin_PB08), TIM(4, 2, 4, &pin_PB09), - TIM(11, 2, 1, &pin_PB09), + TIM(11, 3, 1, &pin_PB09), TIM(2, 1, 3, &pin_PB10), TIM(3, 2, 1, &pin_PC06), TIM(3, 2, 2, &pin_PC07), diff --git a/ports/stm/peripherals/stm32l4/stm32l433xx/periph.c b/ports/stm/peripherals/stm32l4/stm32l433xx/periph.c index e98c192c685..14eed76eb59 100644 --- a/ports/stm/peripherals/stm32l4/stm32l433xx/periph.c +++ b/ports/stm/peripherals/stm32l4/stm32l433xx/periph.c @@ -48,7 +48,7 @@ const mcu_periph_obj_t mcu_uart_tx_list[UART_TX_ARRAY_LEN] = { const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN] = { PERIPH(2, 7, &pin_PA03), PERIPH(1, 7, &pin_PA10), - PERIPH(2, 7, &pin_PA15), + PERIPH(2, 3, &pin_PA15), PERIPH(1, 7, &pin_PB07), PERIPH(3, 7, &pin_PB11), }; @@ -60,22 +60,22 @@ const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN] = { TIM(2, 1, 1, &pin_PA00), TIM(2, 1, 2, &pin_PA01), TIM(2, 1, 3, &pin_PA02), - TIM(15, 15, 1, &pin_PA02), + TIM(15, 14, 1, &pin_PA02), TIM(2, 1, 4, &pin_PA03), - TIM(15, 15, 2, &pin_PA03), + TIM(15, 14, 2, &pin_PA03), TIM(2, 1, 1, &pin_PA05), - TIM(16, 15, 1, &pin_PA06), + TIM(16, 14, 1, &pin_PA06), TIM(1, 1, 1, &pin_PA08), TIM(1, 1, 2, &pin_PA09), TIM(1, 1, 3, &pin_PA10), TIM(1, 1, 4, &pin_PA11), TIM(2, 1, 1, &pin_PA15), TIM(2, 1, 2, &pin_PB03), - TIM(16, 15, 1, &pin_PB08), + TIM(16, 14, 1, &pin_PB08), TIM(2, 1, 3, &pin_PB10), TIM(2, 1, 4, &pin_PB11), - TIM(15, 15, 1, &pin_PB14), - TIM(15, 15, 2, &pin_PB15), + TIM(15, 14, 1, &pin_PB14), + TIM(15, 14, 2, &pin_PB15), }; // CAN diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c index 7a5d52e0c83..18d980043bf 100644 --- a/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c @@ -116,21 +116,21 @@ USART_TypeDef *mcu_uart_banks[MAX_UART] = {USART1, USART2, USART3, UART4, UART5} bool mcu_uart_has_usart[MAX_UART] = {true, true, true, false, false}; const mcu_periph_obj_t mcu_uart_tx_list[UART_TX_ARRAY_LEN] = { - PERIPH(4, 9, &pin_PA00), + PERIPH(4, 8, &pin_PA00), PERIPH(2, 7, &pin_PA02), PERIPH(1, 7, &pin_PA09), PERIPH(1, 7, &pin_PB06), PERIPH(3, 7, &pin_PB10), PERIPH(3, 7, &pin_PC04), PERIPH(3, 7, &pin_PC10), - PERIPH(4, 9, &pin_PC10), - PERIPH(5, 9, &pin_PC12), + PERIPH(4, 8, &pin_PC10), + PERIPH(5, 8, &pin_PC12), PERIPH(2, 7, &pin_PD05), PERIPH(3, 7, &pin_PD08), PERIPH(1, 7, &pin_PG09), }; const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN] = { - PERIPH(4, 9, &pin_PA01), + PERIPH(4, 8, &pin_PA01), PERIPH(2, 7, &pin_PA03), PERIPH(1, 7, &pin_PA10), PERIPH(2, 3, &pin_PA15), @@ -138,8 +138,8 @@ const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN] = { PERIPH(3, 7, &pin_PB11), PERIPH(3, 7, &pin_PC05), PERIPH(3, 7, &pin_PC11), - PERIPH(4, 9, &pin_PC11), - PERIPH(5, 9, &pin_PD02), + PERIPH(4, 8, &pin_PC11), + PERIPH(5, 8, &pin_PD02), PERIPH(2, 7, &pin_PD06), PERIPH(3, 7, &pin_PD09), PERIPH(1, 7, &pin_PG10), @@ -156,13 +156,13 @@ const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN] = { TIM(5, 2, 2, &pin_PA01), TIM(2, 1, 3, &pin_PA02), TIM(5, 2, 3, &pin_PA02), - TIM(15, 15, 1, &pin_PA02), + TIM(15, 14, 1, &pin_PA02), TIM(2, 1, 4, &pin_PA03), TIM(5, 2, 4, &pin_PA03), - TIM(15, 15, 2, &pin_PA03), + TIM(15, 14, 2, &pin_PA03), TIM(2, 1, 1, &pin_PA05), TIM(3, 2, 1, &pin_PA06), - TIM(16, 15, 1, &pin_PA06), + TIM(16, 14, 1, &pin_PA06), TIM(3, 2, 2, &pin_PA07), // TIM(17, 15, 1, &pin_PA07), // peripheral indices are 1 based, stored 0-based with 4 bits available. TIM(1, 1, 1, &pin_PA08), @@ -178,13 +178,13 @@ const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN] = { TIM(4, 2, 1, &pin_PB06), TIM(4, 2, 2, &pin_PB07), TIM(4, 2, 3, &pin_PB08), - TIM(16, 15, 1, &pin_PB08), + TIM(16, 14, 1, &pin_PB08), TIM(4, 2, 4, &pin_PB09), // TIM(17, 15, 1, &pin_PB09), // peripheral indices are 1 based, stored 0-based with 4 bits available. TIM(2, 1, 3, &pin_PB10), TIM(2, 1, 4, &pin_PB11), - TIM(15, 15, 1, &pin_PB14), - TIM(15, 15, 2, &pin_PB15), + TIM(15, 14, 1, &pin_PB14), + TIM(15, 14, 2, &pin_PB15), TIM(3, 2, 1, &pin_PC06), TIM(8, 3, 1, &pin_PC06), TIM(3, 2, 2, &pin_PC07), @@ -197,7 +197,7 @@ const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN] = { TIM(4, 2, 2, &pin_PD13), TIM(4, 2, 3, &pin_PD14), TIM(4, 2, 4, &pin_PD15), - TIM(16, 15, 1, &pin_PE00), + TIM(16, 14, 1, &pin_PE00), // TIM(17, 15, 1, &pin_PE01), // peripheral indices are 1 based, stored 0-based with 4 bits available. TIM(3, 2, 1, &pin_PE03), TIM(3, 2, 2, &pin_PE04), @@ -211,10 +211,10 @@ const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN] = { TIM(5, 2, 2, &pin_PF07), TIM(5, 2, 3, &pin_PF08), TIM(5, 2, 4, &pin_PF09), - TIM(15, 15, 1, &pin_PF09), - TIM(15, 15, 2, &pin_PF10), - TIM(15, 15, 1, &pin_PG10), - TIM(15, 15, 2, &pin_PG11), + TIM(15, 14, 1, &pin_PF09), + TIM(15, 14, 2, &pin_PF10), + TIM(15, 14, 1, &pin_PG10), + TIM(15, 14, 2, &pin_PG11), TIM(5, 2, 1, &pin_PH10), TIM(5, 2, 2, &pin_PH11), TIM(5, 2, 3, &pin_PH12),