Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -rf249310122b6543b4145bb4824966535c93515d0 -re63dcc4fa401c74ce82958f1dd4105fcf6fd1d60 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision f249310122b6543b4145bb4824966535c93515d0) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision e63dcc4fa401c74ce82958f1dd4105fcf6fd1d60) @@ -7,8 +7,8 @@ * * @file BloodLeak.c * -* @author (last) Dara Navaei -* @date (last) 20-May-2023 +* @author (last) Bill Bracken +* @date (last) 13-Jun-2023 * * @author (original) Peman Montazemi * @date (original) 18-Mar-2021 @@ -92,6 +92,9 @@ #define BLOOD_LEAK_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Blood leak embedded mode FPGA error timeout in milliseconds. #define BLOOD_LEAK_RXFIFO_COUNT_MASK 0x03FF ///< Mask high order bits of blood leak sensor rx count +#define MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< Blood Leak comm failures window +#define MAX_BLOOD_LEAK_COMM_FAILURES 3 ///< Blood Leak maximum comm failures per MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS + /// Defined states for the blood leak detector state machine. typedef enum BloodLeakStates { @@ -261,12 +264,13 @@ // Initialize the blood leak embedded mode command sequence memset( bloodLeakEmbModeCmdSeq, 0x0, BLOOD_LEAK_EMB_MODE_CMD_SEQ_LENGTH ); - initFPGAPersistentAlarm( FPGA_PERS_ERROR_BLOOD_LEAK_SENSOR, ALARM_ID_HD_BLOOD_LEAK_FPGA_FAULT, - BLOOD_LEAK_FPGA_ERROR_TIMEOUT_MS, BLOOD_LEAK_FPGA_ERROR_TIMEOUT_MS ); - // Enqueue the commands to set the embedded mode and request the set point of the blood leak sensor enqueueEmbModeCmd( CS_EMB_MODE_CMD ); enqueueEmbModeCmd( D_EMB_MODE_CMD ); + + // initialize FPGA comm failures windowed timer count + initTimeWindowedCount( TIME_WINDOWED_COUNT_BLOOD_LEAK_COMM_ERROR, MAX_BLOOD_LEAK_COMM_FAILURES, MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS); + } /*********************************************************************//** @@ -315,8 +319,6 @@ enqueueInfoEmbModeCmds(); - checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_BLOOD_LEAK_SENSOR, getFPGABloodLeakRxErrorCount() ); - // Publish blood leak data if due publishBloodLeakData(); } @@ -679,7 +681,7 @@ } // Check status reading and act upon - if ( BLOOD_LEAK_DETECTED == getBloodLeakStatus() ) + if ( ( BLOOD_LEAK_DETECTED == getBloodLeakStatus() ) && ( MODE_TREA == getCurrentOperationMode() ) ) { if ( ++bloodLeakPersistenceCtr > BLOOD_LEAK_PERSISTENCE ) { @@ -1055,6 +1057,11 @@ bloodLeakEmbModeRqstedCmd = NU_EMB_MODE_CMD; state = BLOOD_LEAK_EMB_MODE_WAIT_FOR_COMAND_STATE; + + if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_BLOOD_LEAK_COMM_ERROR ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_BLOOD_LEAK_FPGA_FAULT, MAX_BLOOD_LEAK_COMM_FAILURES, (U32)MAX_BLOOD_LEAK_COMM_FAILURES_WINDOW_MS ) + } } return state;