Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r208ceefa8e8b1cc30feb93be771ced6d313e6995 -r94dab74a6432263dc4569e0cf8f9fa0b01bf1917 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 208ceefa8e8b1cc30feb93be771ced6d313e6995) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 94dab74a6432263dc4569e0cf8f9fa0b01bf1917) @@ -7,8 +7,8 @@ * * @file FPGA.c * -* @author (last) Darren Cox -* @date (last) 10-Mar-2022 +* @author (last) Michael Garthwaite +* @date (last) 08-Aug-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -91,7 +91,9 @@ #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_ST_BIT_INDEX 12 ///< Bit index for the blood leak self test status bit. #define FPGA_BLOOD_LEAK_ZERO_STATE_MASK 0x2000 ///< Bit mask for blood leak detector zero. +#define FPAG_BLOOD_LEAK_ZERO_BIT_INDEX 13 ///< Bit index for the blood leak zero status bit. #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. @@ -239,9 +241,14 @@ U08 arterialPressureReadCount; ///< Reg 444. Arterial pressure sensor read count. U08 arterialPressureErrorCount; ///< Reg 445. Arterial pressure sensor error count. U08 bloodLeakTxFIFOCount; ///< Reg 446. Blood leak transmit FIFO count. - U08 bloodLeakRxFIFOCount; ///< Reg 447. Blood leak receive FIFO count. - U08 bloodLeakRxErrorCount; ///< Reg 448. Blood leak receive error count. - U08 bloodLeakRxFIFODataOut; ///< Reg 449. Blood leak receive FIFO data out. + U08 bloodLeakRxErrorCount; ///< Reg 447. Blood leak receive error count. + U16 bloodLeakRxFIFOCount; ///< Reg 448. Blood leak receive FIFO count. + U08 bloodLeakRxFIFODataOut; ///< Reg 450. Blood leak receive FIFO data out. + U08 dummyByte; ///< Reg 451. Dummy byte to meet the even of the data. + U16 fpgaCompatibilityRev; ///< Reg 452. Compatibility revisions + U08 bloodLeakSelfTestErrorCounter; ///< Reg 452. Blood leak self test error counter. + U08 bloodLeakZeroErrorCounter; ///< Reg 453. Blood leak zero error counter. + } FPGA_SENSORS_T; /// Record structure for FPGA continuous priority writes. @@ -926,25 +933,18 @@ { SELF_TEST_STATUS_T result; - // Check FPGA reported correct ID + // check FPGA reported correct ID if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) { // Check FPGA compatibility w/ firmware - if ( fpgaHeader.fpgaRevMajor > MIN_HD_FPGA_MAJOR ) + if ( HD_FPGA_COMPATIBILITY_REV == fpgaSensorReadings.fpgaCompatibilityRev ) { result = SELF_TEST_STATUS_PASSED; } else { - if ( ( MIN_HD_FPGA_MAJOR == fpgaHeader.fpgaRevMajor ) && ( fpgaHeader.fpgaRev >= MIN_HD_FPGA_MINOR ) ) - { - result = SELF_TEST_STATUS_PASSED; - } - else - { - result = SELF_TEST_STATUS_FAILED; - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaRevMajor, (U32)fpgaHeader.fpgaRev ) - } + result = SELF_TEST_STATUS_FAILED; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_POST_TEST_FAILED, (U32)HD_FPGA_COMPATIBILITY_REV, (U32)fpgaSensorReadings.fpgaCompatibilityRev ) } } else @@ -1984,21 +1984,6 @@ /*********************************************************************//** * @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: none @@ -2051,6 +2036,34 @@ /*********************************************************************//** * @brief + * The getFPGABloodLeakZeroStatus function returns the blood leak sensor's + * zero status bit. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return blood leak sensor zero status bit + *************************************************************************/ +U08 getFPGABloodLeakZeroStatus( void ) +{ + U08 zeroStatus = (U08)( ( fpgaSensorReadings.fpgaGPIO & FPGA_BLOOD_LEAK_ZERO_STATE_MASK ) >> FPAG_BLOOD_LEAK_ZERO_BIT_INDEX ); + return zeroStatus; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodLeakStatus function returns the blood leak sensor's + * blood detection status bit. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return blood leak sensor self test status bit + *************************************************************************/ +U08 getFPGABloodLeakStatus( void ) +{ + U08 selfTestStatus = (U08)( ( fpgaSensorReadings.fpgaGPIO & FPGA_BLOOD_LEAK_STATUS_MASK ) >> FPGA_BLOOD_LEAK_ST_BIT_INDEX ); + return selfTestStatus; +} + +/*********************************************************************//** + * @brief * The setFPGABloodLeakUARTControl function sets the blood leak sensor UART * control value. * @details Inputs: fpgaSensorReadings @@ -2195,7 +2208,7 @@ * @details Outputs: none * @return fpgaSensorReadings.bloodLeakRxFIFOCount *************************************************************************/ -U08 getFPGABloodLeakRxFIFOCount( void ) +U16 getFPGABloodLeakRxFIFOCount( void ) { return fpgaSensorReadings.bloodLeakRxFIFOCount; } @@ -2228,6 +2241,32 @@ /*********************************************************************//** * @brief + * The getFPGABloodLeakSelfTestErrorCounter function returns the blood leak + * self test error counter. + * @details Inputs: none + * @details Outputs: none + * @return fpgaSensorReadings.bloodLeakSelfTestErrorCounter + *************************************************************************/ +U08 getFPGABloodLeakSelfTestErrorCounter( void ) +{ + return fpgaSensorReadings.bloodLeakSelfTestErrorCounter; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodLeakZeroErrorCounter function returns the blood leak + * zero error counter. + * @details Inputs: none + * @details Outputs: none + * @return fpgaSensorReadings.bloodLeakZeroErrorCounter + *************************************************************************/ +U08 getFPGABloodLeakZeroErrorCounter( void ) +{ + return fpgaSensorReadings.bloodLeakZeroErrorCounter; +} + +/*********************************************************************//** + * @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