Index: firmware/App/Modes/ModeFault.c =================================================================== diff -u -rd91a24c730aeb5cd7e3eba9ef4eca78e442911f8 -raf2674758d7b9dbe05e348b318845975b423509f --- firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision d91a24c730aeb5cd7e3eba9ef4eca78e442911f8) +++ firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision af2674758d7b9dbe05e348b318845975b423509f) @@ -16,15 +16,15 @@ ***************************************************************************/ #include "AlarmLamp.h" -#ifdef EMC_TEST_BUILD // TODO - test code #include "BloodFlow.h" +#ifdef EMC_TEST_BUILD // TODO - test code #include "Buttons.h" +#endif #include "DialInFlow.h" #include "DialOutFlow.h" -#include "FPGA.h" -#endif -#include "OperationModes.h" #include "ModeFault.h" +#include "OperationModes.h" +#include "Valves.h" /** * @addtogroup HDFaultMode @@ -38,41 +38,49 @@ /*********************************************************************//** * @brief * The initFaultMode function initializes the Fault Mode module. - * @details - * Inputs : none - * Outputs : Fault Mode module initialized. + * @details Inputs: none + * @details Outputs: Fault Mode module initialized. * @return none *************************************************************************/ void initFaultMode( void ) { + // TODO - anything to do here? } /*********************************************************************//** * @brief * The transitionToFaultMode function prepares for transition to fault mode. - * @details - * Inputs : none - * Outputs : + * @details Inputs: none + * @details Outputs: * @return none *************************************************************************/ void transitionToFaultMode( void ) { -#ifdef EMC_TEST_BUILD // TODO - test code - enableValvesPIDControl(0); // enable valves -#endif + // TODO - anything to do here? } /*********************************************************************//** * @brief * The execFaultMode function executes the Fault Mode state machine. - * @details - * Inputs : none - * Outputs : + * @details Inputs: none + * @details Outputs: * @return current state (sub-mode) *************************************************************************/ U32 execFaultMode( void ) { -#ifdef EMC_TEST_BUILD // TODO - test code +#ifndef EMC_TEST_BUILD + // ensure all pumps are stopped + signalBloodPumpHardStop(); + signalDialInPumpHardStop(); + signalDialOutPumpHardStop(); + // ensure all valves are in safe position + setValveAirTrap( STATE_CLOSED ); + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); +#else + // TODO - EMC test code - remove later static U32 toggle = 0; static BOOL button_state = FALSE; BOOL stop = isStopButtonPressed(); @@ -85,10 +93,10 @@ switch ( toggle ) { case 0: // pumps and valves off - setDialyzerInletValvePosition( 0 ); - setDialyzerOutletValvePosition( 0 ); - setVenousBloodValvePosition( 0 ); - setArterialBloodValvePosition( 0 ); + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); break; case 1: // pumps on, valves off @@ -98,10 +106,10 @@ break; case 2: // pumps on, valves on - setDialyzerInletValvePosition( 12000 ); - setDialyzerOutletValvePosition( 12000 ); - setVenousBloodValvePosition( 12000 ); - setArterialBloodValvePosition( 12000 ); + setValvePosition( VDI, VALVE_POSITION_B_OPEN ); + setValvePosition( VDO, VALVE_POSITION_B_OPEN ); + setValvePosition( VBA, VALVE_POSITION_B_OPEN ); + setValvePosition( VBV, VALVE_POSITION_B_OPEN ); break; case 3: // pumps off, valves on @@ -115,10 +123,10 @@ setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - setDialyzerInletValvePosition( 0 ); - setDialyzerOutletValvePosition( 0 ); - setVenousBloodValvePosition( 0 ); - setArterialBloodValvePosition( 0 ); + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); break; } }