Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -reb877ae36c28eb83553ee11ccccf42e2c4a5b4d2 -r2a3a47ca90ad19851a30c52f6999a56d5f578783 --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision eb877ae36c28eb83553ee11ccccf42e2c4a5b4d2) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 2a3a47ca90ad19851a30c52f6999a56d5f578783) @@ -1,50 +1,130 @@ -/************************************************************************** - * - * 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 TaskPriority.c - * - * @date 19-Sep-2019 - * @author S. Nash - * - * @brief Priority task handler. - * - **************************************************************************/ - -#include -#include "gio.h" - -#include "FPGA.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 TaskPriority.c +* +* @author (last) Sean Nash +* @date (last) 12-Nov-2021 +* +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 +* +***************************************************************************/ + +#include "Accel.h" +#include "AirTrap.h" +#include "BloodFlow.h" +#include "BloodLeak.h" +#include "Bubble.h" +#include "Buttons.h" +#include "CPLD.h" +#include "DialInFlow.h" +#include "DialOutFlow.h" +#include "FluidLeak.h" +#include "FPGA.h" +#include "NVDataMgmt.h" +#include "InternalADC.h" +#include "SyringePump.h" +#include "SystemComm.h" +#include "Valves.h" #include "WatchdogMgmt.h" -#include "TaskPriority.h" +#include "TaskPriority.h" + +#include "Fans.h" -/************************************************************************* - * @brief taskPriority +/** + * @addtogroup TaskPriority + * @{ + */ + +/*********************************************************************//** + * @brief * The taskPriority function handles the scheduled Priority Task interrupt. * Calls the executive functions for FPGA, pumps, valves, and buttons. - * @details - * Inputs : none - * Outputs : Executive for the FPGA, pumps, valves, and buttons called. + * @details Inputs: none + * @details Outputs: Executives running in priority task are called. + * @return none *************************************************************************/ void taskPriority( void ) { - // 1st pass for FPGA - execFPGAIn(); +#ifdef TASK_TIMING_OUTPUT_ENABLED + // Set GPIO high to indicate priority task has begun executing + setCPLDLampRed( PIN_SIGNAL_HIGH ); +#endif + + // Prevent most processing until UI has started communicating +#ifndef SIMULATE_UI + if ( TRUE == uiCommunicated() ) +#endif + { + // 1st pass for FPGA + execFPGAIn(); - // monitor and process buttons - execButtons(); +#ifndef BOARD_WITH_NO_HARDWARE + // Verify processor clock speed against FPGA clock + execFPGAClockSpeedTest(); +#ifndef CAN_TEST + // Monitor and process buttons + execButtons(); - // 2nd pass for FPGA - execFPGAOut(); + // Monitor internal ADC channels + execInternalADC(); + + // Monitor air trap level sensors + execAirTrapMonitor(); + + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) + { + // Control/Monitor syringe pump + execSyringePump(); + } - // check in with watchdog manager - checkInWithWatchdogMgmt( TASK_PRIORITY ); + // Monitor blood pump and flow + execBloodFlowMonitor(); - // toggle GPIO to indicate priority task has executed -// gioToggleBit( gioPORTB, 3 ); -} + // Monitor dialysate inlet pump and flow + execDialInFlowMonitor(); + // Monitor dialysate outlet pump and load cells + execDialOutFlowMonitor(); + + // Monitor fluid leak detector + execFluidLeak(); + + // Monitor blood leak detector + execBloodLeak(); + + // Monitor air bubble detectors + execBubbles(); + +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ACCELEROMETERS ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + // Monitor accelerometer + execAccel(); + } + + // Exec and monitor valves + execValves(); +#endif +#endif + // 2nd pass for FPGA + execFPGAOut(); + } + + // Check in with watchdog manager + checkInWithWatchdogMgmt( TASK_PRIORITY ); + +#ifdef TASK_TIMING_OUTPUT_ENABLED + // Set GPIO low to indicate priority task has finished executing + setCPLDLampRed( PIN_SIGNAL_LOW ); +#endif +} + +/**@}*/