Skip to content

Instantly share code, notes, and snippets.

@hello-world-dot-c
hello-world-dot-c / stm32_read_can_buffer.c
Created June 15, 2025 16:44
[STM32 read CAN FD buffer] #STM32 #embedded #CAN
uint32_t GetIndex = 0;
/* Calculate Rx FIFO 0 element index */
GetIndex += ((hfdcan->Instance->RXF0S & FDCAN_RXF0S_F0GI) >> FDCAN_RXF0S_F0GI_Pos);
/* Calculate Rx FIFO 0 element address */
RxAddress = (uint32_t *)(hfdcan->msgRam.RxFIFO0SA + (GetIndex * SRAMCAN_RF0_SIZE));
/* Retrieve IdType */
pRxHeader->IdType = *RxAddress & FDCAN_ELEMENT_MASK_XTD;