Skip to content

Commit

Permalink
drivers: uart: stm32: fix handling interrupt and async api in isr
Browse files Browse the repository at this point in the history
When using the uart driver with interrupt and async api
at the same time (instance for interrupt and instance for async),
the transmission complete interrupt was handled in the async
handling section, even when interrupt driven api is used.
This caused transmission to not work properly in interrupt mode.
The fix is to move the interrupt mode handling to the begginning
of the isr. If async mode is used then interrupt mode code
will not be run.

Signed-off-by: Shlomi Vaknin <[email protected]>
  • Loading branch information
shlomow authored and galak committed May 19, 2021
1 parent 1100326 commit 1b4f7e5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/serial/uart_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,12 @@ static void uart_stm32_isr(const struct device *dev)
{
struct uart_stm32_data *data = DEV_DATA(dev);

#ifdef CONFIG_UART_INTERRUPT_DRIVEN
if (data->user_cb) {
data->user_cb(dev, data->user_data);
}
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */

#ifdef CONFIG_UART_ASYNC_API
USART_TypeDef *UartInstance = UART_STRUCT(dev);

Expand Down Expand Up @@ -820,12 +826,6 @@ static void uart_stm32_isr(const struct device *dev)
/* Clear errors */
uart_stm32_err_check(dev);
#endif /* CONFIG_UART_ASYNC_API */

#ifdef CONFIG_UART_INTERRUPT_DRIVEN
if (data->user_cb) {
data->user_cb(dev, data->user_data);
}
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
}

#endif /* (CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API) */
Expand Down

0 comments on commit 1b4f7e5

Please sign in to comment.