Skip to content

Commit 8594389

Browse files
iabdalkaderdpgeorge
authored andcommitted
stm32/fdcan: Use the right FIFO to calc element address in can_receive.
1 parent f5dd46b commit 8594389

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ports/stm32/fdcan.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,14 @@ int can_receive(FDCAN_HandleTypeDef *can, int fifo, FDCAN_RxHeaderTypeDef *hdr,
218218
}
219219

220220
// Get pointer to incoming message
221-
uint32_t index = (can->Instance->RXF0S & FDCAN_RXF0S_F0GI) >> 8;
222-
uint32_t *address = (uint32_t *)(can->msgRam.RxFIFO0SA + (index * can->Init.RxFifo0ElmtSize * 4));
221+
uint32_t index, *address;
222+
if (fifo == FDCAN_RX_FIFO0) {
223+
index = (*rxf & FDCAN_RXF0S_F0GI) >> FDCAN_RXF0S_F0GI_Pos;
224+
address = (uint32_t *)(can->msgRam.RxFIFO0SA + (index * can->Init.RxFifo0ElmtSize * 4));
225+
} else {
226+
index = (*rxf & FDCAN_RXF1S_F1GI) >> FDCAN_RXF1S_F1GI_Pos;
227+
address = (uint32_t *)(can->msgRam.RxFIFO1SA + (index * can->Init.RxFifo1ElmtSize * 4));
228+
}
223229

224230
// Parse header of message
225231
hdr->IdType = *address & FDCAN_ELEMENT_MASK_XTD;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy