Std_ReturnType Wdg_SetMode (WdgIf_ModeType Mode) { /* @req SWS_Wdg_00160 */ static const Wdg_SettingsType *modeWdgConfig; Std_ReturnType res = E_NOT_OK; /* @req SWS_Wdg_00017 */ /* @req SWS_Wdg_00010 */ VALIDATE_RV(runTimeData.configWdgPtr != NULL, WDG_SET_MODE_SERVICE_ID, WDG_E_DRIVER_STATE, E_NOT_OK); switch (Mode) { case WDGIF_OFF_MODE: modeWdgConfig = &(runTimeData.configWdgPtr->Wdg_ModeConfig->WdgSettingsOff); break; case WDGIF_FAST_MODE: modeWdgConfig = &(runTimeData.configWdgPtr->Wdg_ModeConfig->WdgSettingsFast); break; case WDGIF_SLOW_MODE: modeWdgConfig = &(runTimeData.configWdgPtr->Wdg_ModeConfig->WdgSettingsSlow); break; default: /* @req SWS_Wdg_00091 */ REPORT_DET_ERROR(WDG_SET_MODE_SERVICE_ID, WDG_E_PARAM_MODE); modeWdgConfig = NULL; break; } if (modeWdgConfig != NULL) { /* Enable watchdog if config tell us to.. */ if (modeWdgConfig->ActivationBit != 0u) { #if defined(CFG_MPC560X) || defined(CFG_MPC563XM) || defined(CFG_MPC5744P) || defined(CFG_MPC5645S) || defined(CFG_MPC5644A) || defined(CFG_MPC5777M) StopWatchdog(); // must be stopped in order to change TO #endif /* @req SWS_Wdg_00145*/ StartWatchdog(modeWdgConfig->ReloadValue); } else { StopWatchdog(); } /* Set internal mode for debugging and test */ runTimeData.mode = Mode; res = E_OK; } /* @req SWS_Wdg_00103 */ return res; }
Std_ReturnType Wdg_SetMode (WdgIf_ModeType Mode) { Std_ReturnType res = E_NOT_OK; switch (Mode) { case WDGIF_OFF_MODE: modeWdgConfig = &configWdgPtr->Wdg_ModeConfig->WdgSettingsOff; break; case WDGIF_FAST_MODE: modeWdgConfig = &configWdgPtr->Wdg_ModeConfig->WdgSettingsFast; break; case WDGIF_SLOW_MODE: modeWdgConfig = &(configWdgPtr->Wdg_ModeConfig->WdgSettingsSlow); break; default: modeWdgConfig = 0; break; } if (modeWdgConfig != 0) { /* Enable watchdog if config tell us to.. */ if (modeWdgConfig->ActivationBit) { #if defined(CFG_MPC560X) || defined(CFG_MPC563XM) StopWatchdog(); // must be stopped in order to change TO SWT.TO.R = modeWdgConfig->ReloadValue; #endif StartWatchdog(modeWdgConfig->ReloadValue); } else { StopWatchdog(); } res = E_OK; } return res; }