Skip to content

Commit 18659ab

Browse files
committed
STM32F0: manage better uart3 & 4 irqs
Manage the case where both uart3 and uart4 interrupts are arriving at the same time.
1 parent eaa3e9d commit 18659ab

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

targets/TARGET_STM/TARGET_STM32F0/serial_device.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,27 @@ static uart_irq_handler irq_handler;
5151
* INTERRUPTS HANDLING
5252
******************************************************************************/
5353

54-
static uint32_t uart_irq(int id)
54+
static void uart_irq(int id)
5555
{
5656
UART_HandleTypeDef * huart = &uart_handlers[id];
57-
uint32_t status = 0;
58-
5957
if (serial_irq_ids[id] != 0) {
6058
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_TXE) != RESET) {
6159
if (__HAL_UART_GET_IT(huart, UART_IT_TXE) != RESET) {
6260
irq_handler(serial_irq_ids[id], TxIrq);
63-
status = 1;
6461
}
6562
}
6663
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET) {
6764
if (__HAL_UART_GET_IT(huart, UART_IT_RXNE) != RESET) {
6865
irq_handler(serial_irq_ids[id], RxIrq);
69-
/* Flag has been cleared when reading the content */
70-
status = 1;
66+
/* Flag has been cleared when reading the content */
7167
}
7268
}
7369
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_ORE) != RESET) {
7470
if (__HAL_UART_GET_IT(huart, UART_IT_ORE) != RESET) {
7571
__HAL_UART_CLEAR_FLAG(huart, UART_CLEAR_OREF);
76-
status = 1;
7772
}
7873
}
7974
}
80-
81-
return status;
8275
}
8376

8477
static void uart1_irq(void)
@@ -128,9 +121,12 @@ static void uart3_8_irq(void)
128121
}
129122
#endif
130123
#else // TARGET_STM32F070RB, TARGET_STM32F072RB
131-
if (uart_irq(2) == 0) { // Check if it's USART3
132-
uart_irq(3); // Otherwise it's USART4
133-
}
124+
#if defined(USART3_BASE)
125+
uart_irq(2);
126+
#endif
127+
#if defined(USART4_BASE)
128+
uart_irq(3);
129+
#endif
134130
#endif
135131
}
136132

0 commit comments

Comments
 (0)