diff --git a/ports/stm32/stm32_it.c b/ports/stm32/stm32_it.c index 7363e26e89..50fd56ecae 100644 --- a/ports/stm32/stm32_it.c +++ b/ports/stm32/stm32_it.c @@ -1015,6 +1015,14 @@ void UART10_IRQHandler(void) { } #endif +#if defined(USART10) +void USART10_IRQHandler(void) { + IRQ_ENTER(USART10_IRQn); + uart_irq_handler(10); + IRQ_EXIT(USART10_IRQn); +} +#endif + #endif #if defined(LPUART1) diff --git a/ports/stm32/uart.c b/ports/stm32/uart.c index 7a2a3a9580..1823596df1 100644 --- a/ports/stm32/uart.c +++ b/ports/stm32/uart.c @@ -491,9 +491,15 @@ bool uart_init(pyb_uart_obj_t *uart_obj, #if defined(MICROPY_HW_UART10_TX) && defined(MICROPY_HW_UART10_RX) case PYB_UART_10: uart_unit = 10; + #if defined(UART10) UARTx = UART10; irqn = UART10_IRQn; __HAL_RCC_UART10_CLK_ENABLE(); + #else + UARTx = USART10; + irqn = USART10_IRQn; + __HAL_RCC_USART10_CLK_ENABLE(); + #endif pins[0] = MICROPY_HW_UART10_TX; pins[1] = MICROPY_HW_UART10_RX; break; @@ -771,6 +777,13 @@ void uart_deinit(pyb_uart_obj_t *self) { __HAL_RCC_UART10_RELEASE_RESET(); __HAL_RCC_UART10_CLK_DISABLE(); #endif + #if defined(USART10) + } else if (self->uart_id == 10) { + HAL_NVIC_DisableIRQ(USART10_IRQn); + __HAL_RCC_USART10_FORCE_RESET(); + __HAL_RCC_USART10_RELEASE_RESET(); + __HAL_RCC_USART10_CLK_DISABLE(); + #endif #if defined(LPUART1) } else if (self->uart_id == PYB_LPUART_1) { #if defined(STM32G0) @@ -886,7 +899,7 @@ uint32_t uart_get_source_freq(pyb_uart_obj_t *self) { #if defined(UART9) || self->uart_id == 9 #endif - #if defined(UART10) + #if defined(UART10) || defined(USART10) || self->uart_id == 10 #endif ) {