/********************************************************************************************************************** * COPYRIGHT * ------------------------------------------------------------------------------------------------------------------- * \verbatim * Copyright (c) 2025 by Vector Informatik GmbH. All rights reserved. * * This software is copyright protected and proprietary to Vector Informatik GmbH. * Vector Informatik GmbH grants to you only those rights as set out in the license conditions. * All other rights remain with Vector Informatik GmbH. * \endverbatim * ------------------------------------------------------------------------------------------------------------------- * FILE DESCRIPTION * -----------------------------------------------------------------------------------------------------------------*/ /** \file File: BrsMain_Appl.c * Project: Vector Basic Runtime System * Module: BrsMain * * \brief Description: Additional, Application-specific, implementation * * \attention Please note: * The demo and example programs only show special aspects of the software. With regard to the fact * that these programs are meant for demonstration purposes only, Vector Informatik liability shall be * expressly excluded in cases of ordinary negligence, to the extent admissible by law or statute. *********************************************************************************************************************/ /********************************************************************************************************************** * REVISION HISTORY * ------------------------------------------------------------------------------------------------------------------- * Refer to BrsMain.h. *********************************************************************************************************************/ /********************************************************************************************************************** * EXAMPLE CODE ONLY * ------------------------------------------------------------------------------------------------------------------- * This Example Code is only intended for illustrating an example of a possible BSW integration and BSW configuration. * The Example Code has not passed any quality control measures and may be incomplete. The Example Code is neither * intended nor qualified for use in series production. The Example Code as well as any of its modifications and/or * implementations must be tested with diligent care and must comply with all quality requirements which are necessary * according to the state of the art before their use. *********************************************************************************************************************/ #define _BRSMAIN_APPL_C_ /********************************************************************************************************************** * INCLUDES *********************************************************************************************************************/ #include "BrsMain_Appl.h" #if defined (BRS_ENABLE_SCHM_STUB_GENERATION) /* needed for SuspendAllInterrupts() and ResumeAllInterrupts() of SchM stub wrapper APIs * BrsMain_Appl_SuspendAllInterrupts() and BrsMain_Appl_ResumeAllInterrupts() */ #include "Os.h" #endif #if defined (BRS_ENABLE_HYPERVISOR_SUPPORT) && defined (BRS_ENABLE_OS_MULTICORESUPPORT) /* Needed for BrsMain_CoreConfig[] and BrsMain_CoreConfig_Size */ #include "vBrs_Lcfg.h" #endif #if !defined (BRSMAINAPPL_DISABLE_CAN_EXCLUSIVEAREA_HANDLING) # if defined (BRS_ENABLE_CAN_SUPPORT) && defined (BRS_ENABLE_CAN_CLASSIC_SUPPORT) /* with vCan drivers, only Can_30_Core.h needs to be included (see BrsMain_Appl.h) */ #include BRS_DRVCAN_HEADER_FILENAME # if defined (BRS_DRVCAN1_HEADER_FILENAME) #include BRS_DRVCAN1_HEADER_FILENAME # endif # endif #endif /********************************************************************************************************************** * VERSION CHECK *********************************************************************************************************************/ #if (BRSMAIN_MAJOR_VERSION != 2u) || (BRSMAIN_MINOR_VERSION != 27u) #error "Header and source file are inconsistent!" #endif #if (BRSMAIN_PATCH_VERSION != 0u) #error "Different versions of patch in Header and Source used!" #endif /********************************************************************************************************************** * CONFIGURATION CHECK *********************************************************************************************************************/ /* COMPILER CHECK */ /* Check if the DaVinci configured compiler fits to the used buildenvironment */ #if defined (VVIRTUALTARGET) /* For vVirtualTarget, the compier should always be configured to Ansi. This is related to BRS_COMPILER_DFDD3B47_BB56_4B45_BEC9_BE0B2C58DC11. But, as no MakeSupport is used for vVirtualTarget, we do not need to check this here. */ #else # if defined (BRS_COMPILER_UNDEFINED) #error "No compiler is configured in DaVinci!" #error "As several parts of vBaseEnv are compiler dependent, proper usage without a compiler selection is not possible." # endif # if defined (BRS_COMP_ARM5) && !defined (BRS_COMPILER_ACA8C365_6D1E_49FA_97F8_792D81C79C74) #error "Buildenvironment for Arm5 compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_ARM6) && !defined (BRS_COMPILER_89D464F1_ECCF_4306_A854_BF45FB1D7441) #error "Buildenvironment for Arm6 compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_ARMTFE) && !defined (BRS_COMPILER_B052FFB3_EA77_4E0B_ACB8_A77A4A0F24E8) #error "Buildenvironment for ArmTfE compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_CCAC) && !defined (BRS_COMPILER_2526EC26_414A_4091_91D0_0442AF47D241) #error "Buildenvironment for Ccac compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_DIABDATA) && !defined (BRS_COMPILER_44266E21_0E8C_4DDA_B800_91CE20104931) #error "Buildenvironment for DiabData compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_GCCHIGHTEC) && !defined (BRS_COMPILER_E7BC1F6B_0DF4_4345_BE50_A9AE95AF99A7) #error "Buildenvironment for GccHighTec compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_GCCNXP) && !defined (BRS_COMPILER_E832C52E_6625_4C6A_96D2_0BD6FFD35ECE) #error "Buildenvironment for GccNxp compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_GHS) && !defined (BRS_COMPILER_BBC47DF5_C78B_4E8E_8F86_0EF503FD3198) #error "Buildenvironment for GreenHills compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_GNU) && !defined (BRS_COMPILER_1350F673_6EFC_4394_917C_52F584E83ACE) #error "Buildenvironment for GccGnu compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_IAR) && !defined (BRS_COMPILER_FA51A718_3ADB_438D_98F3_245101681392) #error "Buildenvironment for Iar compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_LLVMDIAB) && !defined (BRS_COMPILER_E0E70C27_10E6_4169_9D2C_B9CAA4649C65) #error "Buildenvironment for LlvmDiabData compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_LLVMHIGHTEC) && !defined (BRS_COMPILER_BEBEB212_6307_4BD8_A274_A517B187644E) #error "Buildenvironment for LlvmHighTec compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_LLVMTEXASINSTRUMENTS) && !defined (BRS_COMPILER_051C3D73_B474_4677_9754_FBA372BF80EC) #error "Buildenvironment for LlvmTexasInstruments compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_MICROCHIP) && !defined (BRS_COMPILER_82CA3A19_9A7A_49D6_9EFE_39486D0F6510) #error "Buildenvironment for MicroChip compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_RENESAS) && !defined (BRS_COMPILER_5BCBEFDE_F5D2_49AA_B4DD_04AC02CE5A9A) #error "Buildenvironment for Renesas compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_TASKING) && !defined (BRS_COMPILER_8DB6C5C5_6807_4601_B7B7_68A4A5B277F6) #error "Buildenvironment for Tasking compiler is used, but DaVinci is configured for a different compiler!" # endif # if defined (BRS_COMP_TI) && !defined (BRS_COMPILER_B961F280_648C_45FF_A994_700EDE3B9F78) #error "Buildenvironment for TexasInstruments compiler is used, but DaVinci is configured for a different compiler!" # endif #endif /* VVIRTUALTARGET */ /* If the template version for BrsHw is not at least 01.03.13, Hypervisor Multicore configuration is not supported. */ #if defined (BRS_ENABLE_HYPERVISOR_SUPPORT) && defined (BRS_ENABLE_OS_MULTICORESUPPORT) /* BRSHW_SOURCECODE_TEMPLATE_VERSION_COMBINED was introduced in Brs_Template 1.04.00 - no check needed */ # if !defined (BRSHW_SOURCECODE_TEMPLATE_VERSION_COMBINED) # if (BRSHW_SOURCECODE_TEMPLATE_VERSION < 0x0103) || ((BRSHW_SOURCECODE_TEMPLATE_VERSION == 0x0103) && \ (BRSHW_SOURCECODE_TEMPLATE_BUGFIX_VERSION < 0x13)) #error "Hypervisor Multicore is only supported with Brs_Template[01.03.13] onwards." # endif # endif #endif /********************************************************************************************************************** * DEFINITION + MACROS *********************************************************************************************************************/ /********************************************************************************************************************** * GLOBAL VARIABLES *********************************************************************************************************************/ #if !defined (BRSMAINAPPL_DISABLE_CAN_EXCLUSIVEAREA_HANDLING) # if defined (BRS_ENABLE_CAN_SUPPORT) && (!defined (BRS_ENABLE_FBL_SUPPORT)) # if defined (BRS_ENABLE_CAN_CLASSIC_SUPPORT) #define CAN_START_SEC_VAR_NOINIT_8BIT /* * to support CAN driver name infix, vBRS generator provides a wrapper * for usage of the driver specific MemMap.h define in vBrsCfg.h */ #include "vBrsCfg.h" static uint8 BrsAsrApplCanInterruptLockCtr; #define CAN_STOP_SEC_VAR_NOINIT_8BIT /* * to support CAN driver name infix, vBRS generator provides a wrapper * for usage of the driver specific MemMap.h define in vBrsCfg.h */ #include "vBrsCfg.h" # endif /* BRS_ENABLE_CAN_CLASSIC_SUPPORT */ # endif /* BRS_ENABLE_CAN_SUPPORT && !BRS_ENABLE_FBL_SUPPORT */ #endif /* !BRSMAINAPPL_DISABLE_CAN_EXCLUSIVEAREA_HANDLING */ /********************************************************************************************************************** * GLOBAL CONST VARIABLES *********************************************************************************************************************/ #if defined (BRS_FBL_INSTANCE_FBL) /********************************************************************************************************************** * FBL Instance Presence Pattern * This presence pattern is only required when downloading the FBL with debugger. When using an updater (or an EOL * programmer), this presence pattern is not required as part of the .hex file and should be removed. *********************************************************************************************************************/ #define BRS_START_SEC_FBL_PP_CONST #include "Brs_MemMap.h" const uint8 FblPresencePatternArray[4] = {0x73u, 0x6Au, 0x29u, 0x3Eu}; #define BRS_STOP_SEC_FBL_PP_CONST #include "Brs_MemMap.h" #endif /* BRS_FBL_INSTANCE_FBL */ /********************************************************************************************************************** * LOCAL VARIABLES *********************************************************************************************************************/ /********************************************************************************************************************** * LOCAL CONST VARIABLES *********************************************************************************************************************/ /********************************************************************************************************************** * PROTOTYPES OF GLOBAL FUNCTIONS *********************************************************************************************************************/ /********************************************************************************************************************** * PROTOTYPES OF LOCAL FUNCTIONS *********************************************************************************************************************/ /********************************************************************************************************************** * FUNCTION DEFINITIONS *********************************************************************************************************************/ /*****************************************************************************/ /* @brief Main initialization routine. * Contains configuration specific initialization of BrsHw parts * and BrsMain specific mechanisms. * @pre - * @param[in] - * @param[out] - * @return - * @context Function is called from main *****************************************************************************/ void BrsMain_Appl_Init(void) { #if !defined (BRSMAINAPPL_DISABLE_CAN_EXCLUSIVEAREA_HANDLING) # if defined (BRS_ENABLE_CAN_SUPPORT) && (!defined (BRS_ENABLE_FBL_SUPPORT)) # if defined (BRS_ENABLE_CAN_CLASSIC_SUPPORT) /* UserDefined ExclusiveArea handling for CAN channels, according to AN-ISC-8-1149_ErrorHook_E_OS_DISABLED_INT.pdf */ BrsAsrApplCanInterruptLockCtr = 0u; # endif # endif #endif } #if defined (BRS_ENABLE_SCHM_STUB_GENERATION) # if defined (BRS_ENABLE_FBL_SUPPORT) #define BRS_START_SEC_RAM_CODE #include "Brs_MemMap.h" # endif /*****************************************************************************/ /* @brief Suspend all interrupts via OS call * @pre - * @param[in] - * @param[out] - * @return - * @context Function is used for SchM_Enter_* defines in vBrs generated * SchM stub module specific header files. This allows the user to * add project specific code. As default, SuspendAllInterrupts() is * defined empty within BrsMain provided Os.h stub for delieveries * w/o OS (no interrupt locking needed in polling environments) *****************************************************************************/ void BrsMain_Appl_SuspendAllInterrupts(void) { SuspendAllInterrupts(); } /*****************************************************************************/ /* @brief Resume all interrupts via OS call * @pre - * @param[in] - * @param[out] - * @return - * @context Function is used for SchM_Exit_* defines in vBrs generated * SchM stub module specific header files. This allows the user to * add project specific code. As default, ResumeAllInterrupts() is * defined empty within BrsMain provided Os.h stub for delieveries * w/o OS (no interrupt locking needed in polling environments) *****************************************************************************/ void BrsMain_Appl_ResumeAllInterrupts(void) { ResumeAllInterrupts(); } # if defined (BRS_ENABLE_FBL_SUPPORT) #define BRS_STOP_SEC_RAM_CODE #include "Brs_MemMap.h" # endif #endif /* BRS_ENABLE_SCHM_STUB_GENERATION */ #if defined (BRS_ENABLE_HYPERVISOR_SUPPORT) /*****************************************************************************/ /* @brief Callout to let the additional configured cores started by the * boot core, if necessary. This is just an initial template and * may need project specific adaptions. It's called by every core. * @pre - * @param[in] coreID is the physical core ID of the actual running core * @param[out] - * @return - * @context Function is called from main, previously to vHyp_Init() *****************************************************************************/ void BrsMain_Appl_HypervisorStartCoreApi(uint32 coreID) { #if defined (BRS_ENABLE_OS_MULTICORESUPPORT) && (!defined (BRSHW_CORES_AUTOSTART)) /* * If additional cores need to be started by the boot core, this needs to be done previously to the call of * vHyp_Init(), to prevent issues, if boot core is not the same as vHyp init core (VHYP_CORE_INIT). * As vHyp_RegisterCore() will wait until the additional core reaches a sync barrier, all configured cores should be * started as early as possible. */ /* Check, if the actual running core is the boot core */ if (coreID == BRSHW_INIT_CORE_ID) { for (uint32 i = 0u; i < BrsMain_CoreConfig_Size; i++) { if (BrsMain_CoreConfig[i].PhysicalCoreId != BRSHW_INIT_CORE_ID) { BrsHw_StartCore(BrsMain_CoreConfig[i].PhysicalCoreId); } } } #endif /* BRS_ENABLE_OS_MULTICORESUPPORT && !BRSHW_CORES_AUTOSTART */ } /*****************************************************************************/ /* @brief Callout to implement user code previous to the call of * vHyp_Start(). This is just an initial template and may need * project specific adaptions. It's called by every core. * @pre - * @param[in] coreID is the physical core ID of the actual running core * @param[out] - * @return - * @context Function is called from main, previously to vHyp_Start() *****************************************************************************/ void BrsMain_Appl_HypervisorApi(uint32 coreID) { #if defined (BRS_ENABLE_OS_MULTICORESUPPORT) /* Check, if the actual running core is the vHyp init core */ if ((vHyp_CoreIdType)coreID == VHYP_CORE_INIT) { vHyp_CoreIdType core; for (core = 0; core < VHYP_CORE_COUNT; core++) { if (core != VHYP_CORE_INIT) { vHyp_RegisterCore(core); } } } #endif /* BRS_ENABLE_OS_MULTICORESUPPORT */ } #endif /* BRS_ENABLE_HYPERVISOR_SUPPORT */ #if !defined (BRSMAINAPPL_DISABLE_CAN_EXCLUSIVEAREA_HANDLING) # if defined (BRS_ENABLE_CAN_SUPPORT) # if defined (BRS_ENABLE_CAN_CLASSIC_SUPPORT) /********************************************************************************************************************** * A classic (non-Gen3) DrvCan is part of the configuration. "Oldschool" implementation is needed *********************************************************************************************************************/ /********************************************************************************************************************** * UserDefined ExclusiveArea handling for CAN channels, according to AN-ISC-8-1149_ErrorHook_E_OS_DISABLED_INT.pdf *********************************************************************************************************************/ /* * Macro is generated in vBrsCfg.h, to support drivers with infix. * Sample w/o infix: void SchM_Enter_Can_CAN_EXCLUSIVE_AREA_0(void) * Can_DisableControllerInterrupts(0u); * Sample w/ infix: void SchM_Enter_Can_30_Mcan_CAN_30_MCAN_EXCLUSIVE_AREA_0(void) * Can_30_Mcan_DisableControllerInterrupts(0u); */ #define CAN_START_SEC_CODE /* * to support CAN driver name infix, vBRS generator provides a wrapper * for usage of the driver specific MemMap.h define in vBrsCfg.h */ #include "vBrsCfg.h" BRS_DRVCAN_EXCLUSIVE_AREA_INFIX(Enter, EXCLUSIVE_AREA_0) { #if !defined (BRS_ENABLE_FBL_SUPPORT) if (++BrsAsrApplCanInterruptLockCtr == 1u) { BRS_DRVCAN_ControllerInterrupts_INFIX(Disable)(0u); } #endif } BRS_DRVCAN_EXCLUSIVE_AREA_INFIX(Exit, EXCLUSIVE_AREA_0) { #if !defined (BRS_ENABLE_FBL_SUPPORT) if (--BrsAsrApplCanInterruptLockCtr == 0u) { BRS_DRVCAN_ControllerInterrupts_INFIX(Enable)(0u); } #endif } BRS_DRVCAN_EXCLUSIVE_AREA_INFIX(Enter, EXCLUSIVE_AREA_6) { #if !defined (BRS_ENABLE_FBL_SUPPORT) if (++BrsAsrApplCanInterruptLockCtr == 1u) { BRS_DRVCAN_ControllerInterrupts_INFIX(Disable)(0u); } #endif } BRS_DRVCAN_EXCLUSIVE_AREA_INFIX(Exit, EXCLUSIVE_AREA_6) { #if !defined (BRS_ENABLE_FBL_SUPPORT) if (--BrsAsrApplCanInterruptLockCtr == 0u) { BRS_DRVCAN_ControllerInterrupts_INFIX(Enable)(0u); } #endif } #define CAN_STOP_SEC_CODE /* * to support CAN driver name infix, vBRS generator provides a wrapper * for usage of the driver specific MemMap.h define in vBrsCfg.h */ #include "vBrsCfg.h" # if !defined (BRS_ENABLE_FBL_SUPPORT) #define CANIF_START_SEC_CODE #include "MemMap.h" void SchM_Enter_CanIf_CANIF_EXCLUSIVE_AREA_0(void) { if (++BrsAsrApplCanInterruptLockCtr == 1u) { BRS_DRVCAN_ControllerInterrupts_INFIX(Disable)(0u); } } void SchM_Exit_CanIf_CANIF_EXCLUSIVE_AREA_0(void) { if (--BrsAsrApplCanInterruptLockCtr == 0u) { BRS_DRVCAN_ControllerInterrupts_INFIX(Enable)(0u); } } #define CANIF_STOP_SEC_CODE #include "MemMap.h" #define CANSM_START_SEC_CODE #include "MemMap.h" void SchM_Enter_CanSM_CANSM_EXCLUSIVE_AREA_4(void) { if (++BrsAsrApplCanInterruptLockCtr == 1u) { BRS_DRVCAN_ControllerInterrupts_INFIX(Disable)(0u); } } void SchM_Exit_CanSM_CANSM_EXCLUSIVE_AREA_4(void) { if (--BrsAsrApplCanInterruptLockCtr == 0u) { BRS_DRVCAN_ControllerInterrupts_INFIX(Enable)(0u); } } void SchM_Enter_CanSM_CANSM_EXCLUSIVE_AREA_1(void) { /* Protects against task interruptions -> no locking needed, because all main functions are on same task */ } void SchM_Exit_CanSM_CANSM_EXCLUSIVE_AREA_1(void) { /* Protects against task interruptions -> no locking needed, because all main functions are on same task */ } #define CANSM_STOP_SEC_CODE #include "MemMap.h" #define COMM_START_SEC_CODE #include "MemMap.h" void SchM_Enter_ComM_COMM_EXCLUSIVE_AREA_1(void) { /* Protects against task interruptions -> no locking needed, because all main functions are on same task */ } void SchM_Exit_ComM_COMM_EXCLUSIVE_AREA_1(void) { /* Protects against task interruptions -> no locking needed, because all main functions are on same task */ } #define COMM_STOP_SEC_CODE #include "MemMap.h" # endif /* !BRS_ENABLE_FBL_SUPPORT */ # endif /* BRS_ENABLE_CAN_CLASSIC_SUPPORT */ # if defined (BRS_ENABLE_CAN_CORE_SUPPORT) /********************************************************************************************************************** * A new (Gen3) DrvCan is part of the configuration. New implementation is needed *********************************************************************************************************************/ # if (Can_30_Core_IsHardwareCancelByApplOfGeneralFeature(0u) && Can_30_Core_IsHardwareLoopCheckOfGeneralFeature(0u)) /* If these do not exist, maybe Can_30_Core/Can/CanGeneral/CanConstantDataToDefine is deactivated. If so, please choose the suitable implementation manually */ # if !defined (BRS_ENABLE_FBL_SUPPORT) /* Within a FBL project, depending APIs are already available within Fbl_cw.c */ /********************************************************************************************************************** * Hardware Loop Check / Timeout Monitoring for CAN Driver, according to TechnicalReference_Can_30_Core.pdf, * chapter 2.8.2 *********************************************************************************************************************/ #define CAN_30_CORE_START_SEC_VAR_NOCACHE_INIT_32 # if defined (BRSMAIN_CAN_30_CORE_SPECIFIC_MEMMAP) #include "Can_30_Core_MemMap.h" # else #include "MemMap.h" # endif static uint32 BrsAsrApplCanTimerCount; #define CAN_30_CORE_STOP_SEC_VAR_NOCACHE_INIT_32 # if defined (BRSMAIN_CAN_30_CORE_SPECIFIC_MEMMAP) #include "Can_30_Core_MemMap.h" # else #include "MemMap.h" # endif #define CAN_30_CORE_START_SEC_CODE # if defined (BRSMAIN_CAN_30_CORE_SPECIFIC_MEMMAP) #include "Can_30_Core_MemMap.h" # else #include "MemMap.h" # endif void Appl_30_CoreCanTimerStart(uint8 Controller, uint8 source) { BrsAsrApplCanTimerCount = 0u; } void Appl_30_CoreCanTimerEnd(uint8 Controller, uint8 source) { /* nothing to be done here; BrsAsrApplCanTimerCount will be set to 0 by next call of Appl_30_CoreCanTimerStart() */ } Can_ReturnType Appl_30_CoreCanTimerLoop(uint8 Controller, uint8 source) { BrsAsrApplCanTimerCount++; if (BrsAsrApplCanTimerCount > 10000u) { /* timeout detected! Something seems to block the DrvCan */ return CAN_NOT_OK; } else return CAN_OK; } #define CAN_30_CORE_STOP_SEC_CODE # if defined (BRSMAIN_CAN_30_CORE_SPECIFIC_MEMMAP) #include "Can_30_Core_MemMap.h" # else #include "MemMap.h" # endif # endif /* !BRS_ENABLE_FBL_SUPPORT */ # else #error "Can_30_Core/Can/CanGeneral/CanHardwareCancelByAppl and/or Can_30_Core/Can/CanGeneral/CanHardwareLoopCheck are deactivated! If you really want to use customer specific exclusive area handling, implement them controller and project specific. The following APIs are only a generic sample and need to be adapted." /*********************************************************************************************************************** * UserDefined ExclusiveArea handling for CAN Driver Core, according to TechnicalReference_Can_30_Core.pdf, Note within * chapter 3.2 **********************************************************************************************************************/ /* * BE AWARE, THIS IS ONLY A SAMPLE IMPLEMENTATION! * To get a suitable implementation for your project, take account to the technical reference of Can_30_Core * and implement them according to your specific project settings. * The suitable implementation is highly configuration specific, e.g. amount of channels, postbuild, ... */ #define CAN_30_CORE_START_SEC_CODE # if defined (BRSMAIN_CAN_30_CORE_SPECIFIC_MEMMAP) #include "Can_30_Core_MemMap.h" # else #include "MemMap.h" # endif void SchM_Enter_Can_30_Core_CAN_30_CORE_EXCLUSIVE_AREA_6(void) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_DisableControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_DisableControllerInterrupts(ch); */ #endif } void SchM_Exit_Can_30_Core_CAN_30_CORE_EXCLUSIVE_AREA_6(void) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_EnableControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_EnableControllerInterrupts(ch); */ #endif } #define CAN_30_CORE_STOP_SEC_CODE # if defined (BRSMAIN_CAN_30_CORE_SPECIFIC_MEMMAP) #include "Can_30_Core_MemMap.h" # else #include "MemMap.h" # endif # if !defined (BRS_ENABLE_CAN_CLASSIC_SUPPORT) /* * If vCan and classic CAN is mixed within one config, the "old" DrvCan is expected to be the 1st one. So, the * exclusive areas are already implemented earlier in this file */ /********************************************************************************************************************** * UserDefined ExclusiveArea handling for vCAN Driver, according to TechnicalReference_vCan_30_Mcan.pdf, Note within * chapter 3.2 *********************************************************************************************************************/ /* * BE AWARE, THIS IS ONLY A SAMPLE IMPLEMENTATION! * To get a suitable implementation for your project, take account to the technical reference of your specific DrvCan * and implement them according to your specific project settings. * The suitable implementation is highly configuration specific, e.g. amount of channels, postbuild, ... */ #define CAN_START_SEC_CODE /* * to support CAN driver name infix, vBRS generator provides a wrapper * for usage of the driver specific MemMap.h define in vBrsCfg.h */ #include "vBrsCfg.h" BRS_DRVCAN_EXCLUSIVE_AREA_INFIX(Enter, EXCLUSIVE_AREA_0) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_DisableControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_DisableControllerInterrupts(ch); */ #endif } BRS_DRVCAN_EXCLUSIVE_AREA_INFIX(Exit, EXCLUSIVE_AREA_0) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_RestoreControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_RestoreControllerInterrupts(ch); */ #endif } BRS_DRVCAN_EXCLUSIVE_AREA_INFIX(Enter, EXCLUSIVE_AREA_1) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_DisableControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_DisableControllerInterrupts(ch); */ #endif } BRS_DRVCAN_EXCLUSIVE_AREA_INFIX(Exit, EXCLUSIVE_AREA_1) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_RestoreControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_RestoreControllerInterrupts(ch); */ #endif } #define CAN_STOP_SEC_CODE /* * to support CAN driver name infix, vBRS generator provides a wrapper * for usage of the driver specific MemMap.h define in vBrsCfg.h */ #include "vBrsCfg.h" # endif /* !BRS_ENABLE_CAN_CLASSIC_SUPPORT */ # if defined (BRS_DRVCAN1_HEADER_FILENAME) /* 2nd DrvCan instance detected */ #define CAN1_START_SEC_CODE /* * to support CAN driver name infix, vBRS generator provides a wrapper * for usage of the driver specific MemMap.h define in vBrsCfg.h */ #include "vBrsCfg.h" BRS_DRVCAN1_EXCLUSIVE_AREA_INFIX(Enter, EXCLUSIVE_AREA_0) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_DisableControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_DisableControllerInterrupts(ch); */ #endif } BRS_DRVCAN1_EXCLUSIVE_AREA_INFIX(Exit, EXCLUSIVE_AREA_0) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_RestoreControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_RestoreControllerInterrupts(ch); */ #endif } BRS_DRVCAN1_EXCLUSIVE_AREA_INFIX(Enter, EXCLUSIVE_AREA_1) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_DisableControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_DisableControllerInterrupts(ch); */ #endif } BRS_DRVCAN1_EXCLUSIVE_AREA_INFIX(Exit, EXCLUSIVE_AREA_1) { #if !defined (BRS_ENABLE_FBL_SUPPORT) /* * sample for singlechannel configuration: * Can_30_Core_RestoreControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_RestoreControllerInterrupts(ch); */ #endif } #define CAN1_STOP_SEC_CODE /* * to support CAN driver name infix, vBRS generator provides a wrapper * for usage of the driver specific MemMap.h define in vBrsCfg.h */ #include "vBrsCfg.h" # endif /* BRS_DRVCAN1_HEADER_FILENAME */ # if !defined (BRS_ENABLE_FBL_SUPPORT) # if !defined (BRS_ENABLE_CAN_CLASSIC_SUPPORT) /* * If vCan and classic CAN is mixed within one config, these exclusive areas are already implemented earlier * in this file */ #define CANIF_START_SEC_CODE #include "MemMap.h" void SchM_Enter_CanIf_CANIF_EXCLUSIVE_AREA_0(void) { /* * sample for singlechannel configuration: * Can_30_Core_DisableControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_DisableControllerInterrupts(ch); */ } void SchM_Exit_CanIf_CANIF_EXCLUSIVE_AREA_0(void) { /* * sample for singlechannel configuration: * Can_30_Core_RestoreControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_RestoreControllerInterrupts(ch); */ } #define CANIF_STOP_SEC_CODE #include "MemMap.h" #define CANSM_START_SEC_CODE #include "MemMap.h" void SchM_Enter_CanSM_CANSM_EXCLUSIVE_AREA_4(void) { /* * sample for singlechannel configuration: * Can_30_Core_DisableControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_DisableControllerInterrupts(ch); */ } void SchM_Exit_CanSM_CANSM_EXCLUSIVE_AREA_4(void) { /* * sample for singlechannel configuration: * Can_30_Core_RestoreControllerInterrupts(0u); */ /* * sample for multichannel configuration (be aware, this will have an effect on the runtime!): * uint8 ch; * for (ch = 0; ch < Can_30_Core_GetSizeOfControllerConfig(); ch++) { * Can_30_Core_RestoreControllerInterrupts(ch); */ } void SchM_Enter_CanSM_CANSM_EXCLUSIVE_AREA_1(void) { /* Protects against task interruptions -> no locking needed, because all main functions are on same task */ } void SchM_Exit_CanSM_CANSM_EXCLUSIVE_AREA_1(void) { /* Protects against task interruptions -> no locking needed, because all main functions are on same task */ } #define CANSM_STOP_SEC_CODE #include "MemMap.h" #define COMM_START_SEC_CODE #include "MemMap.h" void SchM_Enter_ComM_COMM_EXCLUSIVE_AREA_1(void) { /* Protects against task interruptions -> no locking needed, because all main functions are on same task */ } void SchM_Exit_ComM_COMM_EXCLUSIVE_AREA_1(void) { /* Protects against task interruptions -> no locking needed, because all main functions are on same task */ } #define COMM_STOP_SEC_CODE #include "MemMap.h" # endif /* !BRS_ENABLE_CAN_CLASSIC_SUPPORT */ # endif /* !BRS_ENABLE_FBL_SUPPORT */ # endif /* Can_30_Core_IsHardwareCancelByApplOfGeneralFeature(0u) && Can_30_Core_IsHardwareLoopCheckOfGeneralFeature(0u) */ # endif /* BRS_ENABLE_CAN_CORE_SUPPORT */ # endif /* BRS_ENABLE_CAN_SUPPORT */ #endif /* !BRSMAINAPPL_DISABLE_CAN_EXCLUSIVEAREA_HANDLING */