Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -rf0c52f6adff7b61132953890a74f1c462b31eedf -ra111a84009c08c53cc058077ccb8fee95f00436d --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision f0c52f6adff7b61132953890a74f1c462b31eedf) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision a111a84009c08c53cc058077ccb8fee95f00436d) @@ -102,6 +102,8 @@ /// Macro converts a flow rate to an estimated PWM duty cycle %. #define DOP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * DOP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * DOP_GEAR_RATIO * DOP_MOTOR_RPM_TO_PWM_DC_FACTOR + DOP_PWM_ZERO_OFFSET ) +#define PUMP_DIR_ERROR_COUNT_MASK 0x3F ///< Bit mask for pump direction error counter. + /// Enumeration of dialysate outlet pump controller states. typedef enum DialOutPump_States { @@ -170,6 +172,8 @@ //static DIAL_OUT_PUMP_SELF_TEST_STATE_T dialOutPumpSelfTestState = DIAL_OUT_PUMP_SELF_TEST_STATE_START; ///< Current state of the dialysate outlet pump self-test state machine. //static U32 dialOutPumpSelfTestTimerCount = 0; ///< Timer counter for time reference during self-test. +static U08 lastDialOutPumpDirectionCount = 0; ///< Previous pump direction error count reported by FPGA + // ********** private function prototypes ********** static DIAL_OUT_PUMP_STATE_T handleDialOutPumpOffState( void ); @@ -791,7 +795,15 @@ if ( DIAL_OUT_PUMP_CONTROL_TO_TARGET_STATE == dialOutPumpState ) { MOTOR_DIR_T dopMCDir, dopDir; + U08 dirErrorCnt = getFPGADialOutPumpHallSensorStatus() & PUMP_DIR_ERROR_COUNT_MASK; + // Check pump direction error count + if ( lastDialOutPumpDirectionCount != dirErrorCnt ) + { + lastDialOutPumpDirectionCount = dirErrorCnt; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PUMP_DIRECTION_STATUS_ERROR, (U32)HD_PUMP_DIALYSATE_OUTLET_PUMP ) + } + dopMCDir = ( getMeasuredDialOutPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); dopDir = ( getMeasuredDialOutPumpSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE );