Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rb7764e26a3460652da29b1f957706dfaca413226 -r6c0750e3fad58595adcda4bcc26da0032daeff57 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision b7764e26a3460652da29b1f957706dfaca413226) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 6c0750e3fad58595adcda4bcc26da0032daeff57) @@ -82,14 +82,16 @@ #define FPGA_AIRTRAP_LEVEL_HIGH_MASK 0x0004 ///< Bit mask for air trap upper level sensor. #define FPGA_FLUID_LEAK_STATE_MASK 0x0040 ///< Bit mask for fluid leak detector. + #define FPGA_BLOOD_LEAK_STATUS_MASK 0x1000 ///< Bit mask for blood leak detector. #define FPGA_BLOOD_LEAK_ZERO_STATE_MASK 0x2000 ///< Bit mask for blood leak detector zero. - #define FPGA_BLOOD_LEAK_ZERO_CMD 0x02 ///< Bit for blood leak detector zero command. #define FPGA_BLOOD_LEAK_SELF_TEST_CMD 0x01 ///< Bit for blood leak detector self test command. -#define FPGA_ADA_INPUT_STATUS_MASK 0x0001 ///< Bit mask for arterial air bubble detector input status. -#define FPGA_ADV_INPUT_STATUS_MASK 0x0002 ///< Bit mask for venous air bubble detector input status. +#define FPGA_ADA_BUBBLE_STATUS_MASK 0x0001 ///< Bit mask for arterial air bubble detector input status. +#define FPGA_ADV_BUBBLE_STATUS_MASK 0x0002 ///< Bit mask for venous air bubble detector input status. +#define FPGA_ADA_BUBBLE_SELF_TEST_CMD 0x04 ///< Bit for arterial air bubble detector self-test command. +#define FPGA_ADV_BUBBLE_SELF_TEST_CMD 0x08 ///< Bit for venous air bubble detector self-test command. // FPGA Sensors Record #pragma pack(push,1) @@ -526,7 +528,7 @@ // If retries for commands exceeds limit, fault if ( fpgaCommRetryCount > MAX_COMM_ERROR_RETRIES ) { - activateAlarmNoData( ALARM_ID_FPGA_COMM_TIMEOUT ); + activateAlarmNoData( ALARM_ID_HD_FPGA_COMM_TIMEOUT ); } // Reset comm flags after processing incoming responses @@ -870,7 +872,7 @@ else { result = SELF_TEST_STATUS_FAILED; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaId ) + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaId ) } return result; @@ -1589,36 +1591,6 @@ /*********************************************************************//** * @brief - * The getFPGAArterialAirBubbleStatus function gets the latest arterial air - * bubble detector status. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return TRUE if air bubble is detected, otherwise FALSE - *************************************************************************/ -BOOL getFPGAArterialAirBubbleStatus( void ) -{ - U16 const status = fpgaSensorReadings.fpgaGPIO & FPGA_ADA_INPUT_STATUS_MASK; - - return ( 0 == status ? TRUE : FALSE ); -} - -/*********************************************************************//** - * @brief - * The getFPGAVenousAirBubbleStatus function gets the latest venous air - * bubble detector status. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return TRUE if air bubble is detected, otherwise FALSE - *************************************************************************/ -BOOL getFPGAVenousAirBubbleStatus( void ) -{ - U16 const status = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_INPUT_STATUS_MASK; - - return ( 0 == status ? FALSE : TRUE ); -} - -/*********************************************************************//** - * @brief * The getDoorState function gets the current state of door switch. * @details Inputs: none * @details Outputs: none @@ -1706,9 +1678,9 @@ * @brief * The setFPGABloodLeakZero function sets the Blood Leak detector into * zeroing mode via the FPGA. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return FPGABloodLeakZeroDetected + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints + * @return none *************************************************************************/ void setFPGABloodLeakZero( void ) { @@ -1732,9 +1704,9 @@ * @brief * The setFPGABloodLeakSelfTest function sets the Blood Leak detector into * self-test mode via the FPGA. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return FPGABloodLeakZeroDetected + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints + * @return: none *************************************************************************/ void setFPGABloodLeakSelfTest( void ) { @@ -1756,6 +1728,78 @@ /*********************************************************************//** * @brief + * The noFPGABubbleDetected function returns TRUE if no air bubble has been + * detected and FALSE if an air bubble has been detected. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return noFPGABubbleDetected + *************************************************************************/ +BOOL noFPGABubbleDetected( U32 bubble ) +{ + U16 noFPGABubbleDetected = 0; + + if ( bubble == ADA ) + { + noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADA_BUBBLE_STATUS_MASK; + } + else if ( bubble == ADV ) + { + noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_BUBBLE_STATUS_MASK; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_BUBBLE_ID, bubble ) + } + + return ( 0 != noFPGABubbleDetected ? TRUE : FALSE ); +} + +/*********************************************************************//** + * @brief + * The setFPGABubbleSelfTest function sets the given air bubble detector into + * self-test mode via the FPGA. + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints + * @return: none + *************************************************************************/ +void setFPGABubbleSelfTest( U32 bubble ) +{ + if ( bubble == ADA ) + { + fpgaActuatorSetPoints.fpgaSensorTest |= FPGA_ADA_BUBBLE_SELF_TEST_CMD; + } + else if ( bubble == ADV ) + { + fpgaActuatorSetPoints.fpgaSensorTest |= FPGA_ADV_BUBBLE_SELF_TEST_CMD; + } +} + +/*********************************************************************//** + * @brief + * The clearFPGABubbleSelfTest function clears the given air bubble detector + * from self-test mode via the FPGA. + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints + * @return: none + *************************************************************************/ +void clearFPGABubbleSelfTest( U32 bubble ) +{ + if ( bubble == ADA ) + { + fpgaActuatorSetPoints.fpgaSensorTest &= ~FPGA_ADA_BUBBLE_SELF_TEST_CMD; + } + else if ( bubble == ADV ) + { + fpgaActuatorSetPoints.fpgaSensorTest &= ~FPGA_ADV_BUBBLE_SELF_TEST_CMD; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_BUBBLE_ID, bubble ) + } +} + +/*********************************************************************//** + * @brief * The setValveDialyzerInletPosition function sets the position of VDi * in counts * @details Inputs: fpgaActuatorSetPoints