Skip to content

Commit

Permalink
stm32/uart: Add support for UART10 when it's a USART.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Sep 13, 2023
1 parent a4d28e5 commit dc99840
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ports/stm32/stm32_it.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 14 additions & 1 deletion ports/stm32/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
) {
Expand Down

0 comments on commit dc99840

Please sign in to comment.