/************************************************************************** * * Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file TaskBG.c * * @author (last) Sean * @date (last) 31-Jul-2024 * * @author (original) Sean * @date (original) 31-Jul-2024 * ***************************************************************************/ #include "TDCommon.h" //#include "Battery.h" #include "SystemCommTD.h" #include "TaskTimer.h" #include "Timers.h" //#include "Voltages.h" #include "WatchdogMgmt.h" /** * @addtogroup TaskBackground * @{ */ // ********** private definitions ********** #define MAX_TIME_FOR_UI_TO_COMMUNICATE_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Maximum time we wait for UI to communicate after power up (2 minutes). // ********** private data ********** static U32 startUICommTimeout; ///< Timer counter for UI to begin communicating. // ********** private function prototypes ********** /*********************************************************************//** * @brief * The taskBackground function handles the idle Background Task loop. * @details \b Alarm: ALARM_ID_TD_UI_COMM_POST_FAILED if UI has not started * communicating within 2 minutes of power up. * @details \b Inputs: none * @details \b Outputs: Background task functions are called. * @return none *************************************************************************/ void taskBackground( void ) { startUICommTimeout = getMSTimerCount(); #ifndef _VECTORCAST_ // Cannot have infinite loop in unit test tool while ( 1 ) #endif { // Wait for UI to come up after power up if ( FALSE == uiCommunicated() ) { #ifndef BOARD_WITH_NO_HARDWARE // Check timeout waiting for UI to check in (via CAN) after startup. if ( TRUE == didTimeout( startUICommTimeout, MAX_TIME_FOR_UI_TO_COMMUNICATE_MS ) ) { activateAlarmNoData( ALARM_ID_TD_UI_COMM_POST_FAILED ); } #endif } // Manage the watchdog execWatchdogMgmt(); // // // Manage Non-volatile data manager // execNVDataMgmt(); // // // Monitor battery status // execBatteryMonitor(); } } /**@}*/