Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r3533955f242cec0505e8826e0e2d96f7b79ad499 -r231a5fce9136a603a9316ead3df7951068b5f65f --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 3533955f242cec0505e8826e0e2d96f7b79ad499) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 231a5fce9136a603a9316ead3df7951068b5f65f) @@ -113,9 +113,11 @@ #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 DIALYSATE_FLOW_FAST_READ_TO_PERSIST 100 +#define DIALYSATE_FLOW_SLOW_READ_TO_PERSIST ( MS_PER_SECOND * 3 ) -#define DFM_SENSOR_PARAM_CORRUPT_STATUS 0x7 ///< Dialysate flow meter NVM parameter corrupt status. +#define DFM_SENSOR_CONNECTED_STATUS 0x02 ///< Dialysate flow meter connected status. +#define DFM_SENSOR_PARAM_CORRUPT_STATUS 0x07 ///< Dialysate flow meter NVM parameter corrupt status. /// Enumeration of dialysate inlet pump states. typedef enum DialInPump_States @@ -136,15 +138,6 @@ 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. @@ -203,7 +196,6 @@ 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 ********** @@ -258,7 +250,8 @@ // 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_DP_FLOW_READ_TIMEOUT_ERROR, 0, DIALYSATE_FLOW_READ_TIMEOUT_PERSIST ); + initPersistentAlarm( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR, 0, DIALYSATE_FLOW_FAST_READ_TO_PERSIST ); + initPersistentAlarm( ALARM_ID_HD_DP_FLOW_SLOW_READ_TIMEOUT_ERROR, 0, DIALYSATE_FLOW_SLOW_READ_TO_PERSIST ); } /*********************************************************************//** @@ -420,29 +413,29 @@ F32 dipFlow = ( getFPGADialysateFlow() * dialInFlowCalGain ) + dialInFlowCalOffset; U08 fpReadCtr = getFPGADialysateFlowFastPacketReadCounter(); U08 spReadCtr = getFPGADialysateFlowSlowPacketReadCounter(); - U08 stpReadCtr = getFPGADialysateFlowStatusPacketReadCounter(); U08 flowErrorCtr = getFPGADialysateFlowErrorCounter(); + U08 flowStatus = getFPGADialysateFlowMeterStatus(); + if ( flowStatus != DFM_SENSOR_CONNECTED_STATUS ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DIALYSATE_FLOW_STATUS_SELF_TEST_FAILURE, (U32)flowStatus ); + } + #ifndef DISABLE_FPGA_COUNTER_CHECKS // 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 ) + activateAlarmNoData( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR ); } - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR, ( spReadCtr == lastDialysateFlowSlowPacketReadCtr ) ) ) + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_DP_FLOW_SLOW_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 ) + activateAlarmNoData( ALARM_ID_HD_DP_FLOW_SLOW_READ_TIMEOUT_ERROR ); } - 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 ) - } #endif // 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;