/******************************************************************************* ** KPIT Technologies Limited ** ** ** ** KPIT Technologies Limited owns all the rights to this work. This ** ** work shall not be copied, reproduced, used, modified or its information ** ** disclosed without the prior written authorization of KPIT Technologies ** ** Limited. ** ** ** ** SRC-MODULE: WdgCallout.c ** ** ** ** TARGET : All ** ** ** ** PRODUCT : Stub ** ** ** ** PURPOSE : Stub for AUTOSAR BSW modules ** ** ** ** PLATFORM DEPENDANT [yes/no]: no ** ** ** ** TO BE CHANGED BY USER [yes/no]: no ** ** ** *******************************************************************************/ /******************************************************************************* ** Revision History ** ******************************************************************************** ** Revision Date By Description ** ******************************************************************************** ** 1.2.0 11-May-2022 KPIT Coding guidelines update ** ** 1.1.0 22/09/20 ManjunathB Updated for External Watchdog ** ** 1.0.0 ----- KPIT Initial Version ** *******************************************************************************/ /******************************************************************************* ** MISRA-C:2012 violations Section ** *******************************************************************************/ /** #section WdgCallout_c_REF_1 * Violates MISRA C:2012 (Required), This is used as per Autosar and * hence does not affect functionality **/ /** #section WdgCallout_c_REF_2 * Violates MISRA C:2012 Rule-1.2 (Required), Assembly level code is present * for synchronization in ECU and wont affect functionality.**/ /** #section WdgCallout_c_REF_3 * Violates MISRA C:2012 Rule-11.4 (Advisory),Cast between a pointer to volatile * object and an integral type. * This type of operation is required in embedded software applications where * memory mapped registers must be addressed**/ /** #section WdgCallout_c_REF_4 * Violates MISRA C:2012 Rule-8.9 (Advisory),this function is only accessed * in one function. * This type of operation is required in embedded software applications where * memory mapped registers must be addressed**/ /* Violates #ref WdgCallout_c_REF_2, MISRA C:2012 Rule-1.2 (Required) */ /* PRQA S 1006 EOF */ /* Violates #ref WdgCallout_c_REF_3, MISRA C:2012 Rule-11.4 (Advisory) */ /* PRQA S 0303 EOF */ /* PRQA S 5087 EOF */ /* PRQA S 3218 EOF */ /******************************************************************************* ** Include Section ** *******************************************************************************/ #include "WdgCallout.h" #include "Gpt.h" #include "ExternalWatchdog.h" #include "Mcu.h" #include "CddSpi.h" #include "Stub.h" #include "BswM.h" /******************************************************************************* ** Global Data ** *******************************************************************************/ #define CDD_START_SEC_VAR_INIT_8 #include "MemMap.h" volatile uint8 Cdd_GSucBswModuleInitialiseCntr = Wdg_ZERO; /* Violates #ref WdgCallout_c_REF_1, MISRA C:2012 (Required) */ /* PRQA S 4800 4 */ volatile uint8 Cdd_GucWdgMInitialised = Wdg_ZERO; static uint16 Cdd_GSusServiceExtWdg; static uint8 Cdd_GSucNvMWriteAllCntr; uint8 Cdd_NvMWriteAllInitiated = Wdg_ZERO; uint8 Cdd_GucSwitchToTimeout = WdgM_Zero; #define CDD_STOP_SEC_VAR_INIT_8 #include "MemMap.h" /******************************************************************************* ** Function Definitions ** *******************************************************************************/ #define CDD_START_SEC_CODE #include "MemMap.h" /******************************************************************************* ** FUNCTION NAME : Cdd_StartWatchdogInWdwMode ** ** ** ** DESCRIPTION : Function to Start ExtWdg in Window Mode ** ** ** ** PRE-CONDITIONS : None ** ** ** ** PARAMETERS : Input Parameters : None ** ** InOut Parameters : None ** ** Output Parameters : None ** ** ** ** RETURN : None ** ** ** ** Remarks : Global Variable(s) : None ** ** Function(s) invoked : None ** ** ** *******************************************************************************/ void Cdd_StartWatchdogInWdwMode(void) { CddSbc_SetWdgWindowModeAnd200ms (); Gpt_StartTimer(GptConf_GptChannelConfiguration_ExtWdgTimer0, Wdg_DELAY_FIVE); Gpt_EnableNotification(GptConf_GptChannelConfiguration_ExtWdgTimer0); Cdd_GSucBswModuleInitialiseCntr = Wdg_DELAY_ONE; } #define CDD_STOP_SEC_CODE #include "MemMap.h" #define CDD_START_SEC_CODE #include "MemMap.h" /******************************************************************************* ** FUNCTION NAME : Cdd_SetExtWdgTriggerCondition ** ** ** ** DESCRIPTION : Function to Set the trigger condition of ExtWdg ** ** ** ** PRE-CONDITIONS : None ** ** ** ** PARAMETERS : Input Parameters : timeout ** ** InOut Parameters : None ** ** Output Parameters : None ** ** ** ** RETURN : None ** ** ** ** Remarks : Global Variable(s) : None ** ** Function(s) invoked : None ** ** ** *******************************************************************************/ void Cdd_SetExtWdgTriggerCondition(uint16 timeout) { if (Cdd_GucWdgMInitialised == (uint8)Wdg_ONE) { if (timeout == (uint16)Wdg_ZERO) { CddSpi_Stop(); CddSbc_SetWdgWindowModeAnd10ms(); /* Infinite loop added to offset the additional 10ms fault logging */ while (Wdg_ONE) { /* do nothing */ } } if (timeout == (uint16)Wdg_DELAY_THREE) { Cdd_GSusServiceExtWdg = Wdg_ONE; } else { /* do nothing */ } } } #define CDD_STOP_SEC_CODE #include "MemMap.h" #define CDD_START_SEC_CODE #include "MemMap.h" /******************************************************************************* ** FUNCTION NAME : Cdd_SetExtWdgMode ** ** ** ** DESCRIPTION : Function to Set the Mode of Ext Wdg ** ** ** ** PRE-CONDITIONS : None ** ** ** ** PARAMETERS : Input Parameters : None ** ** InOut Parameters : None ** ** Output Parameters : None ** ** ** ** RETURN : Std_ReturnType (E_OK or E_NOT_OK) ** ** ** ** Remarks : Global Variable(s) : None ** ** Function(s) invoked : None ** ** ** *******************************************************************************/ Std_ReturnType Cdd_SetExtWdgMode(WdgIf_ModeType Mode) { Std_ReturnType LddReturnVal = E_NOT_OK; if (Mode == WDGIF_FAST_MODE) { LddReturnVal = E_OK; } if (Mode == WDGIF_SLOW_MODE) { LddReturnVal = E_OK; } return LddReturnVal; } #define CDD_STOP_SEC_CODE #include "MemMap.h" #define CDD_START_SEC_CODE #include "MemMap.h" /******************************************************************************* ** FUNCTION NAME : ExtWdgTimer_Notification ** ** ** ** DESCRIPTION : Function to service the Ext Wdg through GPT Int ** ** ** ** PRE-CONDITIONS : None ** ** ** ** PARAMETERS : Input Parameters : None ** ** InOut Parameters : None ** ** Output Parameters : None ** ** ** ** RETURN : None ** ** ** ** Remarks : Global Variable(s) : None ** ** Function(s) invoked : None ** ** ** *******************************************************************************/ void ExtWdgTimer_Notification(void) { uint8 Luc_ServiceExtWdg = Wdg_ZERO; if (Cdd_GSucBswModuleInitialiseCntr > (uint8)Wdg_ZERO) { Cdd_GSucBswModuleInitialiseCntr--; Luc_ServiceExtWdg = Wdg_ONE; } else if(Cdd_GSucNvMWriteAllCntr > (uint8)Wdg_ZERO) { Cdd_GSucNvMWriteAllCntr--; Luc_ServiceExtWdg = Wdg_ONE; } else { if ((Cdd_GucWdgMInitialised == (uint8)Wdg_ONE) && (Cdd_GSusServiceExtWdg > (uint16)Wdg_ZERO)) { Cdd_GSusServiceExtWdg = Wdg_ZERO; Cdd_GSucBswModuleInitialiseCntr = Wdg_ZERO; Cdd_GSucNvMWriteAllCntr = Wdg_ZERO; Luc_ServiceExtWdg = Wdg_ONE; } } if (Luc_ServiceExtWdg == (uint8)Wdg_ONE) { /* Implemented as per JIRA: HQGIF-1533 */ Cdd_ServiceExternalWdg(); } } /******************************************************************************* ** FUNCTION NAME : Cdd_ServiceExternalWdg ** ** ** ** DESCRIPTION : Function to change Ext Wdg mode ** ** ** ** PRE-CONDITIONS : None ** ** ** ** PARAMETERS : Input Parameters : None ** ** InOut Parameters : None ** ** Output Parameters : None ** ** ** ** RETURN : None ** ** ** ** REMARKS : Global Variable(s) : Cdd_GucSwitchToTimeout ** ** Function(s) invoked : CddSpi_Stop, BswM_RequestMode** ** CddSbc_SetWdgTimeoutModeAnd200ms** ** CddSbc_SetWdgWindowModeAnd200ms ** *******************************************************************************/ void Cdd_ServiceExternalWdg(void) { /* Implemented as per JIRA: HQGIF-1533 */ if(Cdd_GucSwitchToTimeout == EXT_WDG_TIMEOUT_MODE) { CddSpi_Stop(); CddSbc_SetWdgTimeoutModeAnd200ms(); BswM_RequestMode(Wdg_ZERO, WdgTimeoutMode); } else { CddSbc_SetWdgWindowModeAnd200ms (); } } #define CDD_STOP_SEC_CODE #include "MemMap.h" /******************************************************************************* ** End of File ** *******************************************************************************/