Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -r61716bc97ecca8af1ec560333844a8cf602eccb0 -r95561ae1f450dc687b9ce8d4cce2ac91293bc925 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 61716bc97ecca8af1ec560333844a8cf602eccb0) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 95561ae1f450dc687b9ce8d4cce2ac91293bc925) @@ -56,6 +56,12 @@ #define BLOOD_LEAK_MIN_WAIT_TIME_2_GET_CAL_MS ( 2 * MS_PER_SECOND ) ///< Blood leak minimum wait time to get calibration in milliseconds. +// TODO remove after zeroing was fixed +#define BLOOD_LEAK_ZERO_SENSOR_SEQ_LENGTH 5 ///< Blood leak zero sensor sequence length. +#define BLOOD_LEAK_ZERO_Z_CHAR_ASCII 90 ///< Blood leak zero sensor 'Z' command in ascii. +#define BLOOD_LEAK_ZERO_FIFO_STOP_INDEX 2 ///< Blood leak zero sensor stop writing to FIFO command. +// TODO remove after zeroing was fixed + /// Defined states for the blood leak detector state machine. typedef enum BloodLeakStates { @@ -84,7 +90,7 @@ static OVERRIDE_U32_T bloodLeakDataPublishInterval = { BLOOD_LEAK_PUB_INTERVAL, BLOOD_LEAK_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms) at which to publish blood leak data to CAN bus. static U32 bloodLeakDataPublicationTimerCounter = 0; ///< Timer counter used to schedule blood leak data publication to CAN bus. -static U32 bloodLeakUARTCmdIndex; ///< Blood leak UART command index. +static U32 bloodLeakUARTCmdIndex = 0; ///< Blood leak UART command index. static U32 bloodLeakSetPointSeqLength = 0; ///< Blood leak set point sequence actual length. static U08 bloodLeakSetPointSequence[ BLOOD_LEAK_SET_POINT_SEQ_MAX_LENGTH ]; ///< Blood leak set point sequence array. static U32 bloodLeakWait2ReadSetPointCounter = 0; ///< Blood leak wait to read delay counter. @@ -100,6 +106,15 @@ BLOOD_LEAK_UART_COMM_ACTIVE_HIGH, BLOOD_LEAK_UART_COMM_ACTIVE_LOW }; +// TODO remove after zeroing was fixed +/// Blood leak zero sensor sequence array. +static const U08 BLOOD_LEAK_ZERO_SNSR_SEQUENCE[ BLOOD_LEAK_ZERO_SENSOR_SEQ_LENGTH ] = { BLOOD_LEAK_ZERO_Z_CHAR_ASCII, + BLOOD_LEAK_CARRIAGE_RETURN_ASCII, + BLOOD_LEAK_STOP_WRITE_FIFO_COMMAND, + BLOOD_LEAK_UART_COMM_ACTIVE_HIGH, + BLOOD_LEAK_UART_COMM_ACTIVE_LOW }; +// TODO remove after zeroing was fixed + // ********** private function prototypes ********** static BLOOD_LEAK_STATES_T handleBloodLeakStartupState( void ); @@ -229,6 +244,7 @@ void zeroBloodLeak( void ) { bloodLeakZeroRequested = TRUE; + bloodLeakUARTCmdIndex = 0; } /*********************************************************************//** @@ -323,7 +339,6 @@ { activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SENSOR_SET_POINT_SET_FAILURE ); } - } else { @@ -396,7 +411,7 @@ state = BLOOD_LEAK_ZERO_STATE; bloodLeakZeroRequested = FALSE; - setFPGABloodLeakZero(); + //setFPGABloodLeakZero(); // DEBUG_DENALI bloodLeakZeroStartTime = getMSTimerCount(); } @@ -415,22 +430,40 @@ { BLOOD_LEAK_STATES_T state = BLOOD_LEAK_ZERO_STATE; - if ( TRUE == FPGABloodLeakZeroDetected() ) + if ( bloodLeakUARTCmdIndex < BLOOD_LEAK_ZERO_SENSOR_SEQ_LENGTH ) { - state = BLOOD_LEAK_SELF_TEST_STATE; - bloodLeakSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; - clearFPGABloodLeakZero(); - setFPGABloodLeakSelfTest(); - bloodLeakSelfTestStartTime = getMSTimerCount(); + U08 command = BLOOD_LEAK_ZERO_SNSR_SEQUENCE[ bloodLeakUARTCmdIndex ]; + + if ( bloodLeakUARTCmdIndex <= BLOOD_LEAK_ZERO_FIFO_STOP_INDEX ) + { + setFPGABloodLeakUARTTransmit( (U08)command ); + } + else + { + setFPGABloodLeakUARTControl( (U08)command ); + } + + bloodLeakUARTCmdIndex++; } else { - if ( TRUE == didTimeout( bloodLeakZeroStartTime, BLOOD_LEAK_TIMEOUT_MS ) ) + if ( TRUE == FPGABloodLeakZeroDetected() ) { -#ifndef IGNORE_BLOOD_LEAK_ALARM - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_FAULT ); -#endif + state = BLOOD_LEAK_SELF_TEST_STATE; + bloodLeakSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; + clearFPGABloodLeakZero(); + setFPGABloodLeakSelfTest(); + bloodLeakSelfTestStartTime = getMSTimerCount(); } + else + { + if ( TRUE == didTimeout( bloodLeakZeroStartTime, BLOOD_LEAK_TIMEOUT_MS ) ) + { + #ifndef IGNORE_BLOOD_LEAK_ALARM + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_FAULT ); + #endif + } + } } return state; @@ -529,7 +562,7 @@ state = BLOOD_LEAK_ZERO_STATE; bloodLeakZeroRequested = FALSE; - setFPGABloodLeakZero(); + //setFPGABloodLeakZero(); // DEBUG_DENALI bloodLeakZeroStartTime = getMSTimerCount(); } Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r61716bc97ecca8af1ec560333844a8cf602eccb0 -r95561ae1f450dc687b9ce8d4cce2ac91293bc925 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 61716bc97ecca8af1ec560333844a8cf602eccb0) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 95561ae1f450dc687b9ce8d4cce2ac91293bc925) @@ -84,12 +84,11 @@ static DG_RESERVOIR_ID_T dgActiveReservoir = DG_RESERVOIR_2; ///< Latest active reservoir reported by the DG. static DG_RESERVOIR_ID_T dgActiveReservoirSet = DG_RESERVOIR_2; ///< Active reservoir commanded. -// TODO remove below variables +// TODO remove below variables static U32 dgReservoirFillVolumeTarget = 0; ///< Latest fill-to volume reported by the DG. static U32 dgReservoirFillVolumeTargetSet = 0; ///< Fill-to volume commanded. static U32 dgReservoirDrainVolumeTarget = 0; ///< Latest drain-to volume reported by the DG. static U32 dgReservoirDrainVolumeTargetSet = 0; ///< Drain-to volume commanded. - static DG_DISINFECT_UI_STATES_T disinfectsStatus; ///< DG disinfects status. static DG_MIXING_RATIOS_T dgMixingRatios; ///< DG mixing ratios. Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r6982379266891326c9d45aecd7d54ad5c85ea69f -r95561ae1f450dc687b9ce8d4cce2ac91293bc925 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 6982379266891326c9d45aecd7d54ad5c85ea69f) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 95561ae1f450dc687b9ce8d4cce2ac91293bc925) @@ -565,7 +565,7 @@ * @brief * The handleReservoirMgmtWaitForFillSettleState function executes the reservoir * management wait for fill to settle state. - * @details Inputs: reservoirSwitchTimer + * @details Inputs: reservoirSwitchTimer, volSpentML * @details Outputs: reservoirSwitchTimer, volSpentML * @return next reservoir management state of the state machine *************************************************************************/ @@ -574,7 +574,7 @@ TREATMENT_RESERVOIR_MGMT_STATE_T state = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_FILL_SETTLE_STATE; // Wait for the reservoir to settle and then send the commands to switch the active reservoir - if ( TRUE == didTimeout( reservoirSwitchStartTimeMS, RESERVOIR_SETTLE_TIME_MS ) ) + if ( ( TRUE == didTimeout( reservoirSwitchStartTimeMS, RESERVOIR_SETTLE_TIME_MS ) ) && ( volSpentML >= (F32)FILL_RESERVOIR_TO_VOLUME_ML ) ) { DG_RESERVOIR_ID_T inactiveRes = getDGInactiveReservoir();