diff --git a/CanPorts.c b/CanPorts.c index 1a2c933..4e94c73 100644 --- a/CanPorts.c +++ b/CanPorts.c @@ -14,6 +14,13 @@ tCanPorts CAN_PORTS; static void CAN0_ErrorInterrupt_CallBack(uint8_t u8CanIndex, FLEXCAN_ErrorInfoType *pErrorInfo) { + + if (pErrorInfo->u32ErrorValue & FLEXCAN_ESR1_BOFFINT_MASK) { + FLEXCAN_Stop(u8CanIndex); + FLEXCAN_DeInit(u8CanIndex); + vCanPort_InitCan0(); + } + FLEXCAN_ClrErrorInfo(u8CanIndex, pErrorInfo); PROCESS_UNUSED_VAR(u8CanIndex); PROCESS_UNUSED_VAR(pErrorInfo); @@ -24,6 +31,13 @@ static void CAN0_TxInterruptCallBackType(uint8_t u8CanIndex, uint8_t u8TxHandler } static void CAN1_ErrorInterrupt_CallBack(uint8_t u8CanIndex, FLEXCAN_ErrorInfoType *pErrorInfo) { + + if (pErrorInfo->u32ErrorValue & FLEXCAN_ESR1_BOFFINT_MASK) { + FLEXCAN_Stop(u8CanIndex); + FLEXCAN_DeInit(u8CanIndex); + vCanPort_InitCan1(); + } + FLEXCAN_ClrErrorInfo(u8CanIndex, pErrorInfo); PROCESS_UNUSED_VAR(u8CanIndex); PROCESS_UNUSED_VAR(pErrorInfo); @@ -182,7 +196,8 @@ const FLEXCAN_RxMbFilterType IdCanFilterFifoCan1[countIdCanFilterFifoCan1] = { }; #endif -static bool vCanPort_InitCan0() { + +bool vCanPort_InitCan0() { vCanPort_InitCAN0RxTxPin(); @@ -287,7 +302,7 @@ static void vCanPort_InitCAN1RxTxPin() { GPIO_InitPins(GPIO_A, &tGpioInitStruct); } -static bool vCanPort_InitCan1() { +bool vCanPort_InitCan1() { vCanPort_InitCAN1RxTxPin(); @@ -356,7 +371,7 @@ static bool vCanPort_InitCan1() { void CanPorts_Init(tLoggerInterface *logger) { - CAN_PORTS.Can0.reInit = false; + CAN_PORTS.Can0.reInitOne = false; bool result = vCanPort_InitCan0(); if (result) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Initialization CAN0 - OK") @@ -365,7 +380,7 @@ void CanPorts_Init(tLoggerInterface *logger) { } CAN_PORTS.Can0_IO = CanPortFrame_GetIo(&CAN_PORTS.Can0); - CAN_PORTS.Can1.reInit = false; + CAN_PORTS.Can1.reInitOne = false; result = vCanPort_InitCan1(); if (result) { diff --git a/CanPorts.h b/CanPorts.h index 720ccd5..046cade 100644 --- a/CanPorts.h +++ b/CanPorts.h @@ -31,5 +31,7 @@ typedef struct { extern tCanPorts CAN_PORTS; void CanPorts_Init(tLoggerInterface *logger); +bool vCanPort_InitCan0(); +bool vCanPort_InitCan1(); #endif //SMART_COMPONENTS_CANPORTS_H