Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -reb877ae36c28eb83553ee11ccccf42e2c4a5b4d2 -r0d60b097df179aeaa2df1f1ad5ec3b9099fc0006 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision eb877ae36c28eb83553ee11ccccf42e2c4a5b4d2) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 0d60b097df179aeaa2df1f1ad5ec3b9099fc0006) @@ -1,80 +1,133 @@ -/************************************************************************** - * - * Copyright (c) 2019-2019 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 - * - * @date 19-Sep-2019 - * @author S. Nash - * - * @brief General task handler. - * - **************************************************************************/ - -#include -#include "gio.h" -#include "lin.h" - -#include "Common.h" +/************************************************************************** +* +* Copyright (c) 2019-2022 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) Darren Cox +* @date (last) 10-Mar-2022 +* +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 +* +***************************************************************************/ + +#include "AirTrap.h" +#include "AlarmLamp.h" +#include "BloodFlow.h" +#include "CPLD.h" +#include "DGInterface.h" +#include "DialInFlow.h" +#include "DialOutFlow.h" +#include "Fans.h" +#include "NVDataMgmt.h" #include "OperationModes.h" +#include "PresOccl.h" +#include "RTC.h" +#include "Switches.h" #include "SystemComm.h" -#include "WatchdogMgmt.h" -#include "TaskGeneral.h" +#include "SystemCommMessages.h" +#include "TaskGeneral.h" +#include "Temperatures.h" +#include "Voltages.h" +#include "WatchdogMgmt.h" + +/** + * @addtogroup TaskGeneral + * @{ + */ + +// ********** private data ********** -#ifdef RM46_EVAL_BOARD_TARGET - #include "CPLD.h" - #include "SystemCommMessages.h" - static BOOL lastUserPress = FALSE; -#endif - -/************************************************************************* - * @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. - * @param none +/*********************************************************************//** + * @brief + * The taskGeneral function handles the scheduled General Task interrupt. + * Calls the executive functions for most monitors and controllers, the + * operation modes, the system communications, and alarms. + * @details Inputs: none + * @details Outputs: Executives running in general task are called. * @return none *************************************************************************/ void taskGeneral( void ) -{ - // check in with watchdog manager - checkInWithWatchdogMgmt( TASK_GENERAL ); // do this first to keep timing consistent with watchdog management +{ +#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(); - // manage data received from other sub-systems - execSystemCommRx(); + // Prevent most processing until UI has started communicating +#ifndef SIMULATE_UI + if ( TRUE == uiCommunicated() ) +#endif + { +#ifndef BOARD_WITH_NO_HARDWARE + // Monitor DG + execDGInterfaceMonitor(); - // run operation mode state machine - execOperationModes(); + // Monitor pressure/occlusion sensors + execPresOccl(); + + // Monitor voltages + execVoltagesMonitor(); + + // Monitor switches + execSwitches(); + + // Monitor temperatures + execTemperatures(); +#endif - // control alarm lamp - execAlarmLamp(); + // Run operation mode state machine + execOperationModes(); + + +#ifndef BOARD_WITH_NO_HARDWARE + + // Manage RTC + execRTC(); + + // Control air trap valve + execAirTrapController(); -#ifdef RM46_EVAL_BOARD_TARGET - if ( getUserButtonState() == PIN_SIGNAL_LOW ) - { - if ( lastUserPress == FALSE ) - { - lastUserPress = TRUE; - setUserLED( FALSE ); - sendOffButtonMsgToUI(); - } - } - else - { - lastUserPress = FALSE; - } -#endif + // Control blood pump + execBloodFlowController(); - // manage data to be transmitted to other sub-systems - execSystemCommTx(); + // Control dialysate inlet pump + execDialInFlowController(); - // toggle GPIO to indicate general task has executed -// gioToggleBit( gioPORTB, 1 ); -} + // Control dialysate outlet pump (keep after call to BP and DPi controllers) + execDialOutFlowController(); + + // Monitor/Control fans + execFans(); + + // Manage NVDataMgmt process record state machine + execNVDataMgmtProcessRecord(); + + // Manage alarm state + execAlarmMgmt(); +#endif + + // Monitor processor RAM status + //execRAMMonitor(); // DN-01SEPT2022 + // 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 +} + +/**@}*/