Skip to content

Commit d6a4821

Browse files
author
Filip Jagodzinski
committed
STM32F3: 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 b88b94e commit d6a4821

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

targets/TARGET_STM/TARGET_STM32F3/serial_device.c

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

0 commit comments

Comments
 (0)