Index: firmware/App/Services/WatchdogMgmt.c =================================================================== diff -u -rdc0d9b087c609e71cacdb7f0395cccf29d749c00 -r44c977966ab7cfecbfbf5110e6abe4ec45ebab62 --- firmware/App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision dc0d9b087c609e71cacdb7f0395cccf29d749c00) +++ firmware/App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision 44c977966ab7cfecbfbf5110e6abe4ec45ebab62) @@ -19,45 +19,51 @@ #include "SystemCommMessages.h" #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 - +#define MIN_WATCHDOG_PET_INTERVAL_MS 45 ///< Minimum watchdog pet interval. +#define WATCHDOG_POST_TIMEOUT_MS 100 ///< Watchdog POST timeout in ms. +#define WATCHDOG_RECOVERY_TIME_MS 250 ///< Watchdog recovery time in ms. + +/// List of watchdog states. typedef enum Button_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 state start + WATCHDOG_SELF_TEST_STATE_IN_PROGRESS, ///< watchdog self test state in progress + WATCHDOG_SELF_TEST_STATE_RECOVER, ///< Watchdog self test state recover + WATCHDOG_SELF_TEST_STATE_COMPLETE, ///< Watchdog self test state complete + 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; ///< Previous watchdog pet timestamp (in ms). -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 U32 watchdogSelfTestTimerCount = 0; +static WATCHDOG_SELF_TEST_STATE_T watchdogSelfTestState; ///< Watchdog self test current state. +static SELF_TEST_STATUS_T watchdogSelfTestStatus; ///< Watchdog self test status. +static U32 watchdogSelfTestTimerCount = 0; ///< Watchdog self test timer count. // ********** private function prototypes ********** static void resetWDTaskCheckIns( void ); static BOOL haveAllTasksCheckedIn( void ); static void petWatchdog( void ); -static DATA_ARRAY_GET_PROTOTYPE( BOOL, hasTaskGeneralCheckedIn, task ); - -/************************************************************************* - * @brief initWatchdogMgmt - * The initWatchdogMgmt function initializes the watchdog mgmt. module. +static BOOL hasTaskGeneralCheckedIn( U32 task ); + +/*********************************************************************//** + * @brief + * The initWatchdogMgmt function initializes the WatchdogMgmt module. * @details * Inputs : none - * Outputs : Watchdog mgmt. module initialized. + * Outputs : WatchdogMgmt module initialized. * @return none *************************************************************************/ void initWatchdogMgmt( void ) @@ -77,13 +83,13 @@ watchdogTaskCheckedIn[ i ].override = OVERRIDE_RESET; } } - -/************************************************************************* - * @brief execWatchdogMgmt - * The execWatchdogMgmt function executes thewatchdog mgmt. service. + +/*********************************************************************//** + * @brief + * The execWatchdogMgmt function executes the watchdog management service. * @details - * Inputs : none - * Outputs : + * Inputs : watchdogTaskCheckedIn[] + * Outputs : Pets watchdog when all tasks checked in * @return none *************************************************************************/ void execWatchdogMgmt( void ) @@ -115,15 +121,15 @@ } } } - -/************************************************************************* - * @brief checkInWithWatchdogMgmt - * The checkInWithWatchdogMgmt function checks a given task in with the \n - * watchdog mgmt. service. + +/*********************************************************************//** + * @brief + * The checkInWithWatchdogMgmt function checks a given task in with the + * watchdog management 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 + * Outputs : task is checked in with the watchdog management + * @param task the task that is checking in with the watchdog management * @return none *************************************************************************/ void checkInWithWatchdogMgmt( TASK_T task ) @@ -133,15 +139,14 @@ watchdogTaskCheckedIn[ task ].data = TRUE; } } - -/************************************************************************* - * @brief execWatchdogTest - * The execWatchdogTest function executes the watchdog test. \n - * This function should be called periodically until a pass or fail \n - * result is returned. + +/*********************************************************************//** + * @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 : + * Inputs : watchdogSelfTestState + * Outputs : Executed watchdog self test * @return in progress, passed, or failed *************************************************************************/ SELF_TEST_STATUS_T execWatchdogTest( void ) @@ -195,9 +200,9 @@ return result; } - -/************************************************************************* - * @brief resetWDTaskCheckIns + +/*********************************************************************//** + * @brief * The resetWDTaskCheckIns function resets the task check-ins with the watchdog. * @details * Inputs : none @@ -214,10 +219,10 @@ watchdogTaskCheckedIn[ i ].data = FALSE; } } - -/************************************************************************* - * @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[] @@ -241,23 +246,42 @@ return result; } - -/************************************************************************* - * @brief hasTaskGeneralCheckedIn - * The hasTaskGeneralCheckedIn function gets the check-in state of a given /n - * task. + +/*********************************************************************//** + * @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 * @return TRUE if given task has checked in, FALSE if not *************************************************************************/ -static DATA_ARRAY_GET( BOOL, hasTaskGeneralCheckedIn, task, NUM_OF_TASKS-1, watchdogTaskCheckedIn, FALSE ) - -/************************************************************************* - * @brief petWatchdog - * The petWatchdog function pets the watchdog by pulsing the CPLD WD pet /n - * signal. +static 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_DG_SOFTWARE_FAULT ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The petWatchdog function pets the watchdog by pulsing the CPLD WD pet signal. * @details * Inputs : none * Outputs : CPLD WD pet signal is pulsed @@ -276,19 +300,61 @@ /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ + - -/************************************************************************* - * @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 * @return TRUE if override successful, FALSE if not *************************************************************************/ -DATA_ARRAY_OVERRIDE_FUNC( BOOL, testSetWatchdogTaskCheckInOverride, testResetWatchdogTaskCheckInOverride, watchdogTaskCheckedIn, task, NUM_OF_TASKS-1 ) +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; +} + +/**@}*/