Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r79bf3d1f0df93b3fffd1d0136db9275544b76112 -r60ec2f1256b02ee0a6d4346877494ce1bda55ab2 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 79bf3d1f0df93b3fffd1d0136db9275544b76112) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 60ec2f1256b02ee0a6d4346877494ce1bda55ab2) @@ -190,18 +190,12 @@ // Assume the target temperature has not changed heatersStatus[ heater ].hasTargetTempChanged = FALSE; - F32 currentTargetTemperature = heatersStatus[ heater ].originalTargetTemp; - - // Check if the current target temperature in structure is different from the new requested target temperature - if ( fabs( targetTemperature - currentTargetTemperature ) > NEARLY_ZERO ) + // Check if the requested temperature is within the allowed range + if ( ( targetTemperature >= MINIMUM_TARGET_TEMPERATURE ) && ( targetTemperature <= MAXIMUM_TARGET_TEMPERATURE ) ) { - // Check if the requested temperature is within the allowed range - if ( ( targetTemperature >= MINIMUM_TARGET_TEMPERATURE ) && ( targetTemperature <= MAXIMUM_TARGET_TEMPERATURE ) ) - { - heatersStatus[ heater ].originalTargetTemp = targetTemperature; - heatersStatus[ heater ].hasTargetTempChanged = TRUE; - // TODO alarm if temperature if out of range or just reject? - } + heatersStatus[ heater ].originalTargetTemp = targetTemperature; + heatersStatus[ heater ].hasTargetTempChanged = TRUE; + // TODO alarm if temperature if out of range or just reject? } } else Index: firmware/App/Modes/ModeFlush.c =================================================================== diff -u -raf0faf02f1bd7bffcce083e9b52988a01c343d8e -r60ec2f1256b02ee0a6d4346877494ce1bda55ab2 --- firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision af0faf02f1bd7bffcce083e9b52988a01c343d8e) +++ firmware/App/Modes/ModeFlush.c (.../ModeFlush.c) (revision 60ec2f1256b02ee0a6d4346877494ce1bda55ab2) @@ -48,7 +48,7 @@ #define DRAIN_WEIGHT_UNCHANGE_TIMEOUT ( 6 * MS_PER_SECOND ) ///< Time period of unchanged weight during draining before timeout. // Flush drain path state defines -#define FLUSH_DRAIN_WAIT_TIME_MS ( 2 /* 60 */ * MS_PER_SECOND ) ///< Flush Drain path wait time in milliseconds. TODo it was 2 minutes +#define FLUSH_DRAIN_WAIT_TIME_MS ( 2 * MS_PER_SECOND ) ///< Flush Drain path wait time in milliseconds. TODo it was 2 minutes // Flush dialysate state defines #define FLUSH_DIALYSATE_WAIT_TIME_MS ( 0.5 * 60 * MS_PER_SECOND ) ///< Flush dialysate wait time in milliseconds. @@ -349,7 +349,7 @@ stateTimerStart = getMSTimerCount(); rsrvr2Status = DG_RESERVOIR_ABOVE_TARGET; - state = DG_FLUSH_STATE_DRAIN_R2; //DG_FLUSH_STATE_CANCEL_BASIC_PATH; + state = DG_FLUSH_STATE_DRAIN_R2; } else if ( DG_RESERVOIR_NOT_REACHED_TARGET == rsrvr1Status ) { Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -raf0faf02f1bd7bffcce083e9b52988a01c343d8e -r60ec2f1256b02ee0a6d4346877494ce1bda55ab2 --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision af0faf02f1bd7bffcce083e9b52988a01c343d8e) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 60ec2f1256b02ee0a6d4346877494ce1bda55ab2) @@ -110,7 +110,7 @@ // the new PWMs for the main and small primary heaters #ifndef DISABLE_FLOW_CONTROL_TREATMENT setROPumpTargetFlowRate( TARGET_FLUSH_LINES_RO_FLOW_RATE_L, TARGET_RO_PRESSURE_PSI ); - setHeaterTargetTemperature( DG_PRIMARY_HEATER, 39.0 ); // DEBUG_DENALI remove this line. It comes form HD this for testing only + setHeaterTargetTemperature( DG_PRIMARY_HEATER, 39.0 ); // remove this line. It comes form HD this for testing only startHeater( DG_PRIMARY_HEATER ); #endif Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -raf0faf02f1bd7bffcce083e9b52988a01c343d8e -r60ec2f1256b02ee0a6d4346877494ce1bda55ab2 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision af0faf02f1bd7bffcce083e9b52988a01c343d8e) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 60ec2f1256b02ee0a6d4346877494ce1bda55ab2) @@ -1032,7 +1032,7 @@ // Get the current volumes of R1 & R2. These values will be used to make sure the reservoirs' // volume does not change more than a certain amount during the actual heat disinfect cycle - R1HeatDisinfectVol = getLoadCellLargeFilteredWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ); // TODO remove + R1HeatDisinfectVol = getLoadCellLargeFilteredWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ); R2HeatDisinfectVol = getLoadCellLargeFilteredWeight( LOAD_CELL_RESERVOIR_2_PRIMARY ); stateTimer = getMSTimerCount(); Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -raf0faf02f1bd7bffcce083e9b52988a01c343d8e -r60ec2f1256b02ee0a6d4346877494ce1bda55ab2 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision af0faf02f1bd7bffcce083e9b52988a01c343d8e) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 60ec2f1256b02ee0a6d4346877494ce1bda55ab2) @@ -33,6 +33,7 @@ #include "RTC.h" #include "SafetyShutdown.h" #include "SystemCommMessages.h" +#include "TaskGeneral.h" #include "TemperatureSensors.h" #include "Thermistors.h" #include "UVReactors.h" @@ -45,29 +46,37 @@ // ********** private data ********** -static DG_POST_STATE_T postState = DG_POST_STATE_START; ///< Currently active initialize & POST state. -static BOOL postCompleted = FALSE; ///< Flag indicating POST completed. -static BOOL postPassed = FALSE; ///< Flag indicating all POST tests passed. -static BOOL tempPOSTPassed = TRUE; ///< Temporary flag indicating all POST tests completed so far have passed. +#define START_POST_DELAY_COUNT ( ( 1 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Start POST delay in count. + +static DG_POST_STATE_T postState = DG_POST_STATE_START; ///< Currently active initialize & POST state. +static BOOL postCompleted = FALSE; ///< Flag indicating POST completed. +static BOOL postPassed = FALSE; ///< Flag indicating all POST tests passed. +static BOOL tempPOSTPassed = TRUE; ///< Temporary flag indicating all POST tests completed so far have passed. +static U32 startPOSTDelayCounter = 0; ///< Start POST delay counter. + // ********** private function prototypes ********** static DG_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ); +static DG_POST_STATE_T handlePOSTStateStart( void ); static SELF_TEST_STATUS_T execFWCompatibilityTest( void ); /*********************************************************************//** * @brief - * The initInitAndPOSTMode function initializes the Initialization and POST mode module. + * The initInitAndPOSTMode function initializes the Initialization and POST + * mode module. * @details Inputs: none - * @details Outputs: Initialization and POST mode module initialized + * @details Outputs: postState, postCompleted, tempPOSTPassed, + * startPOSTDelayCounter * @return none *************************************************************************/ void initInitAndPOSTMode( void ) { - postState = DG_POST_STATE_START; - postCompleted = FALSE; - postPassed = FALSE; - tempPOSTPassed = TRUE; + postState = DG_POST_STATE_START; + postCompleted = FALSE; + postPassed = FALSE; + tempPOSTPassed = TRUE; + startPOSTDelayCounter = 0; } /*********************************************************************//** @@ -101,11 +110,7 @@ switch ( postState ) { case DG_POST_STATE_START: - SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_STARTUP, 0, 0 ) - postState = DG_POST_STATE_FW_COMPATIBILITY; -#ifdef SKIP_POST - postState = DG_POST_STATE_COMPLETED; -#endif + postState = handlePOSTStateStart(); break; case DG_POST_STATE_FW_COMPATIBILITY: @@ -306,6 +311,36 @@ /*********************************************************************//** * @brief + * The handlePOSTStateStart function handles the POST start state. + * @details Inputs: startPOSTDelayCounter + * @details Outputs: startPOSTDelayCounter + * @return next POST state + *************************************************************************/ +static DG_POST_STATE_T handlePOSTStateStart( void ) +{ + DG_POST_STATE_T state = DG_POST_STATE_START; + + // There is a delay before starting POST to make sure the CAN bus is up and listening so + // when the event data can be sent + if ( ++startPOSTDelayCounter > START_POST_DELAY_COUNT ) + { + // Send the startup event + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_STARTUP, 0, 0 ) + // Send the first submode change event. It is the mode Init and it does not start from a previous + // mode previous and current are both published as Init + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_OP_MODE_CHANGE, DG_MODE_INIT, DG_MODE_INIT ) + state = DG_POST_STATE_FW_COMPATIBILITY; +#ifdef SKIP_POST + state = DG_POST_STATE_COMPLETED; +#endif + startPOSTDelayCounter = 0; + } + + return state; +} + +/*********************************************************************//** + * @brief * The getCurrentInitAndPOSTState function returns the current state of the * initialization and POST mode. * @details Inputs: postState Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -raf0faf02f1bd7bffcce083e9b52988a01c343d8e -r60ec2f1256b02ee0a6d4346877494ce1bda55ab2 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision af0faf02f1bd7bffcce083e9b52988a01c343d8e) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 60ec2f1256b02ee0a6d4346877494ce1bda55ab2) @@ -234,7 +234,7 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_EVENT; - // The payload length is the event ID, 2 event datas and the events data types for each of the event datas + // The payload length is the event ID, 2 event datas and the events data types for each of the event data msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( EVENT_DATAS_T ) + 2 * sizeof( U32 ); memcpy( payloadPtr, &e, sizeof( U32 ) );