/************************************************************************** * * Copyright (c) 2019-2021 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) Quang Nguyen * @date (last) 06-Apr-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #include "Battery.h" #include "Buttons.h" #include "HDCommon.h" #include "NVDataMgmt.h" #include "SafetyShutdown.h" #include "SystemComm.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 40000 ///< Maximum time we wait for UI to communicate after power up (40 seconds). // ********** 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. * Calls the Watchdog Mgmt. and NonVolatile Data services. * @details Inputs: none * @details Outputs: Executive for watchdog mgmt. and non-volatile data services 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 #ifndef SIMULATE_UI // 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_UI_COMM_POST_FAILED ); } #endif #endif } // Manage the watchdog execWatchdogMgmt(); // Manage Non-volatile data manager execNVDataMgmt(); // Monitor battery status execBatteryMonitor(); } } /**@}*/