From: mahi Date: Tue, 11 Sep 2012 06:51:39 +0000 (+0200) Subject: EcuM: More watchdog stuff X-Git-Url: https://rtime.felk.cvut.cz/gitweb/arc.git/commitdiff_plain/f5d8715009ce50cefb9293172ee694e97332cf5c EcuM: More watchdog stuff --- diff --git a/boards/mpc5516it/config/Wdg_Cfg.h b/boards/mpc5516it/config/Wdg_Cfg.h new file mode 100644 index 00000000..29c26c43 --- /dev/null +++ b/boards/mpc5516it/config/Wdg_Cfg.h @@ -0,0 +1,45 @@ +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ + +#ifndef WDG_CFG_H_ +#define WDG_CFG_H_ + +#include "Std_Types.h" +#include "WdgIf_Types.h" + +typedef struct +{ + uint32 ReloadValue; + uint8 ActivationBit; +}Wdg_SettingsType; + +typedef struct +{ + WdgIf_ModeType Wdg_DefaultMode; + Wdg_SettingsType WdgSettingsFast; + Wdg_SettingsType WdgSettingsSlow; + Wdg_SettingsType WdgSettingsOff; +}Wdg_ModeConfigType; + +typedef struct +{ + const Wdg_GeneralType *Wdg_General; + const Wdg_ModeConfigType *Wdg_ModeConfig; +}Wdg_ConfigType; + + extern const Wdg_GeneralType WdgGeneral; + extern const Wdg_ConfigType WdgConfig; + +#endif /* WDG_CFG_H_ */ diff --git a/boards/mpc5516it/config/Wdg_Lcfg.c b/boards/mpc5516it/config/Wdg_Lcfg.c new file mode 100644 index 00000000..b948ed69 --- /dev/null +++ b/boards/mpc5516it/config/Wdg_Lcfg.c @@ -0,0 +1,52 @@ +/* -------------------------------- Arctic Core ------------------------------ + * Arctic Core - the open source AUTOSAR platform http://arccore.com + * + * Copyright (C) 2009 ArcCore AB + * + * This source code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; See . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * -------------------------------- Arctic Core ------------------------------*/ + +#include "Wdg.h" + +const Wdg_ModeConfigType WdgModeConfig = +{ + .Wdg_DefaultMode = WDGIF_OFF_MODE, + .WdgSettingsFast = + { + .ReloadValue = 0x200, + .ActivationBit = 1, + }, + .WdgSettingsSlow = + { + .ReloadValue = 0x7D00, + .ActivationBit = 1, + }, + .WdgSettingsOff = + { + .ReloadValue = 0x7D00, + .ActivationBit = 0, + }, +}; + +const Wdg_GeneralType WdgGeneral = +{ + .Wdg_Index = 1, + .Wdg_TriggerLocationPtr = Wdg_Trigger, + .Wdg_SetModeLocationPtr = Wdg_SetMode, +}; + + +const Wdg_ConfigType WdgConfig = +{ + .Wdg_General = &WdgGeneral, + .Wdg_ModeConfig = &WdgModeConfig, +}; + + diff --git a/include/WdgM_ConfigTypes.h b/include/WdgM_ConfigTypes.h index cc85acd8..d5fef146 100644 --- a/include/WdgM_ConfigTypes.h +++ b/include/WdgM_ConfigTypes.h @@ -100,17 +100,21 @@ typedef struct const float32 WdgM_TriggerCycle; }WdgM_ActivationSchMType; +#if (WDGM_GPT_USED == STD_ON) typedef struct { const uint32 WdgM_GptCycle; const Gpt_ChannelType WdgM_GptChannelRef; }WdgM_ActivationGPTType; +#endif typedef struct { const boolean WdgM_IsGPTActivated; const WdgM_ActivationSchMType WdgM_ActivationSchM; +#if (WDGM_GPT_USED == STD_ON) const WdgM_ActivationGPTType WdgM_ActivationGPT; +#endif }WdgM_ActivationType; typedef struct diff --git a/system/EcuM/EcuM.c b/system/EcuM/EcuM.c index 5f3cd568..8cc0886d 100644 --- a/system/EcuM/EcuM.c +++ b/system/EcuM/EcuM.c @@ -186,6 +186,10 @@ void EcuM_StartupTwo(void) SchM_Init(); #endif +#if defined(USE_WDGM) + WdgM_SetMode(internal_data.config->EcuMWdgMConfig->EcuMWdgMStartupMode); +#endif + // Initialize drivers that don't need NVRAM data EcuM_AL_DriverInitTwo(internal_data.config); diff --git a/system/EcuM/EcuM_Main.c b/system/EcuM/EcuM_Main.c index 4cfdf246..128a871d 100644 --- a/system/EcuM/EcuM_Main.c +++ b/system/EcuM/EcuM_Main.c @@ -269,7 +269,7 @@ static inline void in_state_appRun(void){ EcuM_OnExitRun(); /** @req EcuM2865 */ #if defined(USE_WDGM) - // This is APPRUN not RUN.. so WdgM_SetMode() should not be called? + WdgM_SetMode(internal_data.config->EcuMWdgMConfig->EcuMWdgMPostRunMode); #endif #if defined(USE_RTE) && defined(CFG_ECUM_USE_SERVICE_COMPONENT) @@ -339,9 +339,17 @@ static inline void in_state_goOffOne(void){ // Wait for the NVM job (NvmWriteAll) to terminate NvM_GetErrorStatus(0, &writeAllResult); if ((writeAllResult != NVM_REQ_PENDING) || (internal_data_go_off_one_state_timeout == 0)){ + +#if defined(USE_WDGM) + WdgM_SetMode(internal_data.config->EcuMWdgMConfig->EcuMWdgMShutdownMode); +#endif ShutdownOS(E_OK); } #else + +#if defined(USE_WDGM) + WdgM_SetMode(internal_data.config->EcuMWdgMConfig->EcuMWdgMShutdownMode); +#endif ShutdownOS(E_OK); #endif }