#include "CLS_BSP.h"


#ifdef CLS_BSP_FDCAN

HAL_StatusTypeDef CLS_BSP_CAN_AddMessageToSend(CLS_BSP_TxHeaderType * header, uint8_t * data) {
    if (HAL_FDCAN_GetTxFifoFreeLevel(&hfdcan1) > 0) {
        return HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, header, data);
    }
    return HAL_ERROR;
}


HAL_StatusTypeDef CLS_BSP_CAN_SetUniversalFilter(const CLS_BSP_CAN_UniversalFilter * filter) {
    FDCAN_FilterTypeDef sFilterConfig;
    sFilterConfig.IdType = FDCAN_STANDARD_ID;
    sFilterConfig.FilterIndex = filter->filterIndex;
    sFilterConfig.FilterType = filter->filterMode;
    sFilterConfig.FilterConfig = filter->filterDestination;
    sFilterConfig.FilterID1 = filter->id0;
    sFilterConfig.FilterID2 = filter->id1;
    return HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig);
}

#endif



