diff options
author | iabdalkader <i.abdalkader@gmail.com> | 2020-06-30 23:04:57 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-07-09 00:38:33 +1000 |
commit | 63b2eb27d44a9beb9f66abd77d3b6526fdb2482d (patch) | |
tree | 4b15c9d75c1b9adcab3c4f404c008fed45cd2947 | |
parent | 8594389fe75efc3903970db319f07f89fdb8c8cc (diff) |
stm32/fdcan: Use FDCAN_RXFxS_FxFL instead of hard-coded value.
-rw-r--r-- | ports/stm32/fdcan.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ports/stm32/fdcan.c b/ports/stm32/fdcan.c index bafc7e3f5..3ab72cdac 100644 --- a/ports/stm32/fdcan.c +++ b/ports/stm32/fdcan.c @@ -200,17 +200,21 @@ void can_clearfilter(pyb_can_obj_t *self, uint32_t f, uint8_t bank) { int can_receive(FDCAN_HandleTypeDef *can, int fifo, FDCAN_RxHeaderTypeDef *hdr, uint8_t *data, uint32_t timeout_ms) { volatile uint32_t *rxf, *rxa; + uint32_t fl; + if (fifo == FDCAN_RX_FIFO0) { rxf = &can->Instance->RXF0S; rxa = &can->Instance->RXF0A; + fl = FDCAN_RXF0S_F0FL; } else { rxf = &can->Instance->RXF1S; rxa = &can->Instance->RXF1A; + fl = FDCAN_RXF1S_F1FL; } // Wait for a message to become available, with timeout uint32_t start = HAL_GetTick(); - while ((*rxf & 7) == 0) { + while ((*rxf & fl) == 0) { MICROPY_EVENT_POLL_HOOK if (HAL_GetTick() - start >= timeout_ms) { return -MP_ETIMEDOUT; |