/************************************************************************* * * Copyright Diality, Inc. 2019-2020. All Rights Reserved. * 181 Technology, Ste. 150 * Irvine, CA 92618 * * Project Denali * * @file WatchdogMgmt.c * * @brief Monitor for the off and stop buttons. * * @date 20-Sep-2019 * *************************************************************************/ #include "Common.h" #include "CPLD.h" #include "WatchdogMgmt.h" // ********** private data ********** static BOOL watchdogTaskCheckedIn[NUM_OF_TASKS]; // ********** private function prototypes ********** static void resetWDTaskCheckIns( void ); /************************************************************************* * @brief initWatchdogMgmt * The initWatchdogMgmt function initializes the watchdog mgmt. module. * @details * Inputs : none * Outputs : Watchdog mgmt. module initialized. * @param none * @return none *************************************************************************/ void initWatchdogMgmt( void ) { resetWDTaskCheckIns(); } /************************************************************************* * @brief execWatchdogMgmt * The execWatchdogMgmt function executes thewatchdog mgmt. service. * @details * Inputs : none * Outputs : * @param none * @return none *************************************************************************/ void execWatchdogMgmt( void ) { BOOL allTasksCheckedIn = TRUE; U32 i; // called by background task, so give bg task credit for checking in checkInWithWatchdogMgmt( TASK_BG ); // check to see if all monitored tasks have checked in for ( i = 0; i < NUM_OF_TASKS; i++ ) { if ( FALSE == watchdogTaskCheckedIn[i] ) { allTasksCheckedIn = FALSE; break; } } // if all monitored tasks checked in, pet watchdog and clear the slate if ( TRUE == allTasksCheckedIn ) { U32 d; // pulse the watchdog signal setCPLDWatchdog( PIN_SIGNAL_HIGH ); for ( d = 0; d < 1000; d++ ); // ok to block briefly because we're in the background (idle) task setCPLDWatchdog( PIN_SIGNAL_LOW ); // reset task check-ins resetWDTaskCheckIns(); } } /************************************************************************* * @brief checkInWithWatchdogMgmt * The checkInWithWatchdogMgmt function checks a given task in with the \n * 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. * @return none *************************************************************************/ void checkInWithWatchdogMgmt( TASK_T task ) { if ( task < NUM_OF_TASKS ) { watchdogTaskCheckedIn[task] = TRUE; } } /************************************************************************* * @brief resetWDTaskCheckIns * 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 ) { U32 i; // initialize task check-ins to false for ( i = 0; i < NUM_OF_TASKS; i++ ) { watchdogTaskCheckedIn[i] = FALSE; } }