Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -rf43eb1e9e0803776ec7420b16e1db8760b020bd9 -rc48a99d2d1c852adcc986253b6c420a90dab7bfe --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision f43eb1e9e0803776ec7420b16e1db8760b020bd9) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision c48a99d2d1c852adcc986253b6c420a90dab7bfe) @@ -14,6 +14,7 @@ * **************************************************************************/ +#include "FPGA.h" #include "OperationModes.h" #include "Timers.h" #include "ModeFill.h" @@ -32,12 +33,10 @@ #define QUARTER_SECOND 250 #define HALF_SECOND 500 -/// Enumberation of fill mode states. +/// Enumeration of fill mode states. typedef enum Fill_Mode_States { FILL_MODE_STATE_START = 0, ///< Start fill mode state. - FILL_MODE_STATE_CHECK_INLET_WATER, ///< Check inlet water state. - FILL_MODE_STATE_CREATE_PRODUCT_WATER, ///< Create product water state. FILL_MODE_STATE_DIALYSATE_PRODUCTION, ///< Dialysate production state. FILL_MODE_STATE_DELIVER_DIALYSATE, ///< Deliver dialysate state. NUM_OF_FILL_MODE_STATES ///< Number of fill mode states. @@ -49,8 +48,6 @@ // ********** private function prototypes ********** -static FILL_MODE_STATE_T handleCheckInletWaterState( void ); -static FILL_MODE_STATE_T handleCreateProductWaterState( void ); static FILL_MODE_STATE_T handleDialysateProductionState( void ); static FILL_MODE_STATE_T handleDeliverDialysateState( void ); @@ -78,7 +75,13 @@ *************************************************************************/ void transitionToFillMode( void ) { - fillState = FILL_MODE_STATE_START; + // re-initialize fill mode each time we transition to fill mode + initFillMode(); + + // TODO - set initial actuator states + setFPGAValveStates(0x014F); + // VDr, VPo to drain + // Conc. pumps on } /*********************************************************************//** @@ -95,17 +98,9 @@ switch ( fillState ) { case FILL_MODE_STATE_START: - fillState = FILL_MODE_STATE_CHECK_INLET_WATER; + fillState = FILL_MODE_STATE_DIALYSATE_PRODUCTION; break; - case FILL_MODE_STATE_CHECK_INLET_WATER: - fillState = handleCheckInletWaterState(); - break; - - case FILL_MODE_STATE_CREATE_PRODUCT_WATER: - fillState = handleCreateProductWaterState(); - break; - case FILL_MODE_STATE_DIALYSATE_PRODUCTION: fillState = handleDialysateProductionState(); break; @@ -123,40 +118,6 @@ /*********************************************************************//** * @brief - * The handleCheckInletWaterState function executes the Check Inlet Water \n - * state of the Fill Mode state machine. - * @details - * Inputs : none - * Outputs : - * @param none - * @return the next state - *************************************************************************/ -static FILL_MODE_STATE_T handleCheckInletWaterState( void ) -{ - FILL_MODE_STATE_T result = FILL_MODE_STATE_CHECK_INLET_WATER; - - return result; -} - -/*********************************************************************//** - * @brief - * The handleCreateProductWaterState function executes the Create Product \n - * Water state of the Fill Mode state machine. - * @details - * Inputs : none - * Outputs : - * @param none - * @return the next state - *************************************************************************/ -static FILL_MODE_STATE_T handleCreateProductWaterState( void ) -{ - FILL_MODE_STATE_T result = FILL_MODE_STATE_CREATE_PRODUCT_WATER; - - return result; -} - -/*********************************************************************//** - * @brief * The handleDialysateProductionState function executes the Dialysate Production \n * state of the Fill Mode state machine. * @details @@ -169,6 +130,14 @@ { FILL_MODE_STATE_T result = FILL_MODE_STATE_DIALYSATE_PRODUCTION; + // TODO - transition when temperature and mix is in range + if ( 1 ) + { + // TODO - VPo to reservoir + setFPGAValveStates(0x015F); + result = FILL_MODE_STATE_DELIVER_DIALYSATE; + } + return result; } @@ -186,6 +155,15 @@ { FILL_MODE_STATE_T result = FILL_MODE_STATE_DELIVER_DIALYSATE; + // TODO - transition back when temperature or mix out of range + + if ( 0 ) + { + // TODO - VPo to drain + setFPGAValveStates(0x014F); + result = FILL_MODE_STATE_DIALYSATE_PRODUCTION; + } + return result; }