aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader2020-06-30 23:08:20 +0200
committerDamien George2020-07-09 00:38:40 +1000
commitd07073f4e2f37d9614340f7544985dfee834532e (patch)
tree5e7ce537b29c861731b40fbce007135ff22f960a
parent63b2eb27d44a9beb9f66abd77d3b6526fdb2482d (diff)
stm32/fdcan: Support maximum timeout of HAL_MAX_DELAY in can_receive.
-rw-r--r--ports/stm32/fdcan.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ports/stm32/fdcan.c b/ports/stm32/fdcan.c
index 3ab72cdac..2892572f4 100644
--- a/ports/stm32/fdcan.c
+++ b/ports/stm32/fdcan.c
@@ -215,10 +215,12 @@ int can_receive(FDCAN_HandleTypeDef *can, int fifo, FDCAN_RxHeaderTypeDef *hdr,
// Wait for a message to become available, with timeout
uint32_t start = HAL_GetTick();
while ((*rxf & fl) == 0) {
- MICROPY_EVENT_POLL_HOOK
- if (HAL_GetTick() - start >= timeout_ms) {
- return -MP_ETIMEDOUT;
+ if (timeout_ms != HAL_MAX_DELAY) {
+ if (HAL_GetTick() - start >= timeout_ms) {
+ return -MP_ETIMEDOUT;
+ }
}
+ MICROPY_EVENT_POLL_HOOK
}
// Get pointer to incoming message