From df766224fb04554db8b2428764652f6fc9b59927 Mon Sep 17 00:00:00 2001
From: darya
Date: Tue, 23 Jun 2026 09:48:46 +0300
Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?=
=?UTF-8?q?=D0=BD=D0=B8=D0=B5=2023.06.2026?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CanPorts.c | 23 +++++++++++++++++++----
CanPorts.h | 2 ++
2 files changed, 21 insertions(+), 4 deletions(-)
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