Skip to content

Commit 14b83e7

Browse files
author
Filip Jagodzinski
committed
STM32WB: 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 53222fa commit 14b83e7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

targets/TARGET_STM/TARGET_STM32WB/serial_device.c

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

0 commit comments

Comments
 (0)