From d3391047d6f1f619db31a903f447afb7f7a9142c Mon Sep 17 00:00:00 2001 From: Tej Sharma Date: Thu, 10 Jul 2025 14:16:24 +0530 Subject: [PATCH] fix: remove CAN reinit when bus goes off, add api to restore busoff error --- .cproject | 5 +- .project | 12 +- .settings/org.eclipse.core.resources.prefs | 16 +++ Core/Source/ivec_mcal_mcan.c | 8 +- ivec_ECU/ivec_ecu_can/src/ivec_ecu_can.c | 5 +- mspm0g3507.lds | 4 +- targetConfigs/MSPM0G3507.ccxml | 139 ++++++++++++--------- 7 files changed, 112 insertions(+), 77 deletions(-) diff --git a/.cproject b/.cproject index f537f49..c174596 100644 --- a/.cproject +++ b/.cproject @@ -480,10 +480,9 @@ - + - - + diff --git a/.project b/.project index 4d5f51c..ff6ec8a 100644 --- a/.project +++ b/.project @@ -33,17 +33,7 @@ driverlib 2 - C:/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib - - - lib - 2 - C:/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/lib - - - m0p - 2 - C:/ti/mspm0_sdk_2_03_00_07/source/ti/driverlib/m0p + C:/ti/mspm0_sdk_2_05_00_05/source/ti/driverlib diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 51d1a5c..8ea1ea4 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -181,48 +181,64 @@ encoding//Test__GNU/Generated\ Codes/subdir_rules.mk=UTF-8 encoding//Test__GNU/Generated\ Codes/subdir_vars.mk=UTF-8 encoding//Test__GNU/TM1650_SDK/src/subdir_rules.mk=UTF-8 encoding//Test__GNU/TM1650_SDK/src/subdir_vars.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0c1105_c1106/subdir_rules.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0c1105_c1106/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0c110x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0c110x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0g1x0x_g3x0x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0gx51x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0gx51x/subdir_vars.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0h321x/subdir_rules.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0h321x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l111x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l111x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/gcc/m0p/mspm0l122x_l222x/subdir_vars.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0c1105_c1106/subdir_rules.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0c1105_c1106/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0c110x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0c110x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0g1x0x_g3x0x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0gx51x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0gx51x/subdir_vars.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0h321x/subdir_rules.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0h321x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l111x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l111x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/iar/m0p/mspm0l122x_l222x/subdir_vars.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0c1105_c1106/subdir_rules.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0c1105_c1106/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0c110x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0c110x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0g1x0x_g3x0x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0gx51x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0gx51x/subdir_vars.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0h321x/subdir_rules.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0h321x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l111x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l111x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l11xx_l13xx/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l122x_l222x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/keil/m0p/mspm0l122x_l222x/subdir_vars.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0c1105_c1106/subdir_rules.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0c1105_c1106/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0c110x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0c110x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0g1x0x_g3x0x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0g1x0x_g3x0x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0gx51x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0gx51x/subdir_vars.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0h321x/subdir_rules.mk=UTF-8 +encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0h321x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l111x/subdir_rules.mk=UTF-8 encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l111x/subdir_vars.mk=UTF-8 encoding//Test__GNU/driverlib/lib/ticlang/m0p/mspm0l11xx_l13xx/subdir_rules.mk=UTF-8 diff --git a/Core/Source/ivec_mcal_mcan.c b/Core/Source/ivec_mcal_mcan.c index 0f19a44..8bba39d 100644 --- a/Core/Source/ivec_mcal_mcan.c +++ b/Core/Source/ivec_mcal_mcan.c @@ -676,9 +676,13 @@ IVEC_McalCommonErr_e xMCAL_MCANGetErrorStatus(IVEC_McalCanHandle_s* pxCanHandle, DL_MCAN_getErrCounters(CANFD0, &l_xCounter); /* Return the status based on various error conditions */ - + if((g_xHeaderStat.lastErrCode == DL_MCAN_ERR_CODE_ACK_ERROR) || (g_xHeaderStat.busOffStatus)) + DL_MCAN_setOpMode(CANFD0, DL_MCAN_OPERATION_MODE_NORMAL); + return commonMCAL_SUCCESS; + /* return ( (g_xHeaderStat.lastErrCode == DL_MCAN_ERR_CODE_ACK_ERROR) || \ - (g_xHeaderStat.busOffStatus) ) ? IVEC_MCAL_STATUS_ERROR : IVEC_MCAL_STATUS_SUCCESS; + (g_xHeaderStat.busOffStatus) ) ? commonMCAL_FAIL : commonMCAL_SUCCESS; + */ } diff --git a/ivec_ECU/ivec_ecu_can/src/ivec_ecu_can.c b/ivec_ECU/ivec_ecu_can/src/ivec_ecu_can.c index 2cab220..b76328f 100644 --- a/ivec_ECU/ivec_ecu_can/src/ivec_ecu_can.c +++ b/ivec_ECU/ivec_ecu_can/src/ivec_ecu_can.c @@ -286,7 +286,7 @@ IVEC_EcuCommonErr_e xECU_CANGetStatus(IVEC_EcuCANHandle_s *xCanHandle) IVEC_EcuCommonErr_e l_eFuncStatus = commonECU_SUCCESS; if (xCanHandle->__xCanHandle.__u8Init == 0) { - l_eFuncStatus = commonMCAL_FAIL; + l_eFuncStatus = commonECU_FAIL; return l_eFuncStatus; } int8_t l_i8ErrorString[32] = {0}; @@ -295,7 +295,8 @@ IVEC_EcuCommonErr_e xECU_CANGetStatus(IVEC_EcuCANHandle_s *xCanHandle) if (xMCAL_MCANGetErrorStatus(&xCanHandle->__xCanHandle, l_i8ErrorString) == commonMCAL_FAIL) { /* Reinitialize CAN if an error is detected */ - l_eFuncStatus = xECU_CANReInit(xCanHandle); + //l_eFuncStatus = xECU_CANReInit(xCanHandle); + l_eFuncStatus = commonECU_FAIL; } return l_eFuncStatus; } diff --git a/mspm0g3507.lds b/mspm0g3507.lds index 97562bf..ccb3787 100644 --- a/mspm0g3507.lds +++ b/mspm0g3507.lds @@ -7,7 +7,7 @@ _Min_Stack_Size = 0x000012E8; /* required amount of stack */ /* Specify the memory areas */ MEMORY { - FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x00020000 + FLASH (RX) : ORIGIN = 0x00008000, LENGTH = 0x00018000 SRAM (RWX) : ORIGIN = 0x20200000, LENGTH = 0x00008000 BCR_CONFIG (R) : ORIGIN = 0x41C00000, LENGTH = 0x00000080 BSL_CONFIG (R) : ORIGIN = 0x41C00100, LENGTH = 0x00000080 @@ -33,7 +33,7 @@ SECTIONS { /* section for the interrupt vector area */ PROVIDE (_intvecs_base_address = - DEFINED(_intvecs_base_address) ? _intvecs_base_address : 0x00000000); + DEFINED(_intvecs_base_address) ? _intvecs_base_address : 0x00008000); .intvecs (_intvecs_base_address) : AT (_intvecs_base_address) { KEEP (*(.intvecs)) diff --git a/targetConfigs/MSPM0G3507.ccxml b/targetConfigs/MSPM0G3507.ccxml index 1e2b287..58856c2 100644 --- a/targetConfigs/MSPM0G3507.ccxml +++ b/targetConfigs/MSPM0G3507.ccxml @@ -1,60 +1,123 @@ - + + - + + - + + - + + - + + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -72,75 +135,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + - + + - + + - + +