Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -rc72332b4674a895aed7d56ca37ee5230548da3f6 -r88f3fa0b9f8a2b1c54e0489b2c4269fd5bb60d17 --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision c72332b4674a895aed7d56ca37ee5230548da3f6) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 88f3fa0b9f8a2b1c54e0489b2c4269fd5bb60d17) @@ -34,7 +34,6 @@ // ********** private definitions ********** #define BLOOD_LEAK_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the blood leak data is published on the CAN bus. -#define BLOOD_LEAK_TIMEOUT_MS 2000 ///< Blood leak detector timeout for zeroing and self-test (15 ms extended edge detection) #define BLOOD_LEAK_PERSISTENCE ( 10 * MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Persistence for blood leak detected alarm. #define BLOOD_LEAK_RESET_TX_FIFO 2 ///< Blood leak reset transmit FIFO command. #define BLOOD_LEAK_START_COMM_CTRL_U_ASCII 21 ///< Blood leak start communication command, ^U (Ctrl-U) in ascii. @@ -58,6 +57,10 @@ #define BLOOD_LEAK_MAX_CTRL_U_WRITE_TRIALS 3 ///< Blood leak maximum number of trials to write the control U command. #define BLOOD_LEAK_ZERO_CMD_STATUS_READY 0x80 ///< Blood leak zero command status ready value. #define BLOOD_LEAK_SELF_TEST_CMD_STATUS_READY 0x80 ///< Blood leak self test command status ready value. +#define BLOOD_LEAK_STATUS_BIT_HIGH 1 ///< Blood leak status bit high. +#define BLOOD_LEAK_STATUS_BIT_LOW 0 ///< Blood leak status bit low. +#define BLOOD_LEAK_ZERO_CMD_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Blood leak zero command timeout in milliseconds. +#define BLOOD_LEAK_SELF_TEST_CMD_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Blood leak self test command timeout in milliseconds. #define BLOOD_LEAK_MIN_WAIT_TIME_2_GET_CAL_MS ( 2 * MS_PER_SECOND ) ///< Blood leak minimum wait time to get calibration in milliseconds. #define DATA_PUBLISH_COUNTER_START_COUNT 60 ///< Data publish counter start count. @@ -95,7 +98,9 @@ BLOOD_LEAK_CHECK_SET_POINT_STATE, ///< Check set point state. BLOOD_LEAK_SET_SET_POINT_STATE, ///< Set set point state. BLOOD_LEAK_INIT_STATE, ///< Init state. + BLOOD_LEAK_PREP_FOR_ZERO_CMD_STATE, ///< Prepare for zero command state. BLOOD_LEAK_ZERO_STATE, ///< Zero state. + BLOOD_LEAK_PREP_FOR_SELF_TEST_CMD_STATE, ///< Prepare for self test command state. BLOOD_LEAK_SELF_TEST_STATE, ///< Self-test state. BLOOD_LEAK_NORMAL_STATE, ///< Normal state. BLOOD_LEAK_CALIBRATION_STATE, ///< Calibration state. @@ -137,15 +142,19 @@ U32 timeoutMS; ///< Blood leak sensor receive timeout in milliseconds. } EMB_MODE_CMD_T; +/// Zero command structure +typedef struct +{ + BOOL zeroCmdRequested; ///< Blood leak zero command requested. + U08 cmdPrevStatus; ///< Blood leak previous zero/self test status. + U32 cmdStartTimeMS; ///< Blood leak zero/self test command start time in milliseconds. +} BLOOD_LEAK_CMD_T; + // ********** private data ********** static BLOOD_LEAK_STATE_T bloodLeakState; ///< Current state of blood leak state machine. static OVERRIDE_U32_T bloodLeakStatus; ///< Detected blood leak status for blood leak detector. static SELF_TEST_STATUS_T bloodLeakSelfTestStatus; ///< Current status of blood leak self-test. - -static BOOL bloodLeakZeroRequested; ///< Blood leak zero requested flag -static U32 bloodLeakZeroStartTime; ///< Blood leak zeroing start time. -static U32 bloodLeakSelfTestStartTime; ///< Blood leak self-test start time. static BOOL bloodLeakIsPOSTComplete; ///< Blood leak is POST complete flag. static U32 bloodLeakPersistenceCtr; ///< Blood leak alarm persistence timer counter. @@ -161,6 +170,7 @@ static U32 bloodLeakGetCalStartTime; ///< Blood leak get calibration start time. static U32 bloodLeakPrevFPGARegisterCount; ///< Blood leak previous FPGA communications counter. static BOOL bloodLeakExitNormalRequested; ///< Blood leak exit normal state requested. +static BLOOD_LEAK_CMD_T bloodLeakCmd; ///< Blood leak zero/self test command. /// Blood leak start up sequence array. static const U08 BLOOD_LEAK_START_UP_SEQUENCE[ BLOOD_LEAK_STARTUP_SEQ_LENGTH ] = { BLOOD_LEAK_RESET_TX_FIFO, @@ -190,7 +200,9 @@ static BLOOD_LEAK_STATE_T handleBloodLeakCheckSetPointState( void ); static BLOOD_LEAK_STATE_T handleBloodLeakSetSetPointState( void ); static BLOOD_LEAK_STATE_T handleBloodLeakInitState( void ); +static BLOOD_LEAK_STATE_T handleBloodLeakPrepForZeroCmdState( void ); static BLOOD_LEAK_STATE_T handleBloodLeakZeroState( void ); +static BLOOD_LEAK_STATE_T handleBloodLeakPrepForSelfTestCmdState( void ); static BLOOD_LEAK_STATE_T handleBloodLeakSelfTestState( void ); static BLOOD_LEAK_STATE_T handleBloodLeakNormalState( void ); static BLOOD_LEAK_STATE_T handleBloodLeakCalibrationState( void ); @@ -203,13 +215,13 @@ static void prepareSetPointSeq( U16 setPoint ); static void publishBloodLeakData( void ); static void initEmbModeSpecs( void ); +static BOOL hasZeroBloodLeakBeenRequested( void ); /*********************************************************************//** * @brief * The initBloodLeak function initializes the Blood Leak module. * @details Inputs: none * @details Outputs: bloodLeakState, bloodLeakStatus, bloodLeakSelfTestStatus, - * bloodLeakZeroRequested, bloodLeakZeroRequested, bloodLeakSelfTestStartTime, * bloodLeakUARTCmdIndex, bloodLeakSetPointSequence, bloodLeakPrevFPGARegisterCount * bloodLeakWait2ReadResponseCounter, bloodLeakDataPublicationTimerCounter, * bloodLeakCommandWriteTryCount, bloodLeakGetCalStartTime, bloodLeakEmbModeSubstate @@ -228,9 +240,6 @@ bloodLeakStatus.ovData = BLOOD_LEAK_NOT_DETECTED; bloodLeakStatus.override = OVERRIDE_RESET; bloodLeakSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; - bloodLeakZeroRequested = FALSE; - bloodLeakZeroStartTime = 0; - bloodLeakSelfTestStartTime = 0; bloodLeakUARTCmdIndex = 0; bloodLeakSetPointSeqLength = 0; bloodLeakWait2ReadResponseCounter = 0; @@ -327,10 +336,18 @@ bloodLeakState = handleBloodLeakInitState(); break; + case BLOOD_LEAK_PREP_FOR_ZERO_CMD_STATE: + bloodLeakState = handleBloodLeakPrepForZeroCmdState(); + break; + case BLOOD_LEAK_ZERO_STATE: bloodLeakState = handleBloodLeakZeroState(); break; + case BLOOD_LEAK_PREP_FOR_SELF_TEST_CMD_STATE: + bloodLeakState = handleBloodLeakPrepForSelfTestCmdState(); + break; + case BLOOD_LEAK_SELF_TEST_STATE: bloodLeakState = handleBloodLeakSelfTestState(); break; @@ -359,13 +376,13 @@ * The zeroBloodLeak function requests that the Blood Leak Detector be * zeroed. * @details Inputs: none - * @details Outputs: Blood Leak module zeroing. + * @details Outputs: bloodLeakCmd.zeroCmdRequested, bloodLeakUARTCmdIndex * @return none *************************************************************************/ void zeroBloodLeak( void ) { - bloodLeakZeroRequested = TRUE; - bloodLeakUARTCmdIndex = 0; + bloodLeakCmd.zeroCmdRequested = TRUE; + bloodLeakUARTCmdIndex = 0; } /*********************************************************************//** @@ -431,8 +448,8 @@ bloodLeakPrevFPGARegisterCount = getFPGABloodLeakRegisterCounter(); // TODO this has been disabled for the systems team testing. In their test, ^U is not sent //state = BLOOD_LEAK_START_UP_STATE; - state = BLOOD_LEAK_INIT_STATE; - // TODO remove once testing is done + // TODO decide whether we need to go to ^U upon startup + state = BLOOD_LEAK_INIT_STATE; } return state; @@ -448,6 +465,7 @@ *************************************************************************/ static BLOOD_LEAK_STATE_T handleBloodLeakStartupState( void ) { + // TODO NOTE: This function is bypassed until the use of ^U is finalized by the system's team BLOOD_LEAK_STATE_T state = BLOOD_LEAK_START_UP_STATE; U32 command = BLOOD_LEAK_START_UP_SEQUENCE[ bloodLeakUARTCmdIndex ]; @@ -491,6 +509,7 @@ *************************************************************************/ static BLOOD_LEAK_STATE_T handleBloodLeakCheckCommState( void ) { + // TODO NOTE: This function is bypassed until the use of ^U is finalized by the system's team BLOOD_LEAK_STATE_T state = BLOOD_LEAK_CHECK_COMM_STATE; // Check if the blood leak sensor has started communicating @@ -533,7 +552,7 @@ { BLOOD_LEAK_STATE_T state = BLOOD_LEAK_CHECK_SET_POINT_STATE; - U16 bloodLeakSetPoint = getFPGABloodLeakDetectSetPoint(); + U16 bloodLeakSetPoint = getFPGABloodLeakDetectSetPoint(); // TODO is this working in embedded mode? #ifdef BOARD_WITH_NO_HARDWARE // In case it is just a bare board, use this value @@ -576,6 +595,7 @@ *************************************************************************/ static BLOOD_LEAK_STATE_T handleBloodLeakSetSetPointState( void ) { + // TODO remove this function BLOOD_LEAK_STATE_T state = BLOOD_LEAK_SET_SET_POINT_STATE; // Check if the current buffer index is less than the buffer length @@ -624,16 +644,46 @@ { BLOOD_LEAK_STATE_T state = BLOOD_LEAK_INIT_STATE; - if ( ( TRUE == bloodLeakZeroRequested ) && - ( BLOOD_LEAK_ZERO_CMD_STATUS_READY == ( getFPGABloodLeakZeroStatusCounter() & BLOOD_LEAK_ZERO_CMD_STATUS_READY ) ) ) - { - state = BLOOD_LEAK_ZERO_STATE; - bloodLeakZeroRequested = FALSE; - bloodLeakZeroStartTime = getMSTimerCount(); + // Check if the zero command has been requested + state = ( TRUE == hasZeroBloodLeakBeenRequested() ? BLOOD_LEAK_PREP_FOR_ZERO_CMD_STATE : state ); + return state; +} +/*********************************************************************//** + * @brief + * The handleBloodLeakPrepForZeroCmdState function handles the blood leak + * prepare for zero command state. + * @details Inputs: bloodLeakCmd + * @details Outputs: bloodLeakCmd + * @return next state + *************************************************************************/ +static BLOOD_LEAK_STATE_T handleBloodLeakPrepForZeroCmdState( void ) +{ + BLOOD_LEAK_STATE_T state = BLOOD_LEAK_PREP_FOR_ZERO_CMD_STATE; + U08 zeroCmdStatus = getFPGABloodLeakZeroErrorCounter() & BLOOD_LEAK_ZERO_CMD_STATUS_READY; + + // Check if the zero command is ready to receive a command and the zero status is high + if ( ( BLOOD_LEAK_ZERO_CMD_STATUS_READY == zeroCmdStatus ) && ( BLOOD_LEAK_STATUS_BIT_HIGH == getFPGABloodLeakZeroStatus() ) ) + { + // The conditions are met start the command + // Start with the previous status bit is high + state = BLOOD_LEAK_ZERO_STATE; + bloodLeakCmd.cmdStartTimeMS = getMSTimerCount(); + bloodLeakCmd.cmdPrevStatus = BLOOD_LEAK_STATUS_BIT_HIGH; setFPGABloodLeakZero(); } + else if ( TRUE == didTimeout( bloodLeakCmd.cmdStartTimeMS, BLOOD_LEAK_ZERO_CMD_TIMEOUT_MS ) ) + { +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_ZERO_CMD_TIMEOUT ); + } + state = BLOOD_LEAK_INIT_STATE; + } + return state; } @@ -648,25 +698,70 @@ static BLOOD_LEAK_STATE_T handleBloodLeakZeroState( void ) { BLOOD_LEAK_STATE_T state = BLOOD_LEAK_ZERO_STATE; + U08 bloodLeakZeroStatus = getFPGABloodLeakZeroStatus(); - if ( ( TRUE == FPGABloodLeakZeroDetected() ) && - ( BLOOD_LEAK_SELF_TEST_CMD_STATUS_READY == ( getFPGABloodLeakSelfTestErrorCounter() & BLOOD_LEAK_SELF_TEST_CMD_STATUS_READY ) ) ) + // Check if the previous zero status bit was a 0 (low) and the current zero status bit is a 1 (high) + // Clear the blood leak zero and self test commands and get ready to do the self test + if ( ( BLOOD_LEAK_STATUS_BIT_LOW == bloodLeakCmd.cmdPrevStatus ) && ( BLOOD_LEAK_STATUS_BIT_HIGH == bloodLeakZeroStatus ) ) { - state = BLOOD_LEAK_SELF_TEST_STATE; - bloodLeakSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; - bloodLeakSelfTestStartTime = getMSTimerCount(); + // Clear the zero command since it is done and clear the self test since we are getting ready to do a self test. + clearFPGABloodLeakZero(); + clearFPGABloodLeakSelfTest(); + state = BLOOD_LEAK_PREP_FOR_SELF_TEST_CMD_STATE; + } + else if ( TRUE == didTimeout( bloodLeakCmd.cmdStartTimeMS, BLOOD_LEAK_ZERO_CMD_TIMEOUT_MS ) ) + { + // Zero command timed out +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_ZERO_CMD_TIMEOUT ); + } + // Get back to init state + state = BLOOD_LEAK_INIT_STATE; + } + else + { + // Update the previous status with the current zero status since the low to high edge has been observed yet + bloodLeakCmd.cmdPrevStatus = bloodLeakZeroStatus; + } - //clearFPGABloodLeakZero(); // TODO remove once the BLD has been tested + return state; +} + +/*********************************************************************//** + * @brief + * The handleBloodLeakPrepForSelfTestCmdState function handles the blood leak + * prepare for self test command state. + * @details Inputs: bloodLeakCmd + * @details Outputs: bloodLeakCmd + * @return next state + *************************************************************************/ +static BLOOD_LEAK_STATE_T handleBloodLeakPrepForSelfTestCmdState( void ) +{ + BLOOD_LEAK_STATE_T state = BLOOD_LEAK_PREP_FOR_SELF_TEST_CMD_STATE; + U08 selfTestCmdStatus = getFPGABloodLeakSelfTestErrorCounter() & BLOOD_LEAK_SELF_TEST_CMD_STATUS_READY; + + // Check if the self test command status is ready and self test status bit is low (0) + if ( ( BLOOD_LEAK_SELF_TEST_CMD_STATUS_READY == selfTestCmdStatus ) && ( BLOOD_LEAK_STATUS_BIT_LOW == getFPGABloodLeakStatus() ) ) + { + // Update the variables and set the self test + state = BLOOD_LEAK_SELF_TEST_STATE; + bloodLeakCmd.cmdStartTimeMS = getMSTimerCount(); + bloodLeakCmd.cmdPrevStatus = BLOOD_LEAK_STATUS_BIT_LOW; setFPGABloodLeakSelfTest(); } - else if ( TRUE == didTimeout( bloodLeakZeroStartTime, BLOOD_LEAK_TIMEOUT_MS ) ) + else if ( TRUE == didTimeout( bloodLeakCmd.cmdStartTimeMS, BLOOD_LEAK_SELF_TEST_CMD_TIMEOUT_MS ) ) { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) #endif { - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_FAULT ); + activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SELF_TEST_FAILURE ); } + // Self test command failed + state = BLOOD_LEAK_INIT_STATE; } return state; @@ -682,28 +777,33 @@ *************************************************************************/ static BLOOD_LEAK_STATE_T handleBloodLeakSelfTestState( void ) { - BLOOD_LEAK_STATE_T state = BLOOD_LEAK_SELF_TEST_STATE; + BLOOD_LEAK_STATE_T state = BLOOD_LEAK_SELF_TEST_STATE; + U08 bloodLeakSelfTestStatus = getFPGABloodLeakStatus(); - if ( SELF_TEST_STATUS_IN_PROGRESS == bloodLeakSelfTestStatus ) + // Check if the previous status bit was a high (1) and the current status bit is a low (0). This means that the self test was + // successfully finished + if ( ( BLOOD_LEAK_STATUS_BIT_HIGH == bloodLeakCmd.cmdPrevStatus ) && ( BLOOD_LEAK_STATUS_BIT_LOW == bloodLeakSelfTestStatus ) ) { - if ( FALSE == noFPGABloodLeakDetected() ) // Faked blood leak caused by independent MCU board + // Clear the self test command since it is done + clearFPGABloodLeakSelfTest(); + state = BLOOD_LEAK_NORMAL_STATE; + bloodLeakSelfTestStatus = SELF_TEST_STATUS_PASSED; + } + else if ( TRUE == didTimeout( bloodLeakCmd.cmdStartTimeMS, BLOOD_LEAK_SELF_TEST_CMD_TIMEOUT_MS ) ) + { +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - bloodLeakSelfTestStatus = SELF_TEST_STATUS_PASSED; - //clearFPGABloodLeakSelfTest(); // TODO remove this function when the BLD is tested - } - else if ( TRUE == didTimeout( bloodLeakSelfTestStartTime, BLOOD_LEAK_TIMEOUT_MS ) ) - { - bloodLeakSelfTestStatus = SELF_TEST_STATUS_FAILED; activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SELF_TEST_FAILURE ); } + // Self test failed due to timeout + state = BLOOD_LEAK_INIT_STATE; + bloodLeakSelfTestStatus = SELF_TEST_STATUS_FAILED; } else { - // Blood leak self-test finished, wait for self-test faked blood leak clear - if ( TRUE == noFPGABloodLeakDetected() ) - { - state = BLOOD_LEAK_NORMAL_STATE; - } + bloodLeakCmd.cmdPrevStatus = bloodLeakSelfTestStatus; } return state; @@ -721,15 +821,19 @@ { BLOOD_LEAK_STATE_T state = BLOOD_LEAK_NORMAL_STATE; - if ( TRUE == noFPGABloodLeakDetected() ) + // TODO remove + /*if ( TRUE == noFPGABloodLeakDetected() ) // TODO remove noFPGABloodLeakDetected() { bloodLeakStatus.data = BLOOD_LEAK_NOT_DETECTED; } else { bloodLeakStatus.data = BLOOD_LEAK_DETECTED; - } + }*/ + // If the blood leak status bit is low (0) it means blood has not been detected, otherwise, blood has been detected + bloodLeakStatus.data = ( BLOOD_LEAK_STATUS_BIT_LOW == getFPGABloodLeakStatus() ? BLOOD_LEAK_NOT_DETECTED : BLOOD_LEAK_DETECTED ); + // Check status reading and act upon if ( BLOOD_LEAK_DETECTED == getBloodLeakStatus() ) { @@ -761,19 +865,12 @@ } } - if ( TRUE == bloodLeakZeroRequested ) - { - state = BLOOD_LEAK_ZERO_STATE; - bloodLeakZeroRequested = FALSE; + // Check whether zeroing the sensor has been requested or not if yes, transition to zero command state otherwise, stay in this state + state = ( TRUE == hasZeroBloodLeakBeenRequested() ? BLOOD_LEAK_PREP_FOR_ZERO_CMD_STATE : state ); - setFPGABloodLeakZero(); - bloodLeakZeroStartTime = getMSTimerCount(); - } - if ( TRUE == bloodLeakExitNormalRequested ) { state = BLOOD_LEAK_INIT_STATE; - bloodLeakZeroRequested = FALSE; bloodLeakExitNormalRequested = FALSE; } @@ -880,7 +977,7 @@ case D_EMB_MODE_CMD: case C_EMB_MODE_CMD: // First clear the buffer from the older data - memset( bloodLeakEmbModeCmdSquence, 0x0, BLOOD_LEAK_EMB_MODE_CMD_SEQ_LENGTH ); + memset( bloodLeakEmbModeCmdSquence, 0x0, 2 * BLOOD_LEAK_EMB_MODE_CMD_SEQ_LENGTH ); // Set the command sequence bloodLeakEmbModeCmdSquence[ BLOOD_LEAK_EMB_MODE_RESET_INDEX ][ BLOOD_LEAK_EMB_MODE_CMD_COL_INDEX ] = BLOOD_LEAK_EMB_MODE_COMM_RESET; bloodLeakEmbModeCmdSquence[ BLOOD_LEAK_EMB_MODE_RESET_INDEX ][ BLOOD_LEAK_EMB_MODE_IS_UART_COL_INDEX ] = TRUE; @@ -1371,7 +1468,30 @@ bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; } +/*********************************************************************//** + * @brief + * The hasZeroBloodLeakBeenRequested function checks whether zeroing blood + * leak has been requested or not. + * @details Inputs: bloodLeakCmd + * @details Outputs: bloodLeakCmd + * @return TURE if request otherwise, FLASE + *************************************************************************/ +static BOOL hasZeroBloodLeakBeenRequested( void ) +{ + BOOL status = FALSE; + if ( TRUE == bloodLeakCmd.zeroCmdRequested ) + { + status = TRUE; + bloodLeakCmd.zeroCmdRequested = FALSE; + bloodLeakCmd.cmdStartTimeMS = getMSTimerCount(); + clearFPGABloodLeakZero(); + } + + return status; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rc72332b4674a895aed7d56ca37ee5230548da3f6 -r88f3fa0b9f8a2b1c54e0489b2c4269fd5bb60d17 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision c72332b4674a895aed7d56ca37ee5230548da3f6) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 88f3fa0b9f8a2b1c54e0489b2c4269fd5bb60d17) @@ -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. @@ -1987,21 +1989,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 @@ -2054,6 +2041,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 Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rc72332b4674a895aed7d56ca37ee5230548da3f6 -r88f3fa0b9f8a2b1c54e0489b2c4269fd5bb60d17 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision c72332b4674a895aed7d56ca37ee5230548da3f6) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 88f3fa0b9f8a2b1c54e0489b2c4269fd5bb60d17) @@ -123,12 +123,13 @@ BOOL noFPGAFluidLeakDetected( void ); -BOOL noFPGABloodLeakDetected( void ); -BOOL FPGABloodLeakZeroDetected( void ); +BOOL noFPGABloodLeakDetected( void ); // TODO remove void setFPGABloodLeakZero( void ); void clearFPGABloodLeakZero( void ); void setFPGABloodLeakSelfTest( void ); void clearFPGABloodLeakSelfTest( void ); +U08 getFPGABloodLeakZeroStatus( void ); +U08 getFPGABloodLeakStatus( void ); void setFPGABloodLeakUARTControl( U08 value ); void setFPGABloodLeakUARTTransmit( U08 value );