Index: firmware/App/Controllers/Bubble.c =================================================================== diff -u -rf24be7fd135878e6ff28dff56937c31626bd4bc1 -r796d5732ae78870d15ac5c86feee82229626034c --- firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision f24be7fd135878e6ff28dff56937c31626bd4bc1) +++ firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision 796d5732ae78870d15ac5c86feee82229626034c) @@ -48,8 +48,8 @@ static OVERRIDE_U32_T bubblesStatus[ NUM_OF_BUBBLES ]; ///< Detected air bubble status for air bubble detectors. static SELF_TEST_STATUS_T bubblesSelfTestStatus[ NUM_OF_BUBBLES ]; ///< Current status of air bubble detectors self-tests. -static U32 bubblesSelfTestStartTime = [ 0, 0 ]; ///< Air bubble detectors self-test start times. -static BOOL bubblesSelfTestRequested = [ FALSE, FALSE ]; ///< Air bubble detectors self-test requested flags. +static U32 bubblesSelfTestStartTime[ 0, 0 ]; ///< Air bubble detectors self-test start times. +static BOOL bubblesSelfTestRequested[ FALSE, FALSE ]; ///< Air bubble detectors self-test requested flags. /// Interval (in ms) at which to publish air bubble detectors data on CAN bus. static OVERRIDE_U32_T bubblesDataPublishInterval = { BUBBLE_PUB_INTERVAL, BUBBLE_PUB_INTERVAL, 0, 0 }; @@ -138,7 +138,7 @@ *************************************************************************/ void selfTestBubble( BUBBLES_T bubble ) { - bubbleSelfTestRequested[ bubble ] = TRUE; + bubblesSelfTestRequested[ bubble ] = TRUE; } /*********************************************************************//** @@ -167,8 +167,8 @@ /*********************************************************************//** * @brief - * The handleBubbleSelfTestState function handles a given air bubble detector - * module in self-test state. + * The handleBubbleSelfTestState function handles a given air bubble detector + * in self-test state. * @details Inputs: none * @details Outputs: Air bubble detector module self-test. * @return next state @@ -177,170 +177,184 @@ { BUBBLE_STATES_T state[ bubble ] = BUBBLE_SELF_TEST_STATE; - if ( TRUE == FPGABubbleSelfTestDetected( bubble ) ) + if ( SELF_TEST_STATUS_IN_PROGRESS == bubblesSelfTestStatus[ bubble ] ) { - state[ bubble ] = BUBBLE_SELF_TEST_STATE; - bubblesSelfTestStatus[ bubble ] = SELF_TEST_STATUS_IN_PROGRESS; - clearFPGABubbleSelfTest( bubble ); - bubblesSelfTestStartTime[ bubble ] = getMSTimerCount(); - } - else - { - if ( TRUE == didTimeout( bubblesSelfTestStartTime[ bubble ], BUBBLE_TIMEOUT_MS ) ) + if ( FALSE == noFPGABubbleDetected( bubble ) ) // Faked air bubble caused { + bubblesSelfTestStatus[ bubble ] = SELF_TEST_STATUS_PASSED; + clearFPGABubbleSelfTest( bubble ); + } + else if ( TRUE == didTimeout( bubblesSelfTestStartTime[ bubble ], BUBBLE_TIMEOUT_MS ) ) + { + bubblesSelfTestStatus[ bubble ] = SELF_TEST_STATUS_FAILED; if ( bubble == ADA ) { - activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_FAULT ); + activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_SELF_TEST_FAILURE ); } else if ( bubble == ADV ) { - activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_FAULT ); + activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_SELF_TEST_FAILURE ); } else { - // TODO: Should never get here, alarm as appropriate + // TODO: Should never reach here } } } - - return state[ bubble ]; -} - -/*********************************************************************//** - * @brief - * The handleBloodLeakSelfTestState function handles the Blood Leak module - * in self-test state. - * @details Inputs: none - * @details Outputs: Blood Leak module self test. - * @return next state - *************************************************************************/ -static BLOOD_LEAK_STATES_T handleBloodLeakSelfTestState( void ) -{ - BLOOD_LEAK_STATES_T state = BLOOD_LEAK_SELF_TEST_STATE; - - if ( SELF_TEST_STATUS_IN_PROGRESS == bloodLeakSelfTestStatus ) - { - if ( FALSE == noFPGABloodLeakDetected() ) // Faked blood leak caused by independent MCU board - { - bloodLeakSelfTestStatus = SELF_TEST_STATUS_PASSED; - clearFPGABloodLeakSelfTest(); - } - else if ( TRUE == didTimeout( bloodLeakSelfTestStartTime, BLOOD_LEAK_TIMEOUT_MS ) ) - { - bloodLeakSelfTestStatus = SELF_TEST_STATUS_FAILED; - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_SELF_TEST_FAILURE ); - } - } else { - // Blood leak self-test finished, wait for self-test faked blood leak clear - if ( TRUE == noFPGABloodLeakDetected() ) + // Air bubble self-test finished, wait for self-test faked air bubble detector clear + if ( TRUE == noFPGABubbleDetected( bubble ) ) { - state = BLOOD_LEAK_NORMAL_STATE; + state[ bubble ] = BUBBLE_NORMAL_STATE; } } - return state; + return state[ bubble ]; } /*********************************************************************//** * @brief - * The handleBloodLeakNormalState function handles the Blood Leak module + * The handleBubbleNormalState function handles a given air bubble module * in normal state. * @details Inputs: none - * @details Outputs: Blood Leak module normal. + * @details Outputs: Bubble module normal. * @return next state *************************************************************************/ -static BLOOD_LEAK_STATES_T handleBloodLeakNormalState( void ) +static BUBBLE_STATES_T handleBubbleNormalState( BUBBLES_T bubble ) { - BLOOD_LEAK_STATES_T state = BLOOD_LEAK_NORMAL_STATE; + BUBBLE_STATES_T state[ bubble ] = BUBBLE_NORMAL_STATE; - if ( TRUE == noFPGABloodLeakDetected() ) + if ( TRUE == noFPGABubbleDetected( bubble ) ) { - bloodLeakStatus.data = BLOOD_LEAK_NOT_DETECTED; + bubblesStatus[ bubble ].data = BUBBLE_NOT_DETECTED; } else { - bloodLeakStatus.data = BLOOD_LEAK_DETECTED; + bubblesStatus[ bubble ].data = BUBBLE_DETECTED; } // Check status reading and act upon - if ( BLOOD_LEAK_DETECTED == getBloodLeakStatus() ) + if ( BUBBLE_DETECTED == getBubbleStatus( bubble ) ) { if ( getCurrentOperationMode() == MODE_TREA ) { - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + if ( bubble == ADA ) + { + activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTED ); + } + else if ( bubble == ADV ) + { + activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); + } + else + { + // TODO: Should never reach here + } } - else + else if ( getCurrentOperationMode() == MODE_PRET ) // TODO: Any better mode to know we are priming? { - activateAlarmNoData( ALARM_ID_HD_BLOOD_LEAK_FAULT ); + if ( bubble == ADA ) + { + activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTOR_FAULT ); + } + else if ( bubble == ADV ) + { + activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTOR_TREATMENT_FAULT ); + } + else + { + // TODO: Should never reach here + } } + else if ( getCurrentOperationMode() == TREATMENT_RINSEBACK_STATE ) // TODO: Any better mode to know we are in rinseback? + { + if ( bubble == ADA ) + { + activateAlarmNoData( ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTOR_FAULT ); + } + else if ( bubble == ADV ) + { + activateAlarmNoData( ALARM_ID_HD_VENOUS_BUBBLE_DETECTOR_RINSEBACK_FAULT ); + } + else + { + // TODO: Should never reach here + } + } } else // Blood leak not detected { - clearAlarmCondition( ALARM_ID_HD_BLOOD_LEAK_DETECTED ); + if ( bubble == ADA ) + { + clearAlarmCondition( ALARM_ID_HD_ARTERIAL_BUBBLE_DETECTED ); + } + else if ( bubble == ADV ) + { + clearAlarmCondition( ALARM_ID_HD_VENOUS_BUBBLE_DETECTED ); + } } - if ( TRUE == bloodLeakZeroRequested ) + if ( TRUE == bubblesSelfTestRequested( bubble ) ) { - state = BLOOD_LEAK_ZERO_STATE; - bloodLeakZeroRequested = FALSE; + state[ bubble] = BUBBLE_SELF_TEST_STATE; + bubblesSelfTestRequested[ bubble ] = FALSE; - setFPGABloodLeakZero(); - bloodLeakZeroStartTime = getMSTimerCount(); + setFPGABubbleSelfTest( bubble ); + bubblesSelfTestStartTime[ bubble ] = getMSTimerCount(); } - return state; + return state[ bubble ]; } /*********************************************************************//** * @brief - * The getBloodLeakStatus function gets the current reading for the blood - * leak detector. - * @details Inputs: bloodLeakStatus + * The getBubbleStatus function gets the current reading for a given air bubble + * detector. + * @details Inputs: bubblesStatus * @details Outputs: none - * @return the current blood leak status. + * @return the current air bubble status. *************************************************************************/ -BLOOD_LEAK_STATUS_T getBloodLeakStatus( void ) +BUBBLE_STATUS_T getBubbleStatus( BUBBLES_T bubble ) { - BLOOD_LEAK_STATUS_T result = (BLOOD_LEAK_STATUS_T)bloodLeakStatus.data; + BUBBLE_STATUS_T result = (BUBBLE_STATUS_T)bubblesStatus[ bubble ].data; - if ( OVERRIDE_KEY == bloodLeakStatus.override ) + if ( OVERRIDE_KEY == bubblesStatus[ bubble ].override ) { - result = (BLOOD_LEAK_STATUS_T)bloodLeakStatus.ovData; + result = (BLOOD_LEAK_STATUS_T)bubblesStatus[ bubble ].ovData; } return result; } /*********************************************************************//** * @brief - * The getBloodLeakSelfTestStatus function gets the status for the blood - * leak detector self-test. - * @details Inputs: bloodLeakSelfTestStatus + * The getBubbleSelfTestStatus function gets the status for a given air bubble + * detector self-test. + * @details Inputs: bubblesSelfTestStatus * @details Outputs: none - * @return status of blood leak detector self-test. + * @return status of air bubble detector self-test. *************************************************************************/ -SELF_TEST_STATUS_T getBloodLeakSelfTestStatus( void ) +SELF_TEST_STATUS_T getBubbleSelfTestStatus( BUBBLES_T bubble ) { - return bloodLeakSelfTestStatus; + return bubblesSelfTestStatus[ bubble ]; } /*********************************************************************//** * @brief - * The getPublishBloodLeakDataInterval function gets the blood leak data + * The getPublishBubblesDataInterval function gets the air bubbles data * publication interval. - * @details Inputs: bloodLeakDataPublishInterval + * @details Inputs: bubblesDataPublishInterval * @details Outputs: none - * @return the current blood leak data publication interval (in task intervals). + * @return the current air bubbles data publication interval (in task intervals). *************************************************************************/ -static U32 getPublishBloodLeakDataInterval( void ) +static U32 getPublishBubblesDataInterval( void ) { - U32 result = bloodLeakDataPublishInterval.data; + U32 result = bubblesDataPublishInterval.data; - if ( OVERRIDE_KEY == bloodLeakDataPublishInterval.override ) + if ( OVERRIDE_KEY == bubblesDataPublishInterval.override ) { - result = bloodLeakDataPublishInterval.ovData; + result = bubblesDataPublishInterval.ovData; } return result; @@ -350,21 +364,24 @@ * @brief * The publishBubblesData function publishes air bubble detectors data at * the set interval. - * @details Inputs: bloodLeakStatus, bloodLeakState + * @details Inputs: status, bubblesState * @details Outputs: if broadcast is due, send air bubble detectors data * @return none *************************************************************************/ static void publishBubblesData( void ) { - BUBBLE_T bubble; + BUBBLES_T bubble; // Publish air bubble detectors data on interval if ( ++bubblesDataPublicationTimerCounter >= getPublishBubblesDataInterval() ) { - BUBBLES_STATUS_T status = getBubblesStatus(); + for ( bubble = ADA; bubble < NUM_OF_BUBBLES; bubble++ ) + { + BUBBLE_STATUS_T status = getBubbleStatus( bubble ); - broadcastBloodLeakData( status, (U32)bloodLeakState ); - bloodLeakDataPublicationTimerCounter = 0; + broadcastBubblesData( status, (U32)bubblesState[ bubble ] ); + bubblesDataPublicationTimerCounter = 0; + } } } @@ -376,14 +393,14 @@ /*********************************************************************//** * @brief - * The testSetBloodLeakDataPublishIntervalOverride function overrides the - * blood leak data publish interval. + * The testSetBubblesDataPublishIntervalOverride function overrides the + * air bubbles data publish interval. * @details Inputs: none - * @details Outputs: bloodLeakDataPublishInterval - * @param value override blood leak data publish interval with (in ms) + * @details Outputs: bubblesDataPublishInterval + * @param value override air bubbles data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetBloodLeakDataPublishIntervalOverride( U32 value ) +BOOL testSetBubblesDataPublishIntervalOverride( U32 value ) { BOOL result = FALSE; @@ -392,46 +409,46 @@ U32 intvl = value / TASK_PRIORITY_INTERVAL; result = TRUE; - bloodLeakDataPublishInterval.ovData = intvl; - bloodLeakDataPublishInterval.override = OVERRIDE_KEY; + bubblesDataPublishInterval.ovData = intvl; + bubblesDataPublishInterval.override = OVERRIDE_KEY; } return result; } /*********************************************************************//** * @brief - * The testResetBloodLeakDataPublishIntervalOverride function resets the override - * of the blood leak data publish interval. + * The testResetBubblesDataPublishIntervalOverride function resets the override + * of the air bubbles data publish interval. * @details Inputs: none - * @details Outputs: bloodLeakDataPublishInterval + * @details Outputs: bubblesDataPublishInterval * @return TRUE if override reset successful, FALSE if not *************************************************************************/ -BOOL testResetBloodLeakDataPublishIntervalOverride( void ) +BOOL testResetBubblesDataPublishIntervalOverride( void ) { BOOL result = FALSE; if ( TRUE == isTestingActivated() ) { result = TRUE; - bloodLeakDataPublishInterval.override = OVERRIDE_RESET; - bloodLeakDataPublishInterval.ovData = bloodLeakDataPublishInterval.ovInitData; + bubblesDataPublishInterval.override = OVERRIDE_RESET; + bubblesDataPublishInterval.ovData = bubblesDataPublishInterval.ovInitData; } return result; } /*********************************************************************//** * @brief - * The testSetBloodLeakStatusOverride function overrides the status - * of the blood leak detector. + * The testSetBubblesStatusOverride function overrides the status + * of a given air bubble detector. * @details Inputs: none - * @details Outputs: bloodLeakStatus + * @details Outputs: bubblesStatus * @param none - * @param status override blood leak detector with this + * @param status override air bubble detector with this * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetBloodLeakStatusOverride( BLOOD_LEAK_STATUS_T status ) +BOOL testSetBubbleStatusOverride( BUBBLE_STATUS_T status, BUBBLES_T bubble ) { BOOL result = FALSE; @@ -440,8 +457,8 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - bloodLeakStatus.ovData = (U32)status; - bloodLeakStatus.override = OVERRIDE_KEY; + bubblesStatus[ bubble ].ovData = (U32)status; + bubblesStatus[ bubble ].override = OVERRIDE_KEY; } } @@ -450,22 +467,22 @@ /*********************************************************************//** * @brief - * The testResetBloodLeakStatusOverride function resets the override of the - * blood leak detector status. + * The testResetBubbleStatusOverride function resets the override of a + * given air bubble detector status. * @details Inputs: none - * @details Outputs: bloodLeakStatus + * @details Outputs: bubblesStatus * @param none * @return TRUE if reset successful, FALSE if not *************************************************************************/ -BOOL testResetBloodLeakStatusOverride( void ) +BOOL testResetBubbleStatusOverride( BUBBLES_T bubble ) { BOOL result = FALSE; if ( TRUE == isTestingActivated() ) { result = TRUE; - bloodLeakStatus.override = OVERRIDE_RESET; - bloodLeakStatus.ovData = bloodLeakStatus.ovInitData; + bubblesStatus[ bubble ].override = OVERRIDE_RESET; + bubblesStatus[ bubble ].ovData = bubblesStatus[ bubble ].ovInitData; } return result; Index: firmware/App/Controllers/Bubble.h =================================================================== diff -u -rf24be7fd135878e6ff28dff56937c31626bd4bc1 -r796d5732ae78870d15ac5c86feee82229626034c --- firmware/App/Controllers/Bubble.h (.../Bubble.h) (revision f24be7fd135878e6ff28dff56937c31626bd4bc1) +++ firmware/App/Controllers/Bubble.h (.../Bubble.h) (revision 796d5732ae78870d15ac5c86feee82229626034c) @@ -56,14 +56,14 @@ void execBubbles( void ); void selfTestBubble( BUBBLES_T ); -BUBBLES_STATUS_T getBubblesStatus( void ); -SELF_TEST_STATUS_T getBubblesSelfTestStatus( void ); +BUBBLE_STATUS_T getBubbleStatus( BUBBLES_T bubble ); +SELF_TEST_STATUS_T getBubbleSelfTestStatus( BUBBLES_T bubble ); -BOOL testSetBubblesDataPublishIntervalOverride( U32 value ); +BOOL testSetBubblesDataPublishIntervalOverride( U32 ); BOOL testResetBubblesDataPublishIntervalOverride( void ); -BOOL testSetBubblesStatusOverride( BUBBLE_STATUS_T status); -BOOL testResetBubblesStatusOverride( void ); +BOOL testSetBubbleStatusOverride( BUBBLE_STATUS_T status, BUBBLES_T bubble ); +BOOL testResetBubbleStatusOverride( BUBBLES_T bubble ); /**@}*/ Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rb7764e26a3460652da29b1f957706dfaca413226 -r796d5732ae78870d15ac5c86feee82229626034c --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision b7764e26a3460652da29b1f957706dfaca413226) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 796d5732ae78870d15ac5c86feee82229626034c) @@ -82,14 +82,18 @@ #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_TEST_STATE_MASK 0x2000 ///< Bit mask for arterial air bubble detector self-test state. +#define FPGA_ADV_BUBBLE_TEST_STATE_MASK 0x4000 ///< Bit mask for venous air bubble detector self-test state. +#define FPGA_ADA_BUBBLE_SELF_TEST_CMD 0x01 ///< Bit for arterial air bubble detector self-test command. +#define FPGA_ADV_BUBBLE_SELF_TEST_CMD 0x02 ///< Bit for venous air bubble detector self-test command. // FPGA Sensors Record #pragma pack(push,1) @@ -1589,36 +1593,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 @@ -1756,6 +1730,102 @@ /*********************************************************************//** * @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( BUBBLES_T bubble ) +{ + if ( bubble == ADA ) + { + U16 noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADA_BUBBLE_STATUS_MASK; + } + else if ( bubble == ADV ) + { + U16 noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_BUBBLE_STATUS_MASK; + } + else + { + // TODO: Should never reach here + } + + return ( 0 == noFPGABubbleDetected ? TRUE : FALSE ); +} + +/*********************************************************************//** + * @brief + * The FPGABubbleSelfTestDetected function returns TRUE if air bubble self-test + * has been detected and FALSE if no air bubble self-test has been detected. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return FPGABubbleSelfTestDetected + *************************************************************************/ +BOOL FPGABubbleSelfTestDetected( BUBBLES_T bubble ) +{ + if ( bubble == ADA ) + { + U16 FPGABubbleSelfTestDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADA_BUBBLE_TEST_STATE_MASK; + } + else if ( bubble == ADV ) + { + U16 FPGABubbleSelfTestDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_BUBBLE_TEST_STATE_MASK; + } + else + { + // TODO: Should never reach here + } + + return ( 0 == FPGABubbleSelfTestDetected ? FALSE : TRUE ); +} + +/*********************************************************************//** + * @brief + * The setFPGABubbleSelfTest function sets the given air bubble detector into + * self-test mode via the FPGA. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return FPGABubbleSelfTestDetected + *************************************************************************/ +void setFPGABubbleSelfTest( BUBBLES_T 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: fpgaSensorReadings + * @details Outputs: none + * @return none + *************************************************************************/ +void clearFPGABubbleSelfTest( BUBBLES_T 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 + { + // TODO: Should never reach here + } +} + +/*********************************************************************//** + * @brief * The setValveDialyzerInletPosition function sets the position of VDi * in counts * @details Inputs: fpgaActuatorSetPoints Index: firmware/App/Services/FPGA.h =================================================================== diff -u -r04f033af4174bf41a7aa0ff9ccaae45b77472e01 -r796d5732ae78870d15ac5c86feee82229626034c --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 04f033af4174bf41a7aa0ff9ccaae45b77472e01) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 796d5732ae78870d15ac5c86feee82229626034c) @@ -95,8 +95,6 @@ void getFPGAAccelStatus( U16 *cnt, U16 *accelFPGAFaultReg ); void getFPGAAirTrapLevels( BOOL *airAtLower, BOOL *airAtUpper ); -BOOL getFPGAArterialAirBubbleStatus( void ); -BOOL getFPGAVenousAirBubbleStatus( void ); void setFPGASensorTest( U08 sensorTest ); @@ -114,6 +112,11 @@ void setFPGABloodLeakSelfTest( void ); void clearFPGABloodLeakSelfTest( void ); +BOOL noFPGABubbleDetected( BUBBLES_T bubble ); +BOOL FPGABubbleSelfTestDetected( BUBBLES_T bubble ); +void setFPGABubbleSelfTest( BUBBLES_T bubble ); +void clearFPGABubbleSelfTest( BUBBLES_T bubble ); + void setFPGAValveDialyzerInletPosition( S16 setPoint ); S16 getFPGAValveDialyzerInletPosition( void ); U16 getFPGAValveDialyzerInletCurrentCounts( void ); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r04f033af4174bf41a7aa0ff9ccaae45b77472e01 -r796d5732ae78870d15ac5c86feee82229626034c --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 04f033af4174bf41a7aa0ff9ccaae45b77472e01) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 796d5732ae78870d15ac5c86feee82229626034c) @@ -4920,6 +4920,96 @@ /*********************************************************************//** * @brief + * The handleSetBubblesDataBroadcastIntervalOverrideRequest function handles a + * request to override the air bubble detectors data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetBubblesDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetBubblesDataPublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetBubblesDataPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetBubblesStatusOverrideRequest function handles a request to + * override the air bubble detectors status. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetBubblesStatusOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetBubblesStatusOverride( (BUBBLE_STATUS_T)( payload.state.u32 ), payload.index ); + } + else + { + result = testResetBubblesStatusOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleBubblesSelfTestRequest function handles a request to + * self-test the air bubble detector. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleBubblesSelfTestRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( 0 == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); + result = TRUE; + selfTestBubble( payload.index ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleHDSoftwareResetRequest function handles a request to reset the * HD firmware processor. * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r04f033af4174bf41a7aa0ff9ccaae45b77472e01 -r796d5732ae78870d15ac5c86feee82229626034c --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 04f033af4174bf41a7aa0ff9ccaae45b77472e01) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 796d5732ae78870d15ac5c86feee82229626034c) @@ -23,6 +23,7 @@ #include "BloodFlow.h" #include "BloodLeak.h" #include "BloodPrime.h" +#include "Bubble.h" #include "DGInterface.h" #include "DialInFlow.h" #include "DialOutFlow.h" @@ -563,6 +564,15 @@ // MSG_ID_HD_BLOOD_LEAK_ZERO_REQUEST void handleBloodLeakZeroRequest( MESSAGE_T *message ); +// MSG_ID_HD_BUBBLES_DATA_SEND_INTERVAL_OVERRIDE +void handleSetBubblesDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_BUBBLES_STATUS_OVERRIDE +void handleSetBubblesStatusOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_BUBBLES_SELF_TEST_REQUEST +void handleBubblesSelfTestRequest( MESSAGE_T *message ); + // MSG_ID_SUPER_CLEAR_ALARMS_CMD void handleTestSuperClearAlarmsRequest( MESSAGE_T *message ); Index: firmware/source/sys_main.c =================================================================== diff -u -r04f033af4174bf41a7aa0ff9ccaae45b77472e01 -r796d5732ae78870d15ac5c86feee82229626034c --- firmware/source/sys_main.c (.../sys_main.c) (revision 04f033af4174bf41a7aa0ff9ccaae45b77472e01) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 796d5732ae78870d15ac5c86feee82229626034c) @@ -69,6 +69,7 @@ #include "Battery.h" #include "BloodFlow.h" #include "BloodLeak.h" +#include "Bubble.h" #include "Buttons.h" #include "CommBuffers.h" #include "CPLD.h" @@ -188,6 +189,7 @@ // Initialize monitors initAccel(); initBloodLeak(); + initBubbles(); initButtons(); initFluidLeak(); initPresOccl();