Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r6fcdec8a308be986e5a64b4222918e718622a19d -r794f0aea88a5a860448e54e99db6e2e881b22900 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 6fcdec8a308be986e5a64b4222918e718622a19d) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 794f0aea88a5a860448e54e99db6e2e881b22900) @@ -112,6 +112,9 @@ #define FLOW_SIG_STRGTH_ALARM_PERSIST ( 5 * MS_PER_SECOND ) #define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). +/// Dialysate flow read timeout alarm persistence. +#define DIALYSATE_FLOW_READ_TIMEOUT_PERSIST ( MS_PER_SECOND ) + #define DFM_SENSOR_PARAM_CORRUPT_STATUS 0x7 ///< Dialysate flow meter NVM parameter corrupt status. /// Enumeration of dialysate inlet pump states. @@ -133,6 +136,15 @@ NUM_OF_DIAL_IN_FLOW_SELF_TEST_STATES ///< Number of dialysate inlet pump self-test states. } DIAL_IN_FLOW_SELF_TEST_STATE_T; +/// Enumeration of dialysate flow read counters. +typedef enum DialysateFlow_Read_Counters +{ + DIALYSATE_FLOW_READ_CTR_FAST_PACKET = 0, ///< Dialysate flow fast packet read counter + DIALYSATE_FLOW_READ_CTR_SLOW_PACKET, ///< Dialysate flow slow packet read counter + DIALYSATE_FLOW_READ_CTR_STATUS_PACKET, ///< Dialysate flow status packet read counter + NUM_OF_DIALYSATE_FLOW_READ_COUNTERS ///< Number of dialysate flow read counters. +} DIALYSATE_FLOW_READ_COUNTER_T; + // Pin assignments for pump stop and direction outputs #define STOP_DI_PUMP_GIO_PORT_PIN 2U ///< Pin # on GIO A for stopping the dialysate inlet pump. #define DIR_DI_PUMP_SPI5_PORT_MASK 0x00000100 ///< Pin on unused SPI5 peripheral (ENA) - re-purposed as output GPIO to set dialysate inlet pump direction. @@ -189,6 +201,10 @@ static U32 dipCurrErrorDurationCtr = 0; ///< Used for tracking persistence of dip current errors +static U08 lastDialysateFlowFastPacketReadCtr = 0; ///< Previous read counter for the dialysate flow fast packets +static U08 lastDialysateFlowSlowPacketReadCtr = 0; ///< Previous read counter for the dialysate flow slow packets +static U08 lastDialysateFlowStatusPacketReadCtr = 0; ///< Previous read counter for the dialysate flow status packets + // ********** private function prototypes ********** static DIAL_IN_PUMP_STATE_T handleDialInPumpOffState( void ); @@ -242,6 +258,7 @@ // Initialize persistent alarm for flow sensor signal strength too low initPersistentAlarm( ALARM_ID_DIALYSATE_FLOW_SIGNAL_STRENGTH_TOO_LOW, FLOW_SIG_STRGTH_ALARM_PERSIST, FLOW_SIG_STRGTH_ALARM_PERSIST ); + initPersistentAlarm( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, 0, DIALYSATE_FLOW_READ_TIMEOUT_PERSIST ); } /*********************************************************************//** @@ -400,7 +417,30 @@ HD_OP_MODE_T opMode = getCurrentOperationMode(); U16 dipRPM = getIntADCReading( INT_ADC_DIAL_IN_PUMP_SPEED ); U16 dipmA = getIntADCReading( INT_ADC_DIAL_IN_PUMP_MOTOR_CURRENT ); - F32 dipFlow = ( getFPGADialysateFlow() * dialInFlowCalGain ) + dialInFlowCalOffset; + F32 dipFlow = ( getFPGADialysateFlow() * dialInFlowCalGain ) + dialInFlowCalOffset; + U08 fpReadCtr = getFPGADialysateFlowFastPacketReadCounter(); + U08 spReadCtr = getFPGADialysateFlowSlowPacketReadCounter(); + U08 stpReadCtr = getFPGADialysateFlowStatusPacketReadCounter(); + U08 flowErrorCtr = getFPGADialysateFlowErrorCounter(); + + // Check for stale flow reading + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR, ( fpReadCtr == lastDialysateFlowFastPacketReadCtr ) ) ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR, (U32)DIALYSATE_FLOW_READ_CTR_FAST_PACKET ) + } + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR, ( spReadCtr == lastDialysateFlowSlowPacketReadCtr ) ) ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR, (U32)DIALYSATE_FLOW_READ_CTR_SLOW_PACKET ) + } + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR, ( stpReadCtr == lastDialysateFlowStatusPacketReadCtr ) ) ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR, (U32)DIALYSATE_FLOW_READ_CTR_STATUS_PACKET ) + } + + // Record flow read counters for next time around + lastDialysateFlowFastPacketReadCtr = fpReadCtr; + lastDialysateFlowSlowPacketReadCtr = spReadCtr; + lastDialysateFlowStatusPacketReadCtr = stpReadCtr; adcDialInPumpMCSpeedRPM.data = (F32)(SIGN_FROM_12_BIT_VALUE(dipRPM)) * DIP_SPEED_ADC_TO_RPM_FACTOR; adcDialInPumpMCCurrentmA.data = (F32)(SIGN_FROM_12_BIT_VALUE(dipmA)) * DIP_CURRENT_ADC_TO_MA_FACTOR; @@ -430,6 +470,7 @@ // Publish dialIn flow data on interval publishDialInFlowData(); } +//ALARM_ID_HD_DP_FLOW_SENSOR_ERROR = 210, ///< HD dialysate flow sensor error /*********************************************************************//** * @brief @@ -1235,7 +1276,7 @@ // Get the flow sensors calibration record HD_FLOW_SENSORS_CAL_RECORD_T cal = getHDFlowSensorsCalibrationRecord(); - if ( DFM_SENSOR_PARAM_CORRUPT_STATUS != dfmStatus ) + if ( DFM_SENSOR_PARAM_CORRUPT_STATUS != dfmStatus ) { dialInFlowCalGain = cal.hdFlowSensors[ CAL_DATA_HD_DIALYZER_FLOW_SENSOR ].gain; dialInFlowCalOffset = cal.hdFlowSensors[ CAL_DATA_HD_DIALYZER_FLOW_SENSOR ].offset;