Index: WatchdogMgmt.c =================================================================== diff -u -ra63f636c18858c8444d3e4908bb19755b4f2be27 -r6520e649188757399c2dfd58a30af80d96256295 --- WatchdogMgmt.c (.../WatchdogMgmt.c) (revision a63f636c18858c8444d3e4908bb19755b4f2be27) +++ WatchdogMgmt.c (.../WatchdogMgmt.c) (revision 6520e649188757399c2dfd58a30af80d96256295) @@ -16,9 +16,15 @@ ***************************************************************************/ #ifdef _TD_ -//#include "CPLD.h" +#include "CpldInterface.h" +#include "FpgaTD.h" #endif -//#include "FPGA.h" +#ifdef _DD_ +#include "FpgaDD.h" +#endif +#ifdef _RO_ +#include "FpgaRo.h" +#endif //#include "InternalADC.h" #include "Messaging.h" #include "OperationModes.h" @@ -71,9 +77,9 @@ /*********************************************************************//** * @brief - * The initWatchdogMgmt function initializes the watchdog mgmt. module. - * @details Inputs: none - * @details Outputs: Watchdog mgmt. module initialized. + * The initWatchdogMgmt function initializes the watchdog management unit. + * @details \b Inputs: none + * @details \b Outputs: Watchdog management unit initialized. * @return none *************************************************************************/ void initWatchdogMgmt( void ) @@ -98,16 +104,18 @@ /*********************************************************************//** * @brief - * The execWatchdogMgmt function executes thewatchdog mgmt. service. - * @details Inputs: watchdogTaskCheckedIn[] - * @details Outputs: watchdogTaskCheckedIn[] + * The execWatchdogMgmt function executes the watchdog management service. + * If all tasks have checked in, the watchdog is pet. + * @details \b Inputs: watchdogTaskCheckedIn[] + * @details \b Outputs: watchdogTaskCheckedIn[] + * @details \b Alarm: ALARM_ID_XX_WATCHDOG_EXPIRED if safety activated * @return none *************************************************************************/ void execWatchdogMgmt( void ) { BOOL allTasksCheckedIn; -// PIN_SIGNAL_STATE_T safetyShutdownFeedbackSignal = getWatchdogExpired(); -// PIN_SIGNAL_STATE_T safetyShutdownSoftwareCmd = ( TRUE == isSafetyShutdownActivated() ? PIN_SIGNAL_LOW : PIN_SIGNAL_HIGH ); + PIN_SIGNAL_STATE_T safetyShutdownFeedbackSignal = getCPLDWatchdogExpired(); + PIN_SIGNAL_STATE_T safetyShutdownSoftwareCmd = ( TRUE == isSafetyShutdownActivated() ? PIN_SIGNAL_LOW : PIN_SIGNAL_HIGH ); // Called by background task, so give bg task credit for checking in checkInWithWatchdogMgmt( TASK_BG ); @@ -122,9 +130,9 @@ resetWDTaskCheckIns(); } // Check to see if watchdog has expired or safety shutdown feedback does not match s/w command (only after POST completed) -// if ( ( safetyShutdownSoftwareCmd != safetyShutdownFeedbackSignal ) && ( getCurrentOperationMode() != MODE_INIT ) ) -// { -// if ( ( PIN_SIGNAL_LOW == safetyShutdownFeedbackSignal ) || ( TRUE == didTimeout( safetyShutdownFeedbackMismatchTS, MAX_SAFETY_SHUTDOWN_MISMATCH_MS ) ) ) + if ( ( safetyShutdownSoftwareCmd != safetyShutdownFeedbackSignal ) && ( getCurrentOperationMode() != MODE_INIT ) ) + { + if ( ( PIN_SIGNAL_LOW == safetyShutdownFeedbackSignal ) || ( TRUE == didTimeout( safetyShutdownFeedbackMismatchTS, MAX_SAFETY_SHUTDOWN_MISMATCH_MS ) ) ) { /* DEBUG WARNING * It may be necessary to comment out the following @@ -141,37 +149,45 @@ //activateAlarmNoData( ALARM_ID_RO_WATCHDOG_EXPIRED ); #endif } -// } -// else -// { -// safetyShutdownFeedbackMismatchTS = getMSTimerCount(); -// } + } + else + { + safetyShutdownFeedbackMismatchTS = getMSTimerCount(); + } } /*********************************************************************//** * @brief * The checkInWithWatchdogMgmt function checks a given task in with the - * watchdog mgmt. service. - * @details Inputs: none - * @details Outputs: task is checked in with the watchdog mgmt.. - * @param task the task that is checking in with the watchdog mgmt + * watchdog management service. + * @details \b Inputs: none + * @details \b Outputs: task is checked in + * @details \b Alarms: ALARM_ID_TD_SOFTWARE_FAULT if invalid task given + * @param task the task that is checking in * @return none *************************************************************************/ void checkInWithWatchdogMgmt( TASK_T task ) { if ( task < NUM_OF_TASKS ) { watchdogTaskCheckedIn[ task ].data = TRUE; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_WATCHDOG_INVALID_TASK, task ) } } /*********************************************************************//** * @brief - * The execWatchdogTest function executes the watchdog test. - * This function should be called periodically until a pass or fail - * result is returned. - * @details Inputs: watchdogSelfTestState - * @details Outputs: watchdogSelfTestState + * The execWatchdogTest function executes the watchdog self-test. + * @warning This function should be called periodically until a pass or fail + * result is returned. + * @details \b Inputs: watchdogSelfTestState, watchdogSelfTestTimerCount + * @details \b Outputs: watchdogSelfTestState, watchdogSelfTestTimerCount, + * watchdogSelfTestStatus + * @details \b Alarm: ALARM_ID_XX_WATCHDOG_POST_TEST_FAILED if self-test fails. + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if self-test state is invalid. * @return in progress, passed, or failed *************************************************************************/ SELF_TEST_STATUS_T execWatchdogTest( void ) @@ -189,8 +205,12 @@ while ( FALSE == didTimeout( watchdogSelfTestTimerCount, WATCHDOG_POST_TIMEOUT_MS ) ) { // Waiting here for w.d. test period to prevent this task from checking in - watchdog should expire - } -// if ( PIN_SIGNAL_LOW == getWatchdogExpired() ) + } +#ifdef _TD_ +// if ( PIN_SIGNAL_LOW == getCPLDWatchdogExpired() ) +#else +// if ( TBD ) +#endif // { // F32 v24 = getIntADCVoltageConverted( INT_ADC_24V_ACTUATORS ); // F32 audioCurrent = getFPGABackupAlarmAudioCurrent(); @@ -225,7 +245,11 @@ case WATCHDOG_SELF_TEST_STATE_RECOVER: if ( TRUE == didTimeout( watchdogSelfTestTimerCount, WATCHDOG_RECOVERY_TIME_MS ) ) { // Verify watchdog expired signal no longer active +#ifdef _TD_ // if ( PIN_SIGNAL_HIGH == getCPLDWatchdogExpired() ) +#else +// if ( TBD ) +#endif // { // F32 v24 = getIntADCVoltageConverted( INT_ADC_24V_ACTUATORS ); // F32 audioCurrent = getFPGABackupAlarmAudioCurrent(); @@ -279,9 +303,10 @@ /*********************************************************************//** * @brief - * The resetWatchdogPOSTState function resets the watchdog POST state. - * @details Inputs: none - * @details Outputs: watchdogSelfTestState + * The resetWatchdogPOSTState function resets the watchdog POST state so + * it can be run again if needed. + * @details \b Inputs: none + * @details \b Outputs: watchdogSelfTestState * @return none *************************************************************************/ void resetWatchdogPOSTState( void ) @@ -292,8 +317,8 @@ /*********************************************************************//** * @brief * The resetWDTaskCheckIns function resets the task check-ins with the watchdog. - * @details Inputs: none - * @details Outputs: watchdogTaskCheckedIn[] array reset to all false. + * @details \b Inputs: none + * @details \b Outputs: watchdogTaskCheckedIn[] array reset to all false. * @return none *************************************************************************/ static void resetWDTaskCheckIns( void ) @@ -310,9 +335,9 @@ /*********************************************************************//** * @brief * The haveAllTasksCheckedIn function determines whether all tasks have - * checked in with watchdog mgmt. - * @details Inputs: watchdogTaskCheckedIn[] - * @details Outputs: none + * checked in. + * @details \b Inputs: watchdogTaskCheckedIn[] + * @details \b Outputs: none * @return TRUE if all tasks have checked in since last watchdog pet, FALSE if not. *************************************************************************/ static BOOL haveAllTasksCheckedIn( void ) @@ -335,11 +360,12 @@ /*********************************************************************//** * @brief - * The hasTaskGeneralCheckedIn function gets the check-in state of a given + * The hasTaskGeneralCheckedIn function gets the checked in status of a given * task. - * @details Inputs: watchdogTaskCheckedIn[] - * @details Outputs: none - * @param task ID of task to check + * @details \b Inputs: watchdogTaskCheckedIn[] + * @details \b Outputs: none + * @details \b Alarm: ALARM_ID_XX_SOFTWARE_FAULT if given task is invalid. + * @param task ID of task to determine checked in status of * @return TRUE if given task has checked in, FALSE if not *************************************************************************/ BOOL hasTaskGeneralCheckedIn( U32 task ) @@ -375,16 +401,20 @@ /*********************************************************************//** * @brief - * The petWatchdog function pets the watchdog by pulsing the CPLD WD pet + * The petWatchdog function pets the watchdog by pulsing the watchdog pet * signal. - * @details Inputs: none - * @details Outputs: CPLD WD pet signal is pulsed + * @details \b Inputs: none + * @details \b Outputs: Watchdog pet signal is pulsed * @return none *************************************************************************/ static void petWatchdog( void ) { - // Pulse the watchdog signal -// toggleCPLDWatchdog(); + // Pulse the watchdog signal +#ifdef _TD_ + toggleCPLDWatchdog(); +#else + // TBD +#endif // Remember when we last pet the watchdog lastWatchdogPetTime = getMSTimerCount(); @@ -399,19 +429,23 @@ /*********************************************************************//** * @brief * The testSetWatchdogTaskCheckInOverride function overrides the state of the - * task check-in with the watchdog management with a given check-in state. - * @details Inputs: none - * @details Outputs: watchdogTaskCheckedIn[] + * check-in for a given task with a given check-in state. + * @warning Dialin must be logged into related firmware stack to perform + * an override successfully. + * @details \b Inputs: none + * @details \b Outputs: watchdogTaskCheckedIn[] * @param task ID of task to override check-in state for * @param value override state for the given task ID - * @return TRUE if override successful, FALSE if not + * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetWatchdogTaskCheckInOverride( U32 task, BOOL value ) { BOOL result = FALSE; + // validate given task if ( task < NUM_OF_TASKS ) { + // Dialin must be logged in to perform an override if ( TRUE == isTestingActivated() ) { result = TRUE; @@ -426,18 +460,22 @@ /*********************************************************************//** * @brief * The testResetWatchdogTaskCheckInOverride function resets the override of the - * state of the check-in with the watchdog management. - * @details Inputs: none - * @details Outputs: watchdogTaskCheckedIn[] + * state of the check-in for a given task. + * @warning Dialin must be logged into related firmware stack to perform + * an override successfully. + * @details \b Inputs: none + * @details \b Outputs: watchdogTaskCheckedIn[] * @param task ID of task to override check-in state for * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetWatchdogTaskCheckInOverride( U32 task ) { BOOL result = FALSE; + // validate given task if ( task < NUM_OF_TASKS ) { + // Dialin must be logged in to perform an override if ( TRUE == isTestingActivated() ) { result = TRUE;