Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r3533955f242cec0505e8826e0e2d96f7b79ad499 -r231a5fce9136a603a9316ead3df7951068b5f65f --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 3533955f242cec0505e8826e0e2d96f7b79ad499) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 231a5fce9136a603a9316ead3df7951068b5f65f) @@ -111,9 +111,11 @@ #define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). /// Blood flow read timeout alarm persistence. -#define BLOOD_FLOW_READ_TIMEOUT_PERSIST ( MS_PER_SECOND ) +#define BLOOD_FLOW_FAST_READ_TO_PERSIST 100 +#define BLOOD_FLOW_SLOW_READ_TO_PERSIST ( MS_PER_SECOND * 3 ) -#define BFM_SENSOR_PARAM_CORRUPT_STATUS 0x7 ///< Blood flow meter NVM parameter status. +#define DFM_SENSOR_CONNECTED_STATUS 0x02 ///< Blood flow meter connected status. +#define BFM_SENSOR_PARAM_CORRUPT_STATUS 0x07 ///< Blood flow meter NVM parameter status. /// Enumeration of blood pump controller states. typedef enum BloodPump_States @@ -134,15 +136,6 @@ NUM_OF_BLOOD_FLOW_SELF_TEST_STATES ///< Number of blood pump self-test states } BLOOD_FLOW_SELF_TEST_STATE_T; -/// Enumeration of blood flow read counters. -typedef enum BloodFlow_Read_Counters -{ - BLOOD_FLOW_READ_CTR_FAST_PACKET = 0, ///< Blood flow fast packet read counter - BLOOD_FLOW_READ_CTR_SLOW_PACKET, ///< Blood flow slow packet read counter - BLOOD_FLOW_READ_CTR_STATUS_PACKET, ///< Blood flow status packet read counter - NUM_OF_BLOOD_FLOW_READ_COUNTERS ///< Number of blood pump read counters. -} BLOOD_FLOW_READ_COUNTER_T; - // Pin assignments for pump stop and direction outputs #define STOP_CAN3_PORT_MASK 0x00000002 // (Tx - re-purposed as output GPIO for blood pump stop signal) #define DIR_CAN3_PORT_MASK 0x00000002 // (Rx - re-purposed as output GPIO for blood pump direction signal) @@ -204,7 +197,6 @@ 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 lastBloodFlowStatusPacketReadCtr = 0; ///< Previous read counter for the blood flow status packets // ********** private function prototypes ********** @@ -259,7 +251,8 @@ // Initialize persistent alarm for flow sensor signal strength too low initPersistentAlarm( ALARM_ID_BLOOD_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, BLOOD_FLOW_READ_TIMEOUT_PERSIST ); + initPersistentAlarm( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, 0, BLOOD_FLOW_FAST_READ_TO_PERSIST ); + initPersistentAlarm( ALARM_ID_HD_BP_FLOW_SLOW_READ_TIMEOUT_ERROR, 0, BLOOD_FLOW_SLOW_READ_TO_PERSIST ); } /*********************************************************************//** @@ -454,29 +447,29 @@ #endif U08 fpReadCtr = getFPGABloodFlowFastPacketReadCounter(); U08 spReadCtr = getFPGABloodFlowSlowPacketReadCounter(); - U08 stpReadCtr = getFPGABloodFlowStatusPacketReadCounter(); U08 flowErrorCtr = getFPGABloodFlowErrorCounter(); + U08 flowStatus = getFPGABloodFlowMeterStatus(); + if ( flowStatus != DFM_SENSOR_CONNECTED_STATUS ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BLOOD_FLOW_STATUS_SELF_TEST_FAILURE, (U32)flowStatus ); + } + #ifndef DISABLE_FPGA_COUNTER_CHECKS // Check for stale flow reading if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, ( fpReadCtr == lastBloodFlowFastPacketReadCtr ) ) ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, (U32)BLOOD_FLOW_READ_CTR_FAST_PACKET ) + activateAlarmNoData( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR ); } - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, ( spReadCtr == lastBloodFlowSlowPacketReadCtr ) ) ) + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_FLOW_SLOW_READ_TIMEOUT_ERROR, ( spReadCtr == lastBloodFlowSlowPacketReadCtr ) ) ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, (U32)BLOOD_FLOW_READ_CTR_SLOW_PACKET ) + activateAlarmNoData( ALARM_ID_HD_BP_FLOW_SLOW_READ_TIMEOUT_ERROR ); } - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, ( stpReadCtr == lastBloodFlowStatusPacketReadCtr ) ) ) - { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_BP_FLOW_READ_TIMEOUT_ERROR, (U32)BLOOD_FLOW_READ_CTR_STATUS_PACKET ) - } #endif // Record flow read counters for next time around lastBloodFlowFastPacketReadCtr = fpReadCtr; lastBloodFlowSlowPacketReadCtr = spReadCtr; - lastBloodFlowStatusPacketReadCtr = stpReadCtr; adcBloodPumpMCSpeedRPM.data = (F32)(SIGN_FROM_12_BIT_VALUE(bpRPM)) * BP_SPEED_ADC_TO_RPM_FACTOR; adcBloodPumpMCCurrentmA.data = (F32)(SIGN_FROM_12_BIT_VALUE(bpmA)) * BP_CURRENT_ADC_TO_MA_FACTOR;