Index: firmware/App/Controllers/Bubble.c =================================================================== diff -u -r796d5732ae78870d15ac5c86feee82229626034c -r3d30c9829d316b8c5e632c0201a59c8d14b3486e --- firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision 796d5732ae78870d15ac5c86feee82229626034c) +++ firmware/App/Controllers/Bubble.c (.../Bubble.c) (revision 3d30c9829d316b8c5e632c0201a59c8d14b3486e) @@ -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[ NUM_OF_BUBBLES ]; ///< Air bubble detectors self-test start times. +static BOOL bubblesSelfTestRequested[ NUM_OF_BUBBLES ]; ///< 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 }; @@ -151,18 +151,18 @@ *************************************************************************/ static BUBBLE_STATES_T handleBubbleInitState( BUBBLES_T bubble ) { - BUBBLE_STATES_T state[ bubble ] = BUBBLE_INIT_STATE; + BUBBLE_STATES_T state = BUBBLE_INIT_STATE; if ( TRUE == bubblesSelfTestRequested[ bubble ] ) { - state[ bubble ] = BUBBLE_SELF_TEST_STATE; + state = BUBBLE_SELF_TEST_STATE; bubblesSelfTestRequested[ bubble ] = FALSE; setFPGABubbleSelfTest( bubble ); bubblesSelfTestStartTime[ bubble ] = getMSTimerCount(); } - return state[ bubble ]; + return state; } /*********************************************************************//** @@ -175,7 +175,7 @@ *************************************************************************/ static BUBBLE_STATES_T handleBubbleSelfTestState( BUBBLES_T bubble ) { - BUBBLE_STATES_T state[ bubble ] = BUBBLE_SELF_TEST_STATE; + BUBBLE_STATES_T state = BUBBLE_SELF_TEST_STATE; if ( SELF_TEST_STATUS_IN_PROGRESS == bubblesSelfTestStatus[ bubble ] ) { @@ -206,11 +206,11 @@ // Air bubble self-test finished, wait for self-test faked air bubble detector clear if ( TRUE == noFPGABubbleDetected( bubble ) ) { - state[ bubble ] = BUBBLE_NORMAL_STATE; + state = BUBBLE_NORMAL_STATE; } } - return state[ bubble ]; + return state; } /*********************************************************************//** @@ -223,7 +223,7 @@ *************************************************************************/ static BUBBLE_STATES_T handleBubbleNormalState( BUBBLES_T bubble ) { - BUBBLE_STATES_T state[ bubble ] = BUBBLE_NORMAL_STATE; + BUBBLE_STATES_T state = BUBBLE_NORMAL_STATE; if ( TRUE == noFPGABubbleDetected( bubble ) ) { @@ -252,21 +252,6 @@ // TODO: Should never reach here } } - else if ( getCurrentOperationMode() == MODE_PRET ) // TODO: Any better mode to know we are priming? - { - 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 ) @@ -295,16 +280,16 @@ } } - if ( TRUE == bubblesSelfTestRequested( bubble ) ) + if ( TRUE == bubblesSelfTestRequested[ bubble ] ) { - state[ bubble] = BUBBLE_SELF_TEST_STATE; + state = BUBBLE_SELF_TEST_STATE; bubblesSelfTestRequested[ bubble ] = FALSE; setFPGABubbleSelfTest( bubble ); bubblesSelfTestStartTime[ bubble ] = getMSTimerCount(); } - return state[ bubble ]; + return state; } /*********************************************************************//** @@ -321,7 +306,7 @@ if ( OVERRIDE_KEY == bubblesStatus[ bubble ].override ) { - result = (BLOOD_LEAK_STATUS_T)bubblesStatus[ bubble ].ovData; + result = (BUBBLE_STATUS_T)bubblesStatus[ bubble ].ovData; } return result; @@ -370,18 +355,14 @@ *************************************************************************/ static void publishBubblesData( void ) { - BUBBLES_T bubble; - // Publish air bubble detectors data on interval if ( ++bubblesDataPublicationTimerCounter >= getPublishBubblesDataInterval() ) { - for ( bubble = ADA; bubble < NUM_OF_BUBBLES; bubble++ ) - { - BUBBLE_STATUS_T status = getBubbleStatus( bubble ); + BUBBLE_STATUS_T statusADA = getBubbleStatus( ADA ); + BUBBLE_STATUS_T statusADV = getBubbleStatus( ADV ); - broadcastBubblesData( status, (U32)bubblesState[ bubble ] ); + broadcastBubblesData( statusADA, (U32)bubblesState[ ADA ], statusADV, (U32)bubblesState[ ADV ] ); bubblesDataPublicationTimerCounter = 0; - } } } Index: firmware/App/Controllers/Bubble.h =================================================================== diff -u -r796d5732ae78870d15ac5c86feee82229626034c -r3d30c9829d316b8c5e632c0201a59c8d14b3486e --- firmware/App/Controllers/Bubble.h (.../Bubble.h) (revision 796d5732ae78870d15ac5c86feee82229626034c) +++ firmware/App/Controllers/Bubble.h (.../Bubble.h) (revision 3d30c9829d316b8c5e632c0201a59c8d14b3486e) @@ -59,7 +59,7 @@ BUBBLE_STATUS_T getBubbleStatus( BUBBLES_T bubble ); SELF_TEST_STATUS_T getBubbleSelfTestStatus( BUBBLES_T bubble ); -BOOL testSetBubblesDataPublishIntervalOverride( U32 ); +BOOL testSetBubblesDataPublishIntervalOverride( U32 value ); BOOL testResetBubblesDataPublishIntervalOverride( void ); BOOL testSetBubbleStatusOverride( BUBBLE_STATUS_T status, BUBBLES_T bubble ); Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -rb7764e26a3460652da29b1f957706dfaca413226 -r3d30c9829d316b8c5e632c0201a59c8d14b3486e --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision b7764e26a3460652da29b1f957706dfaca413226) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 3d30c9829d316b8c5e632c0201a59c8d14b3486e) @@ -814,8 +814,8 @@ DRY_SELF_TESTS_STATE_T state = DRY_SELF_TESTS_USED_CARTRIDGE_CHECK_STATE; // TODO: Use appropriate sensor driver - BOOL const isADADetectedAir = getFPGAArterialAirBubbleStatus(); - BOOL const isADVDetectedAir = getFPGAVenousAirBubbleStatus(); + BOOL const isADADetectedAir = noFPGABubbleDetected( ADA ); + BOOL const isADVDetectedAir = noFPGABubbleDetected( ADV ); if ( ( TRUE == isADADetectedAir ) && ( TRUE == isADVDetectedAir ) && ( AIR_TRAP_LEVEL_AIR == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_LOWER ) ) && @@ -1118,8 +1118,8 @@ *result = SELF_TEST_STATUS_FAILED; // TODO: Use appropriate sensor driver - BOOL const isADADetectedAir = getFPGAArterialAirBubbleStatus(); - BOOL const isADVDetectedAir = getFPGAVenousAirBubbleStatus(); + BOOL const isADADetectedAir = noFPGABubbleDetected( ADA ); + BOOL const isADVDetectedAir = noFPGABubbleDetected( ADV ); #ifndef SKIP_AIR_BUBBLE_CHECK if ( ( FALSE == isADADetectedAir ) && ( FALSE == isADVDetectedAir ) ) Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r796d5732ae78870d15ac5c86feee82229626034c -r3d30c9829d316b8c5e632c0201a59c8d14b3486e --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 796d5732ae78870d15ac5c86feee82229626034c) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 3d30c9829d316b8c5e632c0201a59c8d14b3486e) @@ -530,7 +530,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 @@ -874,7 +874,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; @@ -1736,15 +1736,17 @@ * @details Outputs: none * @return noFPGABubbleDetected *************************************************************************/ -BOOL noFPGABubbleDetected( BUBBLES_T bubble ) +BOOL noFPGABubbleDetected( U32 bubble ) { + U16 noFPGABubbleDetected; + if ( bubble == ADA ) { - U16 noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADA_BUBBLE_STATUS_MASK; + noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADA_BUBBLE_STATUS_MASK; } else if ( bubble == ADV ) { - U16 noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_BUBBLE_STATUS_MASK; + noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_BUBBLE_STATUS_MASK; } else { @@ -1762,15 +1764,17 @@ * @details Outputs: none * @return FPGABubbleSelfTestDetected *************************************************************************/ -BOOL FPGABubbleSelfTestDetected( BUBBLES_T bubble ) +BOOL FPGABubbleSelfTestDetected( U32 bubble ) { + U16 FPGABubbleSelfTestDetected; + if ( bubble == ADA ) { - U16 FPGABubbleSelfTestDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADA_BUBBLE_TEST_STATE_MASK; + FPGABubbleSelfTestDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADA_BUBBLE_TEST_STATE_MASK; } else if ( bubble == ADV ) { - U16 FPGABubbleSelfTestDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_BUBBLE_TEST_STATE_MASK; + FPGABubbleSelfTestDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_BUBBLE_TEST_STATE_MASK; } else { @@ -1788,7 +1792,7 @@ * @details Outputs: none * @return FPGABubbleSelfTestDetected *************************************************************************/ -void setFPGABubbleSelfTest( BUBBLES_T bubble ) +void setFPGABubbleSelfTest( U32 bubble ) { if ( bubble == ADA ) { @@ -1808,7 +1812,7 @@ * @details Outputs: none * @return none *************************************************************************/ -void clearFPGABubbleSelfTest( BUBBLES_T bubble ) +void clearFPGABubbleSelfTest( U32 bubble ) { if ( bubble == ADA ) { Index: firmware/App/Services/FPGA.h =================================================================== diff -u -r796d5732ae78870d15ac5c86feee82229626034c -r3d30c9829d316b8c5e632c0201a59c8d14b3486e --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 796d5732ae78870d15ac5c86feee82229626034c) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 3d30c9829d316b8c5e632c0201a59c8d14b3486e) @@ -112,10 +112,10 @@ 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 ); +BOOL noFPGABubbleDetected( U32 bubble ); +BOOL FPGABubbleSelfTestDetected( U32 bubble ); +void setFPGABubbleSelfTest( U32 bubble ); +void clearFPGABubbleSelfTest( U32 bubble ); void setFPGAValveDialyzerInletPosition( S16 setPoint ); S16 getFPGAValveDialyzerInletPosition( void ); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r796d5732ae78870d15ac5c86feee82229626034c -r3d30c9829d316b8c5e632c0201a59c8d14b3486e --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 796d5732ae78870d15ac5c86feee82229626034c) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 3d30c9829d316b8c5e632c0201a59c8d14b3486e) @@ -1917,6 +1917,41 @@ /***********************************************************************//** * @brief + * The broadcastBloodLeakData function constructs an HD blood leak data msg to \n + * be broadcasted and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: blood leak data msg constructed and queued + * @param status blood leak status + * @param state blood leak state + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastBubblesData( BUBBLE_STATUS_T statusADA, U32 stateADA, BUBBLE_STATUS_T statusADV, U32 stateADV ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_BUBBLES_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &statusADA, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &stateADA, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &statusADV, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &stateADV, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/***********************************************************************//** + * @brief * The broadcastPrimeData function constructs a prime data msg to \n * be broadcast and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -4970,11 +5005,11 @@ memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetBubblesStatusOverride( (BUBBLE_STATUS_T)( payload.state.u32 ), payload.index ); + result = testSetBubbleStatusOverride( (BUBBLE_STATUS_T)payload.state.u32, (BUBBLES_T)payload.index ); } else { - result = testResetBubblesStatusOverride(); + result = testResetBubbleStatusOverride( (BUBBLES_T)payload.index ); } } @@ -5001,7 +5036,7 @@ { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); result = TRUE; - selfTestBubble( payload.index ); + selfTestBubble( (BUBBLES_T)payload.index ); } // Respond to request Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r796d5732ae78870d15ac5c86feee82229626034c -r3d30c9829d316b8c5e632c0201a59c8d14b3486e --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 796d5732ae78870d15ac5c86feee82229626034c) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 3d30c9829d316b8c5e632c0201a59c8d14b3486e) @@ -351,6 +351,9 @@ // MSG_ID_HD_BLOOD_LEAK_DATA BOOL broadcastBloodLeakData( BLOOD_LEAK_STATUS_T status, U32 state ); +// MSG_ID_HD_BUBBLES_DATA +BOOL broadcastBubblesData( BUBBLE_STATUS_T statusADA, U32 stateADA, BUBBLE_STATUS_T statusADV, U32 stateADV ); + // MSG_ID_HD_PRIMING_STATUS_DATA BOOL broadcastPrimeData( PRIMING_DATA_PAYLOAD_T *primeDataPtr );