summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2020-06-30 22:59:28 +0200
committerDamien George <damien@micropython.org>2020-07-09 00:37:50 +1000
commit8594389fe75efc3903970db319f07f89fdb8c8cc (patch)
treeeb63d9cf9e5e294ba811d168c6916c2b0f266365
parentf5dd46b4791249c5989859b07c4886c69d8b98b3 (diff)
stm32/fdcan: Use the right FIFO to calc element address in can_receive.
-rw-r--r--ports/stm32/fdcan.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ports/stm32/fdcan.c b/ports/stm32/fdcan.c
index b3b1da998..bafc7e3f5 100644
--- a/ports/stm32/fdcan.c
+++ b/ports/stm32/fdcan.c
@@ -218,8 +218,14 @@ int can_receive(FDCAN_HandleTypeDef *can, int fifo, FDCAN_RxHeaderTypeDef *hdr,
}
// Get pointer to incoming message
- uint32_t index = (can->Instance->RXF0S & FDCAN_RXF0S_F0GI) >> 8;
- uint32_t *address = (uint32_t *)(can->msgRam.RxFIFO0SA + (index * can->Init.RxFifo0ElmtSize * 4));
+ uint32_t index, *address;
+ if (fifo == FDCAN_RX_FIFO0) {
+ index = (*rxf & FDCAN_RXF0S_F0GI) >> FDCAN_RXF0S_F0GI_Pos;
+ address = (uint32_t *)(can->msgRam.RxFIFO0SA + (index * can->Init.RxFifo0ElmtSize * 4));
+ } else {
+ index = (*rxf & FDCAN_RXF1S_F1GI) >> FDCAN_RXF1S_F1GI_Pos;
+ address = (uint32_t *)(can->msgRam.RxFIFO1SA + (index * can->Init.RxFifo1ElmtSize * 4));
+ }
// Parse header of message
hdr->IdType = *address & FDCAN_ELEMENT_MASK_XTD;