Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rf7b149d8b8c9ea6ac58e4739101693d251d7a355 -r2cc4f0cfc6512c942864d7d302cef5df375a2081 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision f7b149d8b8c9ea6ac58e4739101693d251d7a355) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 2cc4f0cfc6512c942864d7d302cef5df375a2081) @@ -7,8 +7,8 @@ * * @file FPGA.c * -* @author (last) Sean Nash -* @date (last) 14-Oct-2020 +* @author (last) Peman Montazemi +* @date (last) 15-Feb-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -81,6 +81,7 @@ #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_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. @@ -1501,6 +1502,21 @@ /*********************************************************************//** * @brief + * The noFluidLeakDetected 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 + *************************************************************************/ +BOOL noFPGAFluidLeakDetected( void ) +{ + U16 noFluidLeakDetected = fpgaSensorReadings.fpgaGPIO & FPGA_FLUIDLEAK_STATE_MASK; + + return ( 0 == noFluidLeakDetected ? FALSE : TRUE ); +} + +/*********************************************************************//** + * @brief * The setValveDialyzerInletPosition function sets the position of VDi * in counts * @details Inputs: fpgaActuatorSetPoints Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rf7b149d8b8c9ea6ac58e4739101693d251d7a355 -r2cc4f0cfc6512c942864d7d302cef5df375a2081 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision f7b149d8b8c9ea6ac58e4739101693d251d7a355) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 2cc4f0cfc6512c942864d7d302cef5df375a2081) @@ -85,6 +85,8 @@ void setFPGAValvesControlMode( U16 bits ); U16 getFPGAValvesStatus( void ); +BOOL noFPGAFluidLeakDetected( void ); + void setFPGAValveDialyzerInletPosition( S16 setPoint ); S16 getFPGAValveDialyzerInletPosition( void ); U16 getFPGAValveDialyzerInletCurrentCounts( void ); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -re23087e0c17f6ea81d60641fdb52121a8dd5a099 -r2cc4f0cfc6512c942864d7d302cef5df375a2081 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision e23087e0c17f6ea81d60641fdb52121a8dd5a099) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 2cc4f0cfc6512c942864d7d302cef5df375a2081) @@ -1447,6 +1447,13 @@ handleTestDialOutPumpHomeRequest( message ); break; + case MSG_ID_HD_FLUID_LEAK_SEND_INTERVAL_OVERRIDE: + handleSetFluidLeakBroadcastIntervalOverrideRequest( message ); + break; + + case MSG_ID_HD_FLUID_LEAK_STATE_DETECTOR_OVERRIDE: + handleSetFluidLeakStateDetectorOverrideRequest( message ); + case MSG_ID_HD_SET_OP_MODE_REQUEST: handleTestSetOpModeRequest( message ); break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r27f3db92495948d4c1192421c1b0c20338c4a034 -r2cc4f0cfc6512c942864d7d302cef5df375a2081 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 2cc4f0cfc6512c942864d7d302cef5df375a2081) @@ -37,7 +37,7 @@ #include "TreatmentEnd.h" #include "TreatmentRecirc.h" #include "Utilities.h" -#include "Valves.h" +#include "Valves.h" #include "WatchdogMgmt.h" /** @@ -1405,10 +1405,39 @@ /***********************************************************************//** * @brief - * The broadcastAirTrapData function constructs an HD air trap data msg to \n + * The broadcastFluidLeakState function constructs an HD fluid leak state msg to \n + * be broadcasted and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: fluid leak state msg constructed and queued + * @param state fluid leak state + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastFluidLeakState( FLUID_LEAK_STATES_T state ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 leakState = (U32)state; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_FLUID_LEAK_STATE; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &leakState, 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 - * @details Outputs: air trap data msg constructed and queued + * @details Outputs: prime data msg constructed and queued * @param primeDataPtr prime data record pointer * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -4119,12 +4148,12 @@ BOOL result = FALSE; // Verify payload length - if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index, (AIR_TRAP_LEVELS_T)(payload.state.u32) ); + result = testSetAirTrapLevelOverride( (AIR_TRAP_LEVEL_SENSORS_T)payload.index, (AIR_TRAP_LEVELS_T)( payload.state.u32 ) ); } else { @@ -4138,6 +4167,70 @@ /*********************************************************************//** * @brief + * The handleSetFluidLeakBroadcastIntervalOverrideRequest function handles a + * request to override the fluid leak state broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetFluidLeakBroadcastIntervalOverrideRequest( 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 = testSetFluidLeakStatePublishIntervalOverride( (U32)( payload.state.u32 ) ); + } + else + { + result = testResetFluidLeakStatePublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetFluidLeakStateDetectorOverrideRequest function handles a request to + * override the fluid leak detector state. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetFluidLeakStateDetectorOverrideRequest( 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 = testSetFluidLeakStateOverride( ( FLUID_LEAK_STATES_T)( payload.state.u32 ) ); + } + else + { + result = testResetFluidLeakStateOverride(); + } + } + + // 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 -r27f3db92495948d4c1192421c1b0c20338c4a034 -r2cc4f0cfc6512c942864d7d302cef5df375a2081 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 2cc4f0cfc6512c942864d7d302cef5df375a2081) @@ -26,6 +26,7 @@ #include "DialInFlow.h" #include "DialOutFlow.h" #include "Dialysis.h" +#include "FluidLeak.h" #include "Prime.h" #include "ModeTreatment.h" #include "MsgQueues.h" @@ -276,6 +277,9 @@ // MSG_ID_HD_AIR_TRAP_DATA BOOL broadcastAirTrapData( AIR_TRAP_LEVELS_T lowerLevel, AIR_TRAP_LEVELS_T upperLevel ); +// MSG_ID_HD_FLUID_LEAK_STATE +BOOL broadcastFluidLeakState( FLUID_LEAK_STATES_T state ); + // MSG_ID_HD_PRIMING_STATUS_DATA BOOL broadcastPrimeData( PRIMING_DATA_PAYLOAD_T *primeDataPtr ); @@ -465,6 +469,12 @@ // MSG_ID_HD_AIR_TRAP_LEVEL_SENSOR_OVERRIDE void handleSetAirTrapLevelSensorOverrideRequest( MESSAGE_T *message ); +// MSG_ID_HD_FLUID_LEAK_SEND_INTERVAL_OVERRIDE +void handleSetFluidLeakBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_FLUID_LEAK_STATE_DETECTOR_OVERRIDE +void handleSetFluidLeakStateDetectorOverrideRequest( MESSAGE_T *message ); + // MSG_ID_SUPER_CLEAR_ALARMS_CMD void handleTestSuperClearAlarmsRequest( MESSAGE_T *message );