Skip to content

Commit b0073bb

Browse files
authored
Merge pull request #10774 from fkjagodzinski/fix-uart_irq
Fix serial IRQ handling
2 parents e9e9bf3 + 8e3ca20 commit b0073bb

File tree

17 files changed

+34
-34
lines changed

17 files changed

+34
-34
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K66F/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
127127
}
128128

129129
if (serial_irq_ids[index] != 0) {
130-
if (transmit_empty)
130+
if (transmit_empty && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_TxDataRegEmptyInterruptEnable))
131131
irq_handler(serial_irq_ids[index], TxIrq);
132132

133-
if (receive_full)
133+
if (receive_full && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_RxDataRegFullInterruptEnable))
134134
irq_handler(serial_irq_ids[index], RxIrq);
135135
}
136136
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_K82F/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
152152
}
153153

154154
if (serial_irq_ids[index] != 0) {
155-
if (transmit_empty)
155+
if (transmit_empty && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_TxDataRegEmptyInterruptEnable))
156156
irq_handler(serial_irq_ids[index], TxIrq);
157157

158-
if (receive_full)
158+
if (receive_full && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_RxDataRegFullInterruptEnable))
159159
irq_handler(serial_irq_ids[index], RxIrq);
160160
}
161161
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL27Z/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
135135
}
136136

137137
if (serial_irq_ids[index] != 0) {
138-
if (transmit_empty)
138+
if (transmit_empty && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_TxDataRegEmptyInterruptEnable))
139139
irq_handler(serial_irq_ids[index], TxIrq);
140140

141-
if (receive_full)
141+
if (receive_full && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_RxDataRegFullInterruptEnable))
142142
irq_handler(serial_irq_ids[index], RxIrq);
143143
}
144144
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL43Z/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
135135
}
136136

137137
if (serial_irq_ids[index] != 0) {
138-
if (transmit_empty)
138+
if (transmit_empty && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_TxDataRegEmptyInterruptEnable))
139139
irq_handler(serial_irq_ids[index], TxIrq);
140140

141-
if (receive_full)
141+
if (receive_full && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_RxDataRegFullInterruptEnable))
142142
irq_handler(serial_irq_ids[index], RxIrq);
143143
}
144144
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KL82Z/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
154154
}
155155

156156
if (serial_irq_ids[index] != 0) {
157-
if (transmit_empty)
157+
if (transmit_empty && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_TxDataRegEmptyInterruptEnable))
158158
irq_handler(serial_irq_ids[index], TxIrq);
159159

160-
if (receive_full)
160+
if (receive_full && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_RxDataRegFullInterruptEnable))
161161
irq_handler(serial_irq_ids[index], RxIrq);
162162
}
163163
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW24D/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
127127
}
128128

129129
if (serial_irq_ids[index] != 0) {
130-
if (transmit_empty)
130+
if (transmit_empty && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_TxDataRegEmptyInterruptEnable))
131131
irq_handler(serial_irq_ids[index], TxIrq);
132132

133-
if (receive_full)
133+
if (receive_full && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_RxDataRegFullInterruptEnable))
134134
irq_handler(serial_irq_ids[index], RxIrq);
135135
}
136136
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_KW41Z/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
131131
}
132132

133133
if (serial_irq_ids[index] != 0) {
134-
if (transmit_empty)
134+
if (transmit_empty && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_TxDataRegEmptyInterruptEnable))
135135
irq_handler(serial_irq_ids[index], TxIrq);
136136

137-
if (receive_full)
137+
if (receive_full && (LPUART_GetEnabledInterrupts(uart_addrs[index]) & kLPUART_RxDataRegFullInterruptEnable))
138138
irq_handler(serial_irq_ids[index], RxIrq);
139139
}
140140
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K22F/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
127127
}
128128

129129
if (serial_irq_ids[index] != 0) {
130-
if (transmit_empty)
130+
if (transmit_empty && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_TxDataRegEmptyInterruptEnable))
131131
irq_handler(serial_irq_ids[index], TxIrq);
132132

133-
if (receive_full)
133+
if (receive_full && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_RxDataRegFullInterruptEnable))
134134
irq_handler(serial_irq_ids[index], RxIrq);
135135
}
136136
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K24F/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
140140
}
141141

142142
if (serial_irq_ids[index] != 0) {
143-
if (transmit_empty)
143+
if (transmit_empty && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_TxDataRegEmptyInterruptEnable))
144144
irq_handler(serial_irq_ids[index], TxIrq);
145145

146-
if (receive_full)
146+
if (receive_full && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_RxDataRegFullInterruptEnable))
147147
irq_handler(serial_irq_ids[index], RxIrq);
148148
}
149149
}

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ static inline void uart_irq(uint32_t transmit_empty, uint32_t receive_full, uint
140140
}
141141

142142
if (serial_irq_ids[index] != 0) {
143-
if (transmit_empty)
143+
if (transmit_empty && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_TxDataRegEmptyInterruptEnable))
144144
irq_handler(serial_irq_ids[index], TxIrq);
145145

146-
if (receive_full)
146+
if (receive_full && (UART_GetEnabledInterrupts(uart_addrs[index]) & kUART_RxDataRegFullInterruptEnable))
147147
irq_handler(serial_irq_ids[index], RxIrq);
148148
}
149149
}

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
}

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
}

targets/TARGET_STM/TARGET_STM32F7/serial_device.c

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

targets/TARGET_STM/TARGET_STM32H7/serial_device.c

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

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
}

targets/TARGET_STM/TARGET_STM32L4/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
}

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)