Index: firmware/App/Services/WatchdogMgmt.c =================================================================== diff -u -rde5a0d43bdef611d963d11855bc958a8d8899a09 -ra3a01327c8fe80f65f6658ae6cbef4910a4a8033 --- firmware/App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision de5a0d43bdef611d963d11855bc958a8d8899a09) +++ firmware/App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision a3a01327c8fe80f65f6658ae6cbef4910a4a8033) @@ -21,29 +21,35 @@ #include "Timers.h" #include "WatchdogMgmt.h" +/** + * @addtogroup WatchdogMgmt + * @{ + */ + // ********** private definitions ********** -#define MIN_WATCHDOG_PET_INTERVAL_MS 45 -#define WATCHDOG_POST_TIMEOUT_MS 100 -#define WATCHDOG_RECOVERY_TIME_MS 250 - -typedef enum Button_Self_Test_States +#define MIN_WATCHDOG_PET_INTERVAL_MS 45 ///< Minimum watchdog pet interval (in ms). +#define WATCHDOG_POST_TIMEOUT_MS 100 ///< Watchdog POST test timeout (in ms). +#define WATCHDOG_RECOVERY_TIME_MS 250 ///< After watchdog POST test, wait this long (in ms) before moving on. + +/// Enumeration of watchdog self-test states. +typedef enum Watchdog_Self_Test_States { - WATCHDOG_SELF_TEST_STATE_START = 0, - WATCHDOG_SELF_TEST_STATE_IN_PROGRESS, - WATCHDOG_SELF_TEST_STATE_RECOVER, - WATCHDOG_SELF_TEST_STATE_COMPLETE, - NUM_OF_WATCHDOG_SELF_TEST_STATES + WATCHDOG_SELF_TEST_STATE_START = 0, ///< Watchdog self-test start state + WATCHDOG_SELF_TEST_STATE_IN_PROGRESS, ///< Watchdog self-test in progress state + WATCHDOG_SELF_TEST_STATE_RECOVER, ///< Watchdog self-test recovery state + WATCHDOG_SELF_TEST_STATE_COMPLETE, ///< Watchdog self-test completed state + NUM_OF_WATCHDOG_SELF_TEST_STATES ///< Number of watchdog self-test states } WATCHDOG_SELF_TEST_STATE_T; // ********** private data ********** -static U32 lastWatchdogPetTime = 0; +static U32 lastWatchdogPetTime = 0; ///< Timestamp (ms counter) since last watchdog pet. -DATA_ARRAY_DECL( BOOL, TaskCheckIns, NUM_OF_TASKS, watchdogTaskCheckedIn ); +static OVERRIDE_U32_T watchdogTaskCheckedIn[ NUM_OF_TASKS ]; ///< Array of flags indicating whether individual tasks have checked in with watchdog manager. -static WATCHDOG_SELF_TEST_STATE_T watchdogSelfTestState = WATCHDOG_SELF_TEST_STATE_START; -static SELF_TEST_STATUS_T watchdogSelfTestStatus; +static WATCHDOG_SELF_TEST_STATE_T watchdogSelfTestState = WATCHDOG_SELF_TEST_STATE_START; ///< Current watchdog self-test state. +static SELF_TEST_STATUS_T watchdogSelfTestStatus; ///< Watchdog self-test state timer counter. static U32 watchdogSelfTestTimerCount = 0; // ********** private function prototypes ********** @@ -53,13 +59,12 @@ static void petWatchdog( void ); static DATA_ARRAY_GET_PROTOTYPE( BOOL, hasTaskGeneralCheckedIn, task ); -/************************************************************************* - * @brief initWatchdogMgmt +/*********************************************************************//** + * @brief * The initWatchdogMgmt function initializes the watchdog mgmt. module. * @details * Inputs : none * Outputs : Watchdog mgmt. module initialized. - * @param none * @return none *************************************************************************/ void initWatchdogMgmt( void ) @@ -80,13 +85,12 @@ } } -/************************************************************************* - * @brief execWatchdogMgmt +/*********************************************************************//** + * @brief * The execWatchdogMgmt function executes thewatchdog mgmt. service. * @details - * Inputs : none - * Outputs : - * @param none + * Inputs : watchdogTaskCheckedIn[] + * Outputs : watchdogTaskCheckedIn[] * @return none *************************************************************************/ void execWatchdogMgmt( void ) @@ -125,14 +129,14 @@ } -/************************************************************************* - * @brief checkInWithWatchdogMgmt - * The checkInWithWatchdogMgmt function checks a given task in with the \n +/*********************************************************************//** + * @brief + * The checkInWithWatchdogMgmt function checks a given task in with the * watchdog mgmt. service. * @details * Inputs : none * Outputs : task is checked in with the watchdog mgmt.. - * @param task : the task that is checking in with the watchdog mgmt. + * @param task the task that is checking in with the watchdog mgmt * @return none *************************************************************************/ void checkInWithWatchdogMgmt( TASK_T task ) @@ -143,15 +147,14 @@ } } -/************************************************************************* - * @brief execWatchdogTest - * The execWatchdogTest function executes the watchdog test. \n - * This function should be called periodically until a pass or fail \n +/*********************************************************************//** + * @brief + * The execWatchdogTest function executes the watchdog test. + * This function should be called periodically until a pass or fail * result is returned. * @details - * Inputs : - * Outputs : - * @param none + * Inputs : watchdogSelfTestState + * Outputs : watchdogSelfTestState * @return in progress, passed, or failed *************************************************************************/ SELF_TEST_STATUS_T execWatchdogTest( void ) @@ -192,27 +195,26 @@ break; case WATCHDOG_SELF_TEST_STATE_COMPLETE: - // if we get called in this state, assume we're doing self test again + // if we get called in this state, assume we're doing self-test again watchdogSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; watchdogSelfTestState = WATCHDOG_SELF_TEST_STATE_START; break; default: result = SELF_TEST_STATUS_FAILED; - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_WATCHDOG_INVALID_SELF_TEST_STATE, watchdogSelfTestState ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_WATCHDOG_INVALID_SELF_TEST_STATE, watchdogSelfTestState ) break; } return result; } -/************************************************************************* - * @brief resetWDTaskCheckIns +/*********************************************************************//** + * @brief * The resetWDTaskCheckIns function resets the task check-ins with the watchdog. * @details * Inputs : none * Outputs : watchdogTaskCheckedIn[] array reset to all false. - * @param none * @return none *************************************************************************/ static void resetWDTaskCheckIns( void ) @@ -226,14 +228,13 @@ } } -/************************************************************************* - * @brief haveAllTasksCheckedIn - * The haveAllTasksCheckedIn function determines whether all tasks have /n +/*********************************************************************//** + * @brief + * The haveAllTasksCheckedIn function determines whether all tasks have * checked in with watchdog mgmt. * @details * Inputs : watchdogTaskCheckedIn[] * Outputs : none - * @param none * @return TRUE if all tasks have checked in since last watchdog pet, FALSE if not. *************************************************************************/ static BOOL haveAllTasksCheckedIn( void ) @@ -254,26 +255,46 @@ return result; } -/************************************************************************* - * @brief hasTaskGeneralCheckedIn - * The hasTaskGeneralCheckedIn function gets the check-in state of a given /n +/*********************************************************************//** + * @brief + * The hasTaskGeneralCheckedIn function gets the check-in state of a given * task. * @details * Inputs : watchdogTaskCheckedIn[] * Outputs : none - * @param task : ID of task to check + * @param task ID of task to check * @return TRUE if given task has checked in, FALSE if not *************************************************************************/ -static DATA_ARRAY_GET( BOOL, hasTaskGeneralCheckedIn, task, NUM_OF_TASKS-1, watchdogTaskCheckedIn, FALSE ) +BOOL hasTaskGeneralCheckedIn( U32 task ) +{ + BOOL result = FALSE; + + if ( task < NUM_OF_TASKS ) + { + if ( OVERRIDE_KEY == watchdogTaskCheckedIn[ task ].override ) + { + result = (BOOL)watchdogTaskCheckedIn[ task ].ovData; + } + else + { + result = (BOOL)watchdogTaskCheckedIn[ task ].data; + } + } + else + { + activateAlarmNoData( ALARM_ID_HD_SOFTWARE_FAULT ); + } + + return result; +} -/************************************************************************* - * @brief petWatchdog - * The petWatchdog function pets the watchdog by pulsing the CPLD WD pet /n +/*********************************************************************//** + * @brief + * The petWatchdog function pets the watchdog by pulsing the CPLD WD pet * signal. * @details * Inputs : none * Outputs : CPLD WD pet signal is pulsed - * @param none * @return none *************************************************************************/ static void petWatchdog( void ) @@ -293,17 +314,59 @@ *************************************************************************/ -/************************************************************************* - * @brief testSetWatchdogTaskCheckInOverride and testResetWatchdogTaskCheckInOverride - * The testSetWatchdogTaskCheckInOverride function overrides the state of the \n - * task check-in with the watchdog management with a given check-in state. \n - * The testResetWatchdogTaskCheckInOverride function resets the override of the \n - * state of the check-in with the watchdog management. +/*********************************************************************//** + * @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 * Outputs : watchdogTaskCheckedIn[] - * @param task : ID of task to override check-in state for - * @param value : override state for the given task ID + * @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 *************************************************************************/ -DATA_ARRAY_OVERRIDE_FUNC( BOOL, testSetWatchdogTaskCheckInOverride, testResetWatchdogTaskCheckInOverride, watchdogTaskCheckedIn, task, NUM_OF_TASKS ) +BOOL testSetWatchdogTaskCheckInOverride( U32 task, BOOL value ) +{ + BOOL result = FALSE; + + if ( task < NUM_OF_TASKS ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + watchdogTaskCheckedIn[ task ].ovData = value; + watchdogTaskCheckedIn[ task ].override = OVERRIDE_KEY; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetWatchdogTaskCheckInOverride function resets the override of the + * state of the check-in with the watchdog management. + * @details + * Inputs : none + * 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; + + if ( task < NUM_OF_TASKS ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + watchdogTaskCheckedIn[ task ].override = OVERRIDE_RESET; + watchdogTaskCheckedIn[ task ].ovData = watchdogTaskCheckedIn[ task ].ovInitData; + } + } + + return result; +} + +/**@}*/