Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rd5060b07988d9f64c3d5cad0fda25f209d23022b -r1af686275f4fd6a11bb3507f9f128eef9636edae --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision d5060b07988d9f64c3d5cad0fda25f209d23022b) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 1af686275f4fd6a11bb3507f9f128eef9636edae) @@ -82,10 +82,15 @@ #define FPGA_AIRTRAP_LEVEL_LOW_MASK 0x0008 ///< Bit mask for air trap lower level sensor. #define FPGA_AIRTRAP_LEVEL_HIGH_MASK 0x0004 ///< Bit mask for air trap upper level sensor. -#define FPGA_FLUIDLEAK_STATE_MASK 0x0040 ///< Bit mask for fluid leak detector. +#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_BLOOD_LEAK_STATUS_MASK 0x1000 ///< Bit mask for blood leak detector status. #define FPGA_PBO_TEMP_DIVISOR 2047.0 ///< Used in conversion of PBo temperature reading to deg C. #define FPGA_PBO_TEMP_GAIN 200.0 ///< Used in conversion of PBo temperature reading to deg C. @@ -1845,34 +1850,6 @@ /*********************************************************************//** * @brief - * The setFPGASensorTest function sets the sensor test output. - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: fpgaActuatorSetPoints - * @param sensorTest - * @return none - *************************************************************************/ -void setFPGASensorTest( U08 sensorTest ) -{ - fpgaActuatorSetPoints.fpgaSensorTest = sensorTest; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakDetectorStatus function gets the latest blood leak - * detector status. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return TRUE if blood leak is detected, otherwise FALSE - *************************************************************************/ -BOOL getFPGABloodLeakDetectorStatus( void ) -{ - U16 const status = fpgaSensorReadings.fpgaGPIO & FPGA_BLOOD_LEAK_STATUS_MASK; - - return ( 0 == status ? FALSE : TRUE ); -} - -/*********************************************************************//** - * @brief * The getDoorState function gets the current state of door switch. * @details Inputs: none * @details Outputs: none @@ -1913,21 +1890,103 @@ /*********************************************************************//** * @brief - * The noFluidLeakDetected function returns TRUE if no fluid leak has been + * The noFPGAFluidLeakDetected function returns TRUE if no fluid leak has been * detected (dry) and FALSE if a fluid leak has been detected (wet). * @details Inputs: fpgaSensorReadings * @details Outputs: none - * @return noFluidLeakDetected + * @return noFPGAFluidLeakDetected *************************************************************************/ BOOL noFPGAFluidLeakDetected( void ) { - U16 noFluidLeakDetected = fpgaSensorReadings.fpgaGPIO & FPGA_FLUIDLEAK_STATE_MASK; + U16 noFPGAFluidLeakDetected = fpgaSensorReadings.fpgaGPIO & FPGA_FLUID_LEAK_STATE_MASK; - return ( 0 == noFluidLeakDetected ? FALSE : TRUE ); + return ( 0 == noFPGAFluidLeakDetected ? FALSE : TRUE ); } /*********************************************************************//** * @brief + * The noFPGABloodLeakDetected function returns TRUE if no blood leak has been + * detected and FALSE if a blood leak has been detected. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return noFPGABloodLeakDetected + *************************************************************************/ +BOOL noFPGABloodLeakDetected( void ) +{ + U16 noFPGABloodLeakDetected = fpgaSensorReadings.fpgaGPIO & FPGA_BLOOD_LEAK_STATUS_MASK; + + return ( 0 == noFPGABloodLeakDetected ? TRUE : FALSE ); +} + +/*********************************************************************//** + * @brief + * The FPGABloodLeakZeroDetected function returns TRUE if blood leak zeroing has + * been detected and FALSE if no blood leak zeroing has been detected. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return FPGABloodLeakZeroDetected + *************************************************************************/ +BOOL FPGABloodLeakZeroDetected( void ) +{ + U16 FPGABloodLeakZeroDetected = fpgaSensorReadings.fpgaGPIO & FPGA_BLOOD_LEAK_ZERO_STATE_MASK; + + return ( 0 == FPGABloodLeakZeroDetected ? FALSE : TRUE ); +} + +/*********************************************************************//** + * @brief + * The setFPGABloodLeakZero function sets the Blood Leak detector into + * zeroing mode via the FPGA. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return FPGABloodLeakZeroDetected + *************************************************************************/ +void setFPGABloodLeakZero( void ) +{ + fpgaActuatorSetPoints.fpgaSensorTest |= FPGA_BLOOD_LEAK_ZERO_CMD; +} + +/*********************************************************************//** + * @brief + * The clearFPGABloodLeakZero function clears the Blood Leak detector from + * zeroing mode via the FPGA. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return none + *************************************************************************/ +void clearFPGABloodLeakZero( void ) +{ + fpgaActuatorSetPoints.fpgaSensorTest &= ~FPGA_BLOOD_LEAK_ZERO_CMD; +} + +/*********************************************************************//** + * @brief + * The setFPGABloodLeakSelfTest function sets the Blood Leak detector into + * self-test mode via the FPGA. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return FPGABloodLeakZeroDetected + *************************************************************************/ +void setFPGABloodLeakSelfTest( void ) +{ + fpgaActuatorSetPoints.fpgaSensorTest |= FPGA_BLOOD_LEAK_SELF_TEST_CMD; +} + +/*********************************************************************//** + * @brief + * The clearFPGABloodLeakSelfTest function clears the Blood Leak detector from + * self-test mode via the FPGA. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return none + *************************************************************************/ +void clearFPGABloodLeakSelfTest( void ) +{ + fpgaActuatorSetPoints.fpgaSensorTest &= ~FPGA_BLOOD_LEAK_SELF_TEST_CMD; +} + +/*********************************************************************//** + * @brief * The setValveDialyzerInletPosition function sets the position of VDi * in counts * @details Inputs: fpgaActuatorSetPoints