Index: firmware/App/Controllers/BalancingChamber.c =================================================================== diff -u -r61061e547ac63df8f0090cc3a3ba81079c88ce9f -rb50acaa8dda74292fb41110440eaaa40f2959fb7 --- firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision 61061e547ac63df8f0090cc3a3ba81079c88ce9f) +++ firmware/App/Controllers/BalancingChamber.c (.../BalancingChamber.c) (revision b50acaa8dda74292fb41110440eaaa40f2959fb7) @@ -42,13 +42,13 @@ #define BAL_CHAMBER_DATA_PUBLISH_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the balancing chamber data published. #define BAL_CHAMBER_FILL_PRES_DROP_MS ( 200 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber filling started and corrosponding valves opened. #define BAL_CHAMBER_FILL_COMPLETE_MS ( 300 / TASK_GENERAL_INTERVAL ) ///< Time (ms/tasktime) to confirm the balancing chamber fill completed and pressure is within range -#define DRY_BICARB_CHAMBER_MAX_TIMEOUT_COUNT ( 20 * SEC_PER_MIN ) ///< Periodic bicarb chamber fill request. +#define DRY_BICARB_CHAMBER_MAX_TIMEOUT_COUNT ( 20 * 15 ) ///< Periodic bicarb chamber fill request. /// Payload record structure for balancing chamber switch only request typedef struct { - U32 startStop; ///< balancing chamber switching only start:1 and stop: 0 - F32 flowrate; ///< dialysate flowrate in ml/min + U32 startStop; ///< Balancing chamber switching only start:1 and stop: 0 + F32 flowrate; ///< Dialysate flowrate in ml/min } BC_SWITCHING_ONLY_START_CMD_PAYLOAD_T; // ********** private data ********** @@ -263,20 +263,43 @@ /*********************************************************************//** * @brief - * The valveControlForBCState1FillStart function actuates the valve combination - * for state 1 fill/drain process. + * The valveControlForBCClosedState function closes the all balancing + * chamber valves. * @details \b Inputs: none * @details \b Outputs: valve states * @return none. *************************************************************************/ -static void valveControlForBCState1FillStart( void ) +void valveControlForBCClosedState( void ) { // Close balancing chamber valve combinations D23,D20 and D21,D26 setValveState( D23_VALV, VALVE_STATE_CLOSED ); setValveState( D20_VALV, VALVE_STATE_CLOSED ); setValveState( D21_VALV, VALVE_STATE_CLOSED ); setValveState( D26_VALV, VALVE_STATE_CLOSED ); + //Close balancing chamber valve combinations D19,D24 and D25,D22 + setValveState( D19_VALV, VALVE_STATE_CLOSED ); + setValveState( D24_VALV, VALVE_STATE_CLOSED ); + setValveState( D25_VALV, VALVE_STATE_CLOSED ); + setValveState( D22_VALV, VALVE_STATE_CLOSED ); +} + +/*********************************************************************//** + * @brief + * The valveControlForBCOpenState function open the all balancing + * chamber valves. + * @details \b Inputs: none + * @details \b Outputs: valve states + * @return none. + *************************************************************************/ +void valveControlForBCOpenState( void ) +{ + // Open balancing chamber valve combinations D23,D20 and D21,D26 + setValveState( D23_VALV, VALVE_STATE_OPEN ); + setValveState( D20_VALV, VALVE_STATE_OPEN ); + setValveState( D21_VALV, VALVE_STATE_OPEN ); + setValveState( D26_VALV, VALVE_STATE_OPEN ); + //Open balancing chamber valve combinations D19,D24 and D25,D22 setValveState( D19_VALV, VALVE_STATE_OPEN ); setValveState( D24_VALV, VALVE_STATE_OPEN ); @@ -286,46 +309,115 @@ /*********************************************************************//** * @brief - * The valveControlForBCState1FillEnd function closes the valve opened - * for state 1 fill/drain process. + * The valveControlForBCFreshSideOnlyOpenState function opens the fresh side + * balancing chamber valves and closes the spent side valves. * @details \b Inputs: none * @details \b Outputs: valve states * @return none. *************************************************************************/ -static void valveControlForBCState1FillEnd( void ) +void valveControlForBCFreshSideOnlyOpenState( void ) { - //Close balancing chamber valve combinations D19,D24 and D25,D22 - setValveState( D19_VALV, VALVE_STATE_CLOSED ); - setValveState( D24_VALV, VALVE_STATE_CLOSED ); + // Open fresh balancing chamber valves D19,D20,D21,D22 + setValveState( D19_VALV, VALVE_STATE_OPEN ); + setValveState( D20_VALV, VALVE_STATE_OPEN ); + setValveState( D21_VALV, VALVE_STATE_OPEN ); + setValveState( D22_VALV, VALVE_STATE_OPEN ); + + // Close spent side valves D23,D24,D25,D26 + setValveState( D23_VALV, VALVE_STATE_CLOSED ); setValveState( D25_VALV, VALVE_STATE_CLOSED ); - setValveState( D22_VALV, VALVE_STATE_CLOSED ); + setValveState( D24_VALV, VALVE_STATE_CLOSED ); + setValveState( D26_VALV, VALVE_STATE_CLOSED ); } /*********************************************************************//** * @brief - * The valveControlForBCState2FillStart function actuates the valve combination - * for state 2 fill/drain process. - * @details \b Inputs: none - * @details \b Outputs: valve states - * @return none. + * The getCurrentBalancingChamberExecState function returns the current state + * of the balancing chamber. + * @details \b Inputs: balChamberExecState + * @details \b Outputs: none + * @return the current state of balancing chamber states. *************************************************************************/ -static void valveControlForBCState2FillStart( void ) +BAL_CHAMBER_EXEC_STATE_T getCurrentBalancingChamberExecState( void ) { - //Close balancing chamber valve combinations D19,D24 and D25,D22 - setValveState( D19_VALV, VALVE_STATE_CLOSED ); - setValveState( D24_VALV, VALVE_STATE_CLOSED ); - setValveState( D25_VALV, VALVE_STATE_CLOSED ); - setValveState( D22_VALV, VALVE_STATE_CLOSED ); + return balChamberExecState; +} - // Open balancing chamber valve combinations D23,D20 and D21,D26 - setValveState( D23_VALV, VALVE_STATE_OPEN ); - setValveState( D20_VALV, VALVE_STATE_OPEN ); - setValveState( D21_VALV, VALVE_STATE_OPEN ); - setValveState( D26_VALV, VALVE_STATE_OPEN ); +/*********************************************************************//** + * @brief + * The getBalancingChamberFillinProgressStatus function returns the current + * balancing chamber fill in progress status. + * @details \b Inputs: isBalChamberFillInProgress + * @details \b Outputs: none + * @return the current balancing chamber fill in progress. + *************************************************************************/ +BOOL getBalancingChamberFillinProgressStatus( void ) +{ + return isBalChamberFillInProgress; } /*********************************************************************//** * @brief + * The getBalChamberSwitchingFreq function gets the balancing chamber switching + * frequency value. + * @details \b Inputs: balChamberSwitchingFreq + * @details \b Outputs: none + * @return balancing chamber switching frequency + *************************************************************************/ +F32 getBalChamberSwitchingFreq( void ) +{ + F32 result = balChamberSwitchingFreq.data; + + if ( OVERRIDE_KEY == balChamberSwitchingFreq.override ) + { + result = balChamberSwitchingFreq.ovData; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The setBalChamberSwitchingOnlyStatus function sets the balancing chamber + * switching only On/Off status. + * @details \b Inputs: balanceChamberSwitchingOnly + * @details \b Outputs: none + * @return none + *************************************************************************/ +void setBalChamberSwitchingOnlyStatus( BOOL OnOff ) +{ + balanceChamberSwitchingOnly = OnOff; +} + +/*********************************************************************//** + * @brief + * The getBalChamberSwitchingOnlyStatus function gets the balancing chamber + * switching only status. + * @details \b Inputs: balanceChamberSwitchingOnly + * @details \b Outputs: none + * @return balancing chamber switching only without any pressure validation + * and dosing delivery + *************************************************************************/ +BOOL getBalChamberSwitchingOnlyStatus( void ) +{ + return balanceChamberSwitchingOnly; +} + +/*********************************************************************//** + * @brief + * The getBalChamberSwitchingPeriod function gets the balancing chamber + * switching period. + * @details \b Inputs: balChamberSwitchingPeriod + * @details \b Outputs: none + * @return balancing chamber switching period + *************************************************************************/ +U32 getBalChamberSwitchingPeriod( void ) +{ + return balChamberSwitchingPeriod; +} + +/*********************************************************************//** + * @brief * The valveControlForBCState2FillEnd function closes the valve opened * for state 2 fill/drain process. * @details \b Inputs: none @@ -343,71 +435,65 @@ /*********************************************************************//** * @brief - * The valveControlForBCClosedState function closes the all balancing - * chamber valves. + * The valveControlForBCState1FillStart function actuates the valve combination + * for state 1 fill/drain process. * @details \b Inputs: none * @details \b Outputs: valve states * @return none. *************************************************************************/ -void valveControlForBCClosedState( void ) +static void valveControlForBCState1FillStart( void ) { // Close balancing chamber valve combinations D23,D20 and D21,D26 setValveState( D23_VALV, VALVE_STATE_CLOSED ); setValveState( D20_VALV, VALVE_STATE_CLOSED ); setValveState( D21_VALV, VALVE_STATE_CLOSED ); setValveState( D26_VALV, VALVE_STATE_CLOSED ); - //Close balancing chamber valve combinations D19,D24 and D25,D22 - setValveState( D19_VALV, VALVE_STATE_CLOSED ); - setValveState( D24_VALV, VALVE_STATE_CLOSED ); - setValveState( D25_VALV, VALVE_STATE_CLOSED ); - setValveState( D22_VALV, VALVE_STATE_CLOSED ); + //Open balancing chamber valve combinations D19,D24 and D25,D22 + setValveState( D19_VALV, VALVE_STATE_OPEN ); + setValveState( D24_VALV, VALVE_STATE_OPEN ); + setValveState( D25_VALV, VALVE_STATE_OPEN ); + setValveState( D22_VALV, VALVE_STATE_OPEN ); } /*********************************************************************//** * @brief - * The valveControlForBCOpenState function open the all balancing - * chamber valves. + * The valveControlForBCState1FillEnd function closes the valve opened + * for state 1 fill/drain process. * @details \b Inputs: none * @details \b Outputs: valve states * @return none. *************************************************************************/ -void valveControlForBCOpenState( void ) +static void valveControlForBCState1FillEnd( void ) { - // Open balancing chamber valve combinations D23,D20 and D21,D26 - setValveState( D23_VALV, VALVE_STATE_OPEN ); - setValveState( D20_VALV, VALVE_STATE_OPEN ); - setValveState( D21_VALV, VALVE_STATE_OPEN ); - setValveState( D26_VALV, VALVE_STATE_OPEN ); - - //Open balancing chamber valve combinations D19,D24 and D25,D22 - setValveState( D19_VALV, VALVE_STATE_OPEN ); - setValveState( D24_VALV, VALVE_STATE_OPEN ); - setValveState( D25_VALV, VALVE_STATE_OPEN ); - setValveState( D22_VALV, VALVE_STATE_OPEN ); + //Close balancing chamber valve combinations D19,D24 and D25,D22 + setValveState( D19_VALV, VALVE_STATE_CLOSED ); + setValveState( D24_VALV, VALVE_STATE_CLOSED ); + setValveState( D25_VALV, VALVE_STATE_CLOSED ); + setValveState( D22_VALV, VALVE_STATE_CLOSED ); } /*********************************************************************//** * @brief - * The valveControlForBCFreshSideOnlyOpenState function opens the fresh side - * balancing chamber valves and closes the spent side valves. + * The valveControlForBCState2FillStart function actuates the valve combination + * for state 2 fill/drain process. * @details \b Inputs: none * @details \b Outputs: valve states * @return none. *************************************************************************/ -void valveControlForBCFreshSideOnlyOpenState( void ) +static void valveControlForBCState2FillStart( void ) { - // Open fresh balancing chamber valves D19,D20,D21,D22 - setValveState( D19_VALV, VALVE_STATE_OPEN ); + //Close balancing chamber valve combinations D19,D24 and D25,D22 + setValveState( D19_VALV, VALVE_STATE_CLOSED ); + setValveState( D24_VALV, VALVE_STATE_CLOSED ); + setValveState( D25_VALV, VALVE_STATE_CLOSED ); + setValveState( D22_VALV, VALVE_STATE_CLOSED ); + + // Open balancing chamber valve combinations D23,D20 and D21,D26 + setValveState( D23_VALV, VALVE_STATE_OPEN ); setValveState( D20_VALV, VALVE_STATE_OPEN ); setValveState( D21_VALV, VALVE_STATE_OPEN ); - setValveState( D22_VALV, VALVE_STATE_OPEN ); - - // Close spent side valves D23,D24,D25,D26 - setValveState( D23_VALV, VALVE_STATE_CLOSED ); - setValveState( D25_VALV, VALVE_STATE_CLOSED ); - setValveState( D24_VALV, VALVE_STATE_CLOSED ); - setValveState( D26_VALV, VALVE_STATE_CLOSED ); + setValveState( D26_VALV, VALVE_STATE_OPEN ); } /*********************************************************************//** @@ -796,92 +882,6 @@ /*********************************************************************//** * @brief - * The getCurrentBalancingChamberExecState function returns the current state - * of the balancing chamber. - * @details \b Inputs: balChamberExecState - * @details \b Outputs: none - * @return the current state of balancing chamber states. - *************************************************************************/ -BAL_CHAMBER_EXEC_STATE_T getCurrentBalancingChamberExecState( void ) -{ - return balChamberExecState; -} - -/*********************************************************************//** - * @brief - * The getBalancingChamberFillinProgressStatus function returns the current - * balancing chamber fill in progress status. - * @details \b Inputs: isBalChamberFillInProgress - * @details \b Outputs: none - * @return the current balancing chamber fill in progress. - *************************************************************************/ -BOOL getBalancingChamberFillinProgressStatus( void ) -{ - return isBalChamberFillInProgress; -} - -/*********************************************************************//** - * @brief - * The getBalChamberSwitchingFreq function gets the balancing chamber switching - * frequency value. - * @details \b Inputs: balChamberSwitchingFreq - * @details \b Outputs: none - * @return balancing chamber switching frequency - *************************************************************************/ -F32 getBalChamberSwitchingFreq( void ) -{ - F32 result = balChamberSwitchingFreq.data; - - if ( OVERRIDE_KEY == balChamberSwitchingFreq.override ) - { - result = balChamberSwitchingFreq.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief - * The setBalChamberSwitchingOnlyStatus function sets the balancing chamber - * switching only On/Off status. - * @details \b Inputs: balanceChamberSwitchingOnly - * @details \b Outputs: none - * @return none - *************************************************************************/ -void setBalChamberSwitchingOnlyStatus( BOOL OnOff ) -{ - balanceChamberSwitchingOnly = OnOff; -} - -/*********************************************************************//** - * @brief - * The getBalChamberSwitchingOnlyStatus function gets the balancing chamber - * switching only status. - * @details \b Inputs: balanceChamberSwitchingOnly - * @details \b Outputs: none - * @return balancing chamber switching only without any pressure validation - * and dosing delivery - *************************************************************************/ -BOOL getBalChamberSwitchingOnlyStatus( void ) -{ - return balanceChamberSwitchingOnly; -} - -/*********************************************************************//** - * @brief - * The getBalChamberSwitchingPeriod function gets the balancing chamber - * switching period. - * @details \b Inputs: balChamberSwitchingPeriod - * @details \b Outputs: none - * @return balancing chamber switching period - *************************************************************************/ -U32 getBalChamberSwitchingPeriod( void ) -{ - return balChamberSwitchingPeriod; -} - -/*********************************************************************//** - * @brief * The getBalChamberDataPublishInterval function gets the balancing chamber * data publish interval. * @details \b Inputs: balChamberDataPublishInterval