Skip to content

Commit 08c7171

Browse files
authored
Merge pull request ARMmbed#15461 from pavels/master
TARGET_STM: only mask CAN rx interrupt after rx interrupt, not all CAN interrupts
2 parents 72f27ce + 47ec87e commit 08c7171

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

targets/TARGET_STM/can_api.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,13 +1216,13 @@ static void can_irq(CANName name, int id)
12161216
tmp1 = __HAL_CAN_MSG_PENDING(&CanHandle, CAN_FIFO0);
12171217
tmp2 = __HAL_CAN_GET_IT_SOURCE(&CanHandle, CAN_IT_FMP0);
12181218

1219-
// In legacy can (bxCAN and earlier), reading is the only way to clear rx interrupt. But can_read has mutex locks
1220-
// since mutexes cannot be used in ISR context, rx interrupt is masked here to temporary disable it
1221-
// rx interrupts will be unamsked in read operation. reads must be deffered to thread context.
1222-
// refer to the CAN receive interrupt problem due to mutex and resolution section of README doc.
1223-
__HAL_CAN_DISABLE_IT(&CanHandle, CAN_IT_FMP0);
1224-
12251219
if ((tmp1 != 0) && tmp2) {
1220+
// In legacy can (bxCAN and earlier), reading is the only way to clear rx interrupt. But can_read has mutex locks
1221+
// since mutexes cannot be used in ISR context, rx interrupt is masked here to temporary disable it
1222+
// rx interrupts will be unamsked in read operation. reads must be deffered to thread context.
1223+
// refer to the CAN receive interrupt problem due to mutex and resolution section of README doc.
1224+
__HAL_CAN_DISABLE_IT(&CanHandle, CAN_IT_FMP0);
1225+
12261226
irq_handler(can_irq_contexts[id], IRQ_RX);
12271227
}
12281228

0 commit comments

Comments
 (0)