Skip to content

Commit c387bd8

Browse files
author
Filip Jagodzinski
committed
STM32F0: 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 8438416 commit c387bd8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

targets/TARGET_STM/TARGET_STM32F0/serial_device.c

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

0 commit comments

Comments
 (0)