Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r569787ec23f8738c3bc5d1b760a5b22dd0753e45 -r7b60e2a885abe3a0bd06e63647c6a93da6501dda --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 569787ec23f8738c3bc5d1b760a5b22dd0753e45) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 7b60e2a885abe3a0bd06e63647c6a93da6501dda) @@ -239,7 +239,7 @@ static void checkDialInPumpFlowRate( void ); static F32 calcDialInFlow( void ); static F32 dialysateInPumpPWMFromTargetFlowRate( F32 QdTarget ); -static BOOL setDialInPumpWithPWM( F32 pwm ); +static BOOL testSetDialInPumpWithPWM( F32 pwm ); /*********************************************************************//** * @brief @@ -297,7 +297,7 @@ BOOL result = FALSE; // Direction change while pump is running is not allowed - if ( ( FALSE == isDialInPumpOn ) || ( 0 == flowRate ) || ( dir == dialInPumpDirectionSet ) ) + if ( ( ( FALSE == isDialInPumpOn ) && ( dir == dialInPumpDirectionSet ) ) || ( 0 == flowRate ) ) { S32 dirFlowRate = ( dir == MOTOR_DIR_FORWARD ? (S32)flowRate : (S32)flowRate * -1 ); @@ -580,7 +580,8 @@ DIAL_IN_PUMP_STATE_T result = DIAL_IN_PUMP_OFF_STATE; // If we have been given a flow rate, setup ramp up and transition to ramp up state - if ( targetDialInFlowRate != 0 ) + if ( ( targetDialInFlowRate != 0 ) || + ( TRUE == isTestPWMSet ) ) { // Set initial PWM duty cycle dialInPumpPWMDutyCyclePctSet = DIP_PWM_ZERO_OFFSET + MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE; @@ -1498,18 +1499,24 @@ return result; } + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + /*********************************************************************//** * @brief - * The setDialInPumpWithPWM function sets a new pwm value and + * The testSetDialInPumpWithPWM function sets a new pwm value and * pump direction. * @details Inputs: isDialInPumpOn, dialInPumpPWMDutyCyclePct, dialInPumpDirectionSet, * dialInPumpState * @details Outputs: dialInPumpControlMode, dialInPumpdirection, dialInPumpPWMDutyCyclePct * @param pwm, the new pwm value * @return TRUE if new flow rate & dir are set, FALSE if not **************************************************************************/ -static BOOL setDialInPumpWithPWM( F32 pwm ) +static BOOL testSetDialInPumpWithPWM( F32 pwm ) { MOTOR_DIR_T dir = MOTOR_DIR_FORWARD; BOOL result = FALSE; @@ -1521,7 +1528,7 @@ } // Direction change while pump is running is not allowed - if ( ( FALSE == isDialInPumpOn ) || ( 0 == dialInPumpPWMDutyCyclePct ) || ( dir == dialInPumpDirectionSet ) ) + if ( ( FALSE == isDialInPumpOn ) && ( dir == dialInPumpDirectionSet ) || ( 0 == pwmFabs ) ) { // Don't interrupt pump control unless rate is changing if ( ( pwmFabs != dialInPumpPWMDutyCyclePct ) ) @@ -1567,13 +1574,8 @@ } } return result; -} +} -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - /*********************************************************************//** * @brief * The testSetDialInFlowDataPublishIntervalOverride function overrides the @@ -1904,9 +1906,10 @@ if ( TRUE == isTestingActivated() ) { - // check for min/max of pump pwm - if ( absolutePWM < MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE && - absolutePWM > MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE ) + // check for max of pump pwm. + // minimum will get bounded within setDialInPumpWithPWM but we want + // 0 to be acceptable as off. + if ( absolutePWM < MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE ) { // if exactly zero, clear test flag if ( pwmPct == 0 ) @@ -1916,9 +1919,8 @@ else { isTestPWMSet = TRUE; - } - result = setDialInPumpWithPWM( pwmPct ); + result = testSetDialInPumpWithPWM( pwmPct ); } }