Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r231a5fce9136a603a9316ead3df7951068b5f65f -r0798ef0a54e4ddaa551ced7b2bd9b032aa458095 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 231a5fce9136a603a9316ead3df7951068b5f65f) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 0798ef0a54e4ddaa551ced7b2bd9b032aa458095) @@ -110,12 +110,15 @@ #define FLOW_SIG_STRGTH_ALARM_PERSIST ( 5 * MS_PER_SECOND ) #define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). -/// Blood flow read timeout alarm persistence. +/// Blood flow fast read timeout alarm persistence. #define BLOOD_FLOW_FAST_READ_TO_PERSIST 100 +/// Blood flow slow read timeout alarm persistence. #define BLOOD_FLOW_SLOW_READ_TO_PERSIST ( MS_PER_SECOND * 3 ) #define DFM_SENSOR_CONNECTED_STATUS 0x02 ///< Blood flow meter connected status. -#define BFM_SENSOR_PARAM_CORRUPT_STATUS 0x07 ///< Blood flow meter NVM parameter status. +#define BFM_SENSOR_PARAM_CORRUPT_STATUS 0x07 ///< Blood flow meter NVM parameter status. + +#define PUMP_DIR_ERROR_COUNT_MASK 0x3F ///< Bit mask for pump direction error counter. /// Enumeration of blood pump controller states. typedef enum BloodPump_States @@ -197,6 +200,7 @@ static U08 lastBloodFlowFastPacketReadCtr = 0; ///< Previous read counter for the blood flow fast packets static U08 lastBloodFlowSlowPacketReadCtr = 0; ///< Previous read counter for the blood flow slow packets +static U08 lastBloodPumpDirectionCount = 0; ///< Previous pump direction error count reported by FPGA // ********** private function prototypes ********** @@ -1057,7 +1061,15 @@ if ( BLOOD_PUMP_CONTROL_TO_TARGET_STATE == bloodPumpState ) { MOTOR_DIR_T bpMCDir, bpDir; + U08 dirErrorCnt = getFPGABloodPumpHallSensorStatus() & PUMP_DIR_ERROR_COUNT_MASK; + // Check pump direction error count + if ( lastBloodPumpDirectionCount != dirErrorCnt ) + { + lastBloodPumpDirectionCount = dirErrorCnt; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_PUMP_DIRECTION_STATUS_ERROR, (U32)HD_PUMP_BLOOD_PUMP ) + } + bpMCDir = ( getMeasuredBloodPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); bpDir = ( getMeasuredBloodPumpSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE );