/************************************************************************** * * Copyright (c) 2019-2020 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 TaskGeneral.c * * @author (last) Sean * @date (last) 11-May-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #include "AlarmLamp.h" #include "BloodFlow.h" #include "CPLD.h" #include "DialInFlow.h" #include "DialOutFlow.h" #include "OperationModes.h" #include "PresOccl.h" #include "SystemComm.h" #include "SystemCommMessages.h" #include "WatchdogMgmt.h" #include "TaskGeneral.h" #include "RTC.h" #ifdef RM46_EVAL_BOARD_TARGET #include "CPLD.h" #include "SystemCommMessages.h" static BOOL lastUserPress = FALSE; #endif // ********** private data ********** /************************************************************************* * @brief taskGeneral * The taskGeneral function handles the scheduled General Task interrupt.\n * Calls the executive functions for most monitors and controllers, the\n * operation modes, the system communications, and alarms.\n * @details * Inputs : none * Outputs : Executive for the TBD called. * @return none *************************************************************************/ void taskGeneral( void ) { #ifdef TASK_TIMING_OUTPUT_ENABLED // set GPIO high to indicate general task has begun executing setCPLDLampGreen( PIN_SIGNAL_HIGH ); #endif // check in with watchdog manager checkInWithWatchdogMgmt( TASK_GENERAL ); // do this first to keep timing consistent with watchdog management // manage data received from other sub-systems execSystemCommRx(); // prevent most processing until UI has started communicating #ifndef SIMULATE_UI if ( TRUE == uiCommunicated() ) #endif { // monitor pressure/occlusion sensors execPresOccl(); // run operation mode state machine execOperationModes(); // control blood pump execBloodFlowController(); // control dialysate inlet pump execDialInFlowController(); // control dialysate outlet pump execDialOutFlowController(); // manage RTC execRTC(); // manage alarm state execAlarmMgmt(); // control alarm lamp execAlarmLamp(); #ifdef RM46_EVAL_BOARD_TARGET if ( getUserButtonState() == PIN_SIGNAL_LOW ) { if ( lastUserPress == FALSE ) { lastUserPress = TRUE; setUserLED( FALSE ); sendOffButtonMsgToUI(TRUE); } } else { lastUserPress = FALSE; } #endif // manage data to be transmitted to other sub-systems execSystemCommTx(); } #ifdef TASK_TIMING_OUTPUT_ENABLED // set GPIO low to indicate general task has finished executing setCPLDLampGreen( PIN_SIGNAL_LOW ); #endif }