Skip to content

Commit b88b94e

Browse files
author
Filip Jagodzinski
committed
STM32L0: Fix serial IRQ handling
Check that the RX or TX interrupt is enabled before calling a registered handler with RxIrq or TxIrq arg.
1 parent c387bd8 commit b88b94e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

targets/TARGET_STM/TARGET_STM32L0/serial_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ static void uart_irq(UARTName uart_name)
6060
UART_HandleTypeDef *huart = &uart_handlers[id];
6161
if (serial_irq_ids[id] != 0) {
6262
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_TXE) != RESET) {
63-
if (__HAL_UART_GET_IT(huart, UART_IT_TXE) != RESET) {
63+
if (__HAL_UART_GET_IT(huart, UART_IT_TXE) != RESET && __HAL_UART_GET_IT_SOURCE(huart, UART_IT_TXE)) {
6464
irq_handler(serial_irq_ids[id], TxIrq);
6565
}
6666
}
6767
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) {
68-
if (__HAL_UART_GET_IT(huart, UART_IT_RXNE) != RESET) {
68+
if (__HAL_UART_GET_IT(huart, UART_IT_RXNE) != RESET && __HAL_UART_GET_IT_SOURCE(huart, UART_IT_RXNE)) {
6969
irq_handler(serial_irq_ids[id], RxIrq);
7070
/* Flag has been cleared when reading the content */
7171
}

0 commit comments

Comments
 (0)