Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r1d44cf33cf4461b81b19a8ab0e402c609649786b -r7f68a672cbc13227f557ec7ddeecd4cc5b706a99 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 7f68a672cbc13227f557ec7ddeecd4cc5b706a99) @@ -1,60 +1,108 @@ -/************************************************************************** - * - * 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 - * - * @date 19-Sep-2019 - * @author S. Nash - * - * @brief General task handler. - * - **************************************************************************/ +/************************************************************************** +* +* 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) Quang Nguyen +* @date (last) 25-Aug-2020 +* +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 +* +***************************************************************************/ #include "gio.h" #include "lin.h" - -#include "DrainPump.h" -#include "Heaters.h" + +#include "ConcentratePumps.h" +#include "DrainPump.h" +#include "Fans.h" +#include "Heaters.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "Reservoirs.h" -#include "ROPump.h" +#include "ROPump.h" +#include "RTC.h" #include "SystemComm.h" #include "SystemCommMessages.h" +#include "TaskGeneral.h" +#include "Thermistors.h" +#include "UVReactors.h" #include "WatchdogMgmt.h" -#include "TaskGeneral.h" + +/** + * @addtogroup TaskGeneral + * @{ + */ + +#ifdef TASK_TIMING_OUTPUT_ENABLED + #include "mibspi.h" + #define TASK_TIMING_TEST_PIN_SPI1_PORT_MASK 0x00000020 // (CS5 - re-purposed as output GPIO) + #define SET_TASK_ON() { mibspiREG3->PC3 |= TASK_TIMING_TEST_PIN_SPI1_PORT_MASK; } + #define SET_TASK_OFF() { mibspiREG3->PC3 &= ~TASK_TIMING_TEST_PIN_SPI1_PORT_MASK; } +#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: Executed all general task functions. * @return none *************************************************************************/ void taskGeneral( void ) -{ +{ + /* Order of exec functions + * 1. Comm Rx + * 2. Monitors + * 3. Op modes + * 4. Controllers + * 5. Comm Tx + * */ + +#ifdef TASK_TIMING_OUTPUT_ENABLED +// SET_TASK_ON(); // TODO - uncomment and define TASK_TIMING_OUTPUT_ENABLED to monitor this tasks timing +#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(); + execSystemCommRx(); + + // Control and monitor RTC + execRTC(); + +#ifndef BOARD_WITH_NO_HARDWARE + // monitor concentrate pumps + execConcentratePumpMonitor(); + + // Monitor thermistors state machine + execThermistors(); -#ifndef CAN_TEST // manage RO pump execROPumpController(); // manage drain pump - execDrainPumpController(); + execDrainPumpController(); + + // manage concentrate pumps + execConcentratePumpController(); + + // Manage fans controller + execFans(); // manage time-based reservoir tasks - execReservoirs(); + execReservoirs(); + + // Manage UV reactors controller + execUVReactors(); +#endif #ifndef DISABLE_HEATERS_AND_TEMPS // Primary heaters state machine @@ -63,33 +111,19 @@ // Trimmer heater state machine execTrimmerHeater(); #endif -#endif // run operation mode state machine - execOperationModes(); + execOperationModes(); + + // Run non-volatile data management state machine that sends the data record + // to Dialin + execNVDataMgmtProcessRecord(); -#ifdef CAN_TEST - { // send test msg every 100ms - static U32 canTestCtr = 0; - static U32 canTestMsgCtr = 0; - if ( ++canTestCtr >= 2 ) - { - if ( ++canTestMsgCtr <= 23076) - { - broadcastCANTest1LargeFrequentMessage(); - } - else - { - canTestMsgCtr = 23076+1; - } - canTestCtr = 0; - } - } -#endif - // manage data to be transmitted to other sub-systems execSystemCommTx(); - // toggle GPIO to indicate general task has executed -// gioToggleBit( gioPORTB, 1 ); +#ifdef TASK_TIMING_OUTPUT_ENABLED +// SET_TASK_OFF(); // TODO - uncomment and define TASK_TIMING_OUTPUT_ENABLED to monitor this tasks timing +#endif } - + +/**@}*/