#pragma once #define CLS_BSP_FDCAN #ifdef CLS_BSP_FDCAN #include "fdcan.h" #include "CLS.h" typedef FDCAN_TxHeaderTypeDef CLS_BSP_TxHeaderType; #define CREATE_BSP_CAN_HEADER(identifier, datalength) \ { \ .IdType = FDCAN_STANDARD_ID, \ .Identifier = identifier, \ .TxFrameType = FDCAN_DATA_FRAME, \ .DataLength = datalength, \ .ErrorStateIndicator = FDCAN_ESI_PASSIVE, \ .BitRateSwitch = FDCAN_BRS_OFF, \ .FDFormat = FDCAN_CLASSIC_CAN, \ .TxEventFifoControl = FDCAN_NO_TX_EVENTS, \ .MessageMarker = 0xCC, \ } #define CLS_BSP_DLC_BYTES_1 FDCAN_DLC_BYTES_1 #define CLS_BSP_DLC_BYTES_2 FDCAN_DLC_BYTES_2 #define CLS_BSP_DLC_BYTES_3 FDCAN_DLC_BYTES_3 #define CLS_BSP_DLC_BYTES_4 FDCAN_DLC_BYTES_4 #define CLS_BSP_DLC_BYTES_5 FDCAN_DLC_BYTES_5 #define CLS_BSP_DLC_BYTES_6 FDCAN_DLC_BYTES_6 #define CLS_BSP_DLC_BYTES_7 FDCAN_DLC_BYTES_7 #define CLS_BSP_DLC_BYTES_8 FDCAN_DLC_BYTES_8 // function to convert DLC to bytes uint8_t CLS_BSP_DLC_ToBytes(uint32_t dlc); #define CLS_CAN_FILTER_DISABLE FDCAN_FILTER_DISABLE #define CLS_CAN_FILTER_TO_RXFIFO0 FDCAN_FILTER_TO_RXFIFO0 #define CLS_CAN_FILTER_TO_RXFIFO1 FDCAN_FILTER_TO_RXFIFO1 #define CLS_BSP_CAN_FILTER_LIST FDCAN_FILTER_DUAL #endif typedef struct { uint32_t filterIndex; uint32_t filterDestination; uint32_t filterMode; uint16_t id0; uint16_t id1; } CLS_BSP_CAN_UniversalFilter; HAL_StatusTypeDef CLS_BSP_CAN_AddMessageToSend(CLS_BSP_TxHeaderType * header, uint8_t * data); HAL_StatusTypeDef CLS_BSP_CAN_SetUniversalFilter(const CLS_BSP_CAN_UniversalFilter * filter); CLS_Type_t CLS_BSP_GetDeviceType(void); void CLS_BSP_SetDeviceType(CLS_Type_t type); CLS_Position_t CLS_BSP_GetPosition(void); void CLS_BSP_SetPosition(CLS_Position_t position);