Index: firmware/App/Monitors/BloodLeak.c =================================================================== diff -u -rbc4537c14a446c8fe1720f574200399b180a6ff9 -r208d9299339c3b89ac7fbd2100eef3aa121bf591 --- firmware/App/Monitors/BloodLeak.c (.../BloodLeak.c) (revision bc4537c14a446c8fe1720f574200399b180a6ff9) +++ firmware/App/Monitors/BloodLeak.c (.../BloodLeak.c) (revision 208d9299339c3b89ac7fbd2100eef3aa121bf591) @@ -11,6 +11,7 @@ #include "OperationModes.h" #include "PersistentAlarm.h" #include "TaskPriority.h" +#include "TDInterface.h" #include "Timers.h" #include "Utilities.h" @@ -154,10 +155,18 @@ OVERRIDE_U32_T zeroingDriftIntervalTimeMS; ///< Blood leak zeroing interval time in milliseconds. OVERRIDE_U32_T zeroingUpperRangeIntervalTimeMS; ///< BLood leak zeroing upper range interval time in milliseconds. U32 driftUpperRangeDebounceTimeMS; ///< Blood leak drift in upper range debounce time in milliseconds. - U32 driftInRangeStatus; - U32 driftUpperRangeStatus; + U32 driftInRangeStatus; ///< Blood leak drift in range status. + U32 driftUpperRangeStatus; ///< Blood leak drift upper range status. } BLOOD_LEAK_ZEROING_STATUS_T; +/// Blood leak embedded mode response command structure +typedef struct +{ + U08 command; ///< Blood leak command. + U32 responseLen; ///< Blood leak response length. + U08 responseBuffer[ BLOOD_LEAK_EMB_MODE_RESP_BUFFER_LEN ]; ///< Blood leak response buffer. +} BLOOD_LEAK_EMB_MODE_RESP_T; + // ********** private data ********** static BLOOD_LEAK_STATE_T bloodLeakState; ///< Current state of blood leak state machine. @@ -231,6 +240,7 @@ static U32 getEmbModeInfoValue( U08 cmd ); static BOOL isLowerRangeIntensityDriftZeroingNeeded( void ); static BOOL isUpperIntensityZeroingNeeded( void ); +static BOOL sendBloodLeakEmbeddedModeCommandResponse( U08 cmd, U32 responseLen, U08 *responseBuffer ); /*********************************************************************//** * @brief @@ -483,13 +493,8 @@ *************************************************************************/ BLOOD_LEAK_STATUS_T getBloodLeakStatus( void ) { - BLOOD_LEAK_STATUS_T result = (BLOOD_LEAK_STATUS_T)bloodLeakStatus.data; + BLOOD_LEAK_STATUS_T result = (BLOOD_LEAK_STATUS_T)getU32OverrideValue( &bloodLeakStatus ); - if ( OVERRIDE_KEY == bloodLeakStatus.override ) - { - result = (BLOOD_LEAK_STATUS_T)bloodLeakStatus.ovData; - } - return result; } @@ -503,13 +508,6 @@ *************************************************************************/ SELF_TEST_STATUS_T getBloodLeakSelfTestStatus( void ) { -#ifndef _RELEASE_ - //if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_SELF_TEST ) ) - { - bloodLeakSelfTestStatus = SELF_TEST_STATUS_PASSED; - } -#endif - return bloodLeakSelfTestStatus; } @@ -524,7 +522,7 @@ BOOL isBloodLeakZeroingNeeded( void ) { BOOL status = FALSE; - DD_OP_MODE_T opMode = getCurrentOperationMode(); + TD_OP_MODE_T opMode = getTDOpMode(); if ( MODE_PRET == opMode ) { @@ -618,12 +616,7 @@ } else { -#ifndef _RELEASE_ - // if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - activateAlarmNoData( ALARM_ID_DD_BLOOD_LEAK_SENSOR_EMBEDDED_MODE_FAILURE ); - } + activateAlarmNoData( ALARM_ID_DD_BLOOD_LEAK_SENSOR_EMBEDDED_MODE_FAILURE ); } } @@ -662,12 +655,7 @@ } else { -#ifndef _RELEASE_ - // if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - activateAlarmNoData( ALARM_ID_DD_BLOOD_LEAK_SENSOR_SET_POINT_SET_FAILURE ); - } + activateAlarmNoData( ALARM_ID_DD_BLOOD_LEAK_SENSOR_SET_POINT_SET_FAILURE ); } } else if ( TRUE == isCommandRespReady ) @@ -840,11 +828,13 @@ bloodLeakStatus.data = getFPGABloodDetectProcessedStatus(); - switch ( getCurrentOperationMode() ) + switch ( getTDOpMode() ) { case MODE_TREA: case MODE_SERV: - if ( ( FALSE == isDialysateLineInBypass() ) && ( getTreatmentState() != TREATMENT_RECIRC_STATE ) && ( getDialysisState() != DIALYSIS_SALINE_BOLUS_STATE ) ) + // TODO uncomment + //if ( ( FALSE == isDialysateLineInBypass() ) && ( getTreatmentState() != TREATMENT_RECIRC_STATE ) && ( getDialysisState() != DIALYSIS_SALINE_BOLUS_STATE ) ) + if ( TRUE ) { if ( BLOOD_LEAK_DETECTED == getBloodLeakStatus() ) { @@ -911,7 +901,7 @@ // Check if the blood is not detected but at the same time the Dialin pump should be running to make sure we are in the // blood recovery state of the treatment stop so the blood detection recovery is not done on the stagnant fluid // NOTE: should we check of the measured flow is about 600 mL/min? - if ( ( BLOOD_LEAK_NOT_DETECTED == getBloodLeakStatus() ) && ( TRUE == isDialInPumpRunning() ) ) + if ( ( BLOOD_LEAK_NOT_DETECTED == getBloodLeakStatus() ) /*&& ( TRUE == isDialInPumpRunning() ) */ ) { if ( TRUE == didTimeout( bloodLeakRecoveryStartTimeMS, BLOOD_LEAK_DETECT_RECOVERY_MIN_TIME_MS ) ) { @@ -1144,7 +1134,8 @@ if ( TRUE == bloodLeakEmbModeHasRxRqstBeenSent ) { // If the read request sequence has been sent already, read the next byte in the buffer and process it - U08 data = getFPGABloodLeakRxFIFODataOut(); + U08 data = getFPGABloodLeakRxFIFODataOut(); + hasCharBeenReceived = TRUE; bloodLeakEmbModeHasRxRqstBeenSent = FALSE; processReceivedEmbModeChar( data ); @@ -1743,8 +1734,9 @@ { BOOL status = TRUE; - status &= ( VALVE_POSITION_C_CLOSE == getValvePosition( VDI ) ? TRUE : FALSE ); - status &= ( VALVE_POSITION_C_CLOSE == getValvePosition( VDO ) ? TRUE : FALSE ); + // TODO uncomment + //status &= ( VALVE_POSITION_C_CLOSE == getValvePosition( VDI ) ? TRUE : FALSE ); + //status &= ( VALVE_POSITION_C_CLOSE == getValvePosition( VDO ) ? TRUE : FALSE ); return status; } @@ -1903,105 +1895,67 @@ return status; } - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - /*********************************************************************//** * @brief - * The testSetBloodLeakDataPublishIntervalOverride function overrides the - * blood leak data publish interval. + * The sendBloodLeakEmbeddedModeCommandResponse function sends out + * the blood leak embedded mode command response. * @details Inputs: none - * @details Outputs: bloodLeakDataPublishInterval - * @param value override blood leak data publish interval with (in ms) - * @return TRUE if override successful, FALSE if not + * @details Outputs: blood leak embedded mode command response msg constructed and queued + * @param cmd: the command its response is being sent + * @param responseLen: the length of the buffer + * @param response: pointer to the response buffer + * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL testSetBloodLeakDataPublishIntervalOverride( U32 value ) +static BOOL sendBloodLeakEmbeddedModeCommandResponse( U08 cmd, U32 responseLen, U08 *responseBuffer ) { + BLOOD_LEAK_EMB_MODE_RESP_T response; BOOL result = FALSE; - if ( TRUE == isTestingActivated() ) - { - U32 intvl = value / TASK_PRIORITY_INTERVAL; - result = TRUE; - bloodLeakDataPublishInterval.ovData = intvl; - bloodLeakDataPublishInterval.override = OVERRIDE_KEY; - } + response.command = cmd; + response.responseLen = responseLen; + memcpy( response.responseBuffer, responseBuffer, responseLen ); + result = sendMessage( MSG_ID_DD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE, COMM_BUFFER_OUT_CAN_PC, (U08*)&response, sizeof( BLOOD_LEAK_EMB_MODE_RESP_T ) ); + return result; } -/*********************************************************************//** - * @brief - * The testResetBloodLeakDataPublishIntervalOverride function resets the override - * of the blood leak data publish interval. - * @details Inputs: none - * @details Outputs: bloodLeakDataPublishInterval - * @return TRUE if override reset successful, FALSE if not + +/************************************************************************* + * TEST SUPPORT FUNCTIONS *************************************************************************/ -BOOL testResetBloodLeakDataPublishIntervalOverride( void ) -{ - BOOL result = FALSE; - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - bloodLeakDataPublishInterval.override = OVERRIDE_RESET; - bloodLeakDataPublishInterval.ovData = bloodLeakDataPublishInterval.ovInitData; - } - - return result; -} - /*********************************************************************//** * @brief - * The testSetBloodLeakStatusOverride function overrides the status - * of the blood leak detector. - * @details Inputs: none - * @details Outputs: bloodLeakStatus - * @param none - * @param status override blood leak detector with this + * The testBloodLeakDataPublishIntervalOverride function overrides the + * bloode leak detector data publish interval. + * @details \b Inputs: none + * @details \b Outputs: bloodLeakDataPublishInterval + * @param message Override message from Dialin which includes the value + * that overrides the blood leak data publish interval * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetBloodLeakStatusOverride( BLOOD_LEAK_STATUS_T status ) +BOOL testBloodLeakDataPublishIntervalOverride( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = u32BroadcastIntervalOverride( message, &bloodLeakDataPublishInterval, TASK_PRIORITY_INTERVAL ); - if ( status < NUM_OF_BLOOD_LEAK_STATUS ) - { - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - bloodLeakStatus.ovData = (U32)status; - bloodLeakStatus.override = OVERRIDE_KEY; - } - } - return result; } /*********************************************************************//** * @brief - * The testResetBloodLeakStatusOverride function resets the override of the - * blood leak detector status. - * @details Inputs: none - * @details Outputs: bloodLeakStatus - * @param none - * @return TRUE if reset successful, FALSE if not + * The testBloodLeakStatusOverride function overrides the + * bloode leak detector status. + * @details \b Inputs: none + * @details \b Outputs: bloodLeakStatus + * @param message Override message from Dialin which includes the value + * that overrides the blood leak status + * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testResetBloodLeakStatusOverride( void ) +BOOL testBloodLeakStatusOverride( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = u32Override( message, &bloodLeakStatus, (U32)BLOOD_LEAK_DETECTED, (U32)NUM_OF_BLOOD_LEAK_STATUS ); - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - bloodLeakStatus.override = OVERRIDE_RESET; - bloodLeakStatus.ovData = bloodLeakStatus.ovInitData; - } - return result; } @@ -2011,24 +1965,21 @@ * embedded more for calibration. * @details Inputs: none * @details Outputs: bloodLeakSignalEmbeddedModeReq + * @param message Override message from Dialin * @return TRUE if switching to embedded mode was accepted otherwise, FALSE *************************************************************************/ -BOOL testSetBloodLeak2EmbeddedMode( void ) +BOOL testSetBloodLeak2EmbeddedMode( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = FALSE; + TD_OP_MODE_T mode = getTDOpMode(); - if ( TRUE == isTestingActivated() ) + // Check if the mode is fault, service or standby before accepting a transition to + // the embedded mode + if ( ( MODE_FAUL == mode ) || ( MODE_SERV == mode ) || ( MODE_STAN == mode ) ) { - DD_OP_MODE_T mode = getCurrentOperationMode(); - - // Check if the mode is fault, service or standby before accepting a transition to - // the embedded mode - if ( ( MODE_FAUL == mode ) || ( MODE_SERV == mode ) || ( MODE_STAN == mode ) ) - { - bloodLeakSignalEmbModeReq = TRUE; - bloodLeakEmbModeRqstedCmd = CS_EMB_MODE_CMD; - result = TRUE; - } + bloodLeakSignalEmbModeReq = TRUE; + bloodLeakEmbModeRqstedCmd = CS_EMB_MODE_CMD; + result = TRUE; } return result; @@ -2040,16 +1991,22 @@ * calibration command. * @details Inputs: none * @details Outputs: bloodLeakEmbModeSetPoint - * @param command the command ID to be sent to blood leak in embedded mode - * @param setpointPayload the set point value that is sent with the set point - * command. This value is 0 with other commands since they do not have a payload + * @param message Override message from Dialin to set the command and the + * setpoint payload value * @return TRUE if the command is accepted otherwise, FALSE *************************************************************************/ -BOOL testSetBloodLeakEmbeddedModeCommand( U08 command, U16 setPointPayload ) +BOOL testSetBloodLeakEmbeddedModeCommand( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = FALSE; + U08* payloadPtr = message->payload; + U08 command; + U16 setPointPayload; - if ( ( TRUE == isTestingActivated() ) && ( command < NUM_OF_EMB_CMDS ) ) + memcpy( &command, payloadPtr, sizeof( U08 ) ); + payloadPtr += sizeof( U08 ); + memcpy( &setPointPayload, payloadPtr, sizeof( U16 ) ); + + if ( command < NUM_OF_EMB_CMDS ) { enqueueEmbModeCmd( command ); @@ -2062,72 +2019,36 @@ /*********************************************************************//** * @brief - * The testSetBloodLeakEmbeddedModeInfoOverride function overrides the + * The testBloodLeakEmbeddedModeInfoOverride function overrides the * blood leak embedded mode info values. * @details Inputs: none * @details Outputs: bloodLeakEmbModeIntensityOverride, * bloodLeakEmbModeDetectOverride - * @param command the command to override its value - * @param value the value that the command is overridden to + * @param message Override message from Dialin to set the command and the + * embedded mode info values * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetBloodLeakEmbeddedModeInfoOverride( U08 command, U32 value ) +BOOL testBloodLeakEmbeddedModeInfoOverride( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = FALSE; + U08* payloadPtr = message->payload; + U08 command; - if ( ( TRUE == isTestingActivated() ) && ( command < NUM_OF_EMB_CMDS ) ) - { - switch( command ) - { - case I_EMB_MODE_CMD: - result = TRUE; - bloodLeakEmbModeIntensityOverride.ovData = value; - bloodLeakEmbModeIntensityOverride.override = OVERRIDE_KEY; - break; + memcpy( &command, payloadPtr, sizeof( U08 ) ); - case V_EMB_MODE_CMD: - result = TRUE; - bloodLeakEmbModeDetectOverride.ovData = value; - bloodLeakEmbModeDetectOverride.override = OVERRIDE_KEY; - break; - - default: - // Do nothing with the rest of the commands. They cannot be overridden. - break; - } - } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetBloodLeakEmbeddedModeInfoOverride function reset the overrides - * of the blood leak embedded mode info values. - * @details Inputs: none - * @details Outputs: bloodLeakEmbModeIntensityOverride, - * bloodLeakEmbModeDetectOverride - * @param command the command to reset its override value - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testResetBloodLeakEmbeddedModeInfoOverride( U08 command ) -{ - BOOL result = FALSE; - - if ( ( TRUE == isTestingActivated() ) && ( command < NUM_OF_EMB_CMDS ) ) + if ( command < NUM_OF_EMB_CMDS ) { + U32 min = 0; + U32 max = 100000; + switch( command ) { case I_EMB_MODE_CMD: - result = TRUE; - bloodLeakEmbModeIntensityOverride.ovData = 0; - bloodLeakEmbModeIntensityOverride.override = OVERRIDE_RESET; + result = u32Override( message, &bloodLeakEmbModeIntensityOverride, min, max ); break; case V_EMB_MODE_CMD: - result = TRUE; - bloodLeakEmbModeDetectOverride.ovData = 0; - bloodLeakEmbModeDetectOverride.override = OVERRIDE_RESET; + result = u32Override( message, &bloodLeakEmbModeDetectOverride, min, max ); break; default: @@ -2141,109 +2062,50 @@ /*********************************************************************//** * @brief - * The testSetBloodLeakIntensityMovingAverageOverride function overrides the + * The testBloodLeakIntensityMovingAverageOverride function overrides the * blood leak intensity moving average. * @details Inputs: none * @details Outputs: bloodLeakZeroingStatus - * @param value intensity moving average + * @param message Override message from Dialin to override the blood leak + * intensity moving average. * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetBloodLeakIntensityMovingAverageOverride( F32 value ) +BOOL testBloodLeakIntensityMovingAverageOverride( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = f32Override( message, &bloodLeakZeroingStatus.intensityMovingAverage ); - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - bloodLeakZeroingStatus.intensityMovingAverage.ovData = value; - bloodLeakZeroingStatus.intensityMovingAverage.override = OVERRIDE_KEY; - } - return result; } /*********************************************************************//** * @brief - * The testResetBloodLeakIntensityMovingAverageOverride function resets the - * override of the blood leak intensity moving average. + * The testBloodLeakZeroingIntervalInMillisecondsOverride function overrides the + * blood leak zeroing interval in milliseconds. * @details Inputs: none - * @details Outputs: bloodLeakZeroingStatus + * @details Outputs: bloodLeakZeroingStatus.zeroingDriftIntervalTimeMS, + * bloodLeakZeroingStatus.zeroingUpperRangeIntervalTimeMS + * @param message Override message from Dialin to override the blood leak + * zeroing interval. * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testResetBloodLeakIntensityMovingAverageOverride( void ) +BOOL testBloodLeakZeroingIntervalInMillisecondsOverride( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = FALSE; + U08* payloadPtr = message->payload; + U32 min = 0; + U32 max = 100000; - if ( TRUE == isTestingActivated() ) - { - result = TRUE; - bloodLeakZeroingStatus.intensityMovingAverage.ovData = bloodLeakZeroingStatus.intensityMovingAverage.ovInitData; - bloodLeakZeroingStatus.intensityMovingAverage.override = OVERRIDE_RESET; - } + BOOL isUpperRangeInterval; - return result; -} + memcpy( &isUpperRangeInterval, payloadPtr, sizeof( BOOL ) ); -/*********************************************************************//** - * @brief - * The testSetBloodLeakZeroingIntervalInMinsOverride function overrides the - * blood leak zeroing interval in minutes. - * @details Inputs: none - * @details Outputs: bloodLeakZeroingStatus - * @param drift check interval or upper range intensity boolean flag - * @param value zeroing interval in minutes - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testSetBloodLeakZeroingIntervalInMinsOverride( BOOL upperRangeInterval, U32 valueMins ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) + if ( FALSE == isUpperRangeInterval ) { - if ( FALSE == upperRangeInterval ) - { - result = TRUE; - bloodLeakZeroingStatus.zeroingDriftIntervalTimeMS.ovData = ( valueMins * SEC_PER_MIN * MS_PER_SECOND ); - bloodLeakZeroingStatus.zeroingDriftIntervalTimeMS.override = OVERRIDE_KEY; - } - else - { - result = TRUE; - bloodLeakZeroingStatus.zeroingUpperRangeIntervalTimeMS.ovData = ( valueMins * SEC_PER_MIN * MS_PER_SECOND ); - bloodLeakZeroingStatus.zeroingUpperRangeIntervalTimeMS.override = OVERRIDE_KEY; - } + result = u32Override( message, &bloodLeakZeroingStatus.zeroingDriftIntervalTimeMS, min, max ); } - - return result; -} - -/*********************************************************************//** - * @brief - * The testResetBloodLeakZeroingIntervalInMinsOverride function resets the - * override of the blood leak zeroing interval - * @details Inputs: none - * @details Outputs: bloodLeakZeroingStatus - * @param boolean flag to indicate to reset upper range interval or the drift - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testResetBloodLeakZeroingIntervalInMinsOverride( BOOL upperRangeInterval ) -{ - BOOL result = FALSE; - - if ( TRUE == isTestingActivated() ) + else { - if ( FALSE == upperRangeInterval ) - { - result = TRUE; - bloodLeakZeroingStatus.zeroingDriftIntervalTimeMS.ovData = bloodLeakZeroingStatus.zeroingDriftIntervalTimeMS.ovInitData; - bloodLeakZeroingStatus.zeroingDriftIntervalTimeMS.override = OVERRIDE_RESET; - } - else - { - result = TRUE; - bloodLeakZeroingStatus.zeroingUpperRangeIntervalTimeMS.ovData = bloodLeakZeroingStatus.zeroingUpperRangeIntervalTimeMS.ovInitData; - bloodLeakZeroingStatus.zeroingUpperRangeIntervalTimeMS.override = OVERRIDE_RESET; - } + result = u32Override( message, &bloodLeakZeroingStatus.zeroingUpperRangeIntervalTimeMS, min, max ); } return result; Index: firmware/App/Monitors/BloodLeak.h =================================================================== diff -u -rbc4537c14a446c8fe1720f574200399b180a6ff9 -r208d9299339c3b89ac7fbd2100eef3aa121bf591 --- firmware/App/Monitors/BloodLeak.h (.../BloodLeak.h) (revision bc4537c14a446c8fe1720f574200399b180a6ff9) +++ firmware/App/Monitors/BloodLeak.h (.../BloodLeak.h) (revision 208d9299339c3b89ac7fbd2100eef3aa121bf591) @@ -55,28 +55,17 @@ void exitBloodLeakNormalState( void ); SELF_TEST_STATUS_T execBloodLeakSelfTest( void ); - BLOOD_LEAK_STATUS_T getBloodLeakStatus( void ); SELF_TEST_STATUS_T getBloodLeakSelfTestStatus( void ); -BOOL testSetBloodLeakDataPublishIntervalOverride( U32 value ); -BOOL testResetBloodLeakDataPublishIntervalOverride( void ); +BOOL testBloodLeakDataPublishIntervalOverride( MESSAGE_T *message ); +BOOL testBloodLeakStatusOverride( MESSAGE_T *message ); +BOOL testSetBloodLeak2EmbeddedMode( MESSAGE_T *message ); +BOOL testSetBloodLeakEmbeddedModeCommand( MESSAGE_T *message ); +BOOL testBloodLeakEmbeddedModeInfoOverride( MESSAGE_T *message ); +BOOL testBloodLeakIntensityMovingAverageOverride( MESSAGE_T *message ); +BOOL testBloodLeakZeroingIntervalInMillisecondsOverride( MESSAGE_T *message ); -BOOL testSetBloodLeakStatusOverride( BLOOD_LEAK_STATUS_T status ); -BOOL testResetBloodLeakStatusOverride( void ); - -BOOL testSetBloodLeak2EmbeddedMode( void ); -BOOL testSetBloodLeakEmbeddedModeCommand( U08 command, U16 setPointPayload ); - -BOOL testSetBloodLeakEmbeddedModeInfoOverride( U08 command, U32 value ); -BOOL testResetBloodLeakEmbeddedModeInfoOverride( U08 command ); - -BOOL testSetBloodLeakIntensityMovingAverageOverride( F32 value ); -BOOL testResetBloodLeakIntensityMovingAverageOverride( void ); - -BOOL testSetBloodLeakZeroingIntervalInMinsOverride( BOOL upperRangeInterval, U32 valueMins ); -BOOL testResetBloodLeakZeroingIntervalInMinsOverride( BOOL upperRangeInterval ); - /**@}*/ #endif Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -r333e2d0c0462dcb4343a279420949cce716ebab7 -r208d9299339c3b89ac7fbd2100eef3aa121bf591 --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 333e2d0c0462dcb4343a279420949cce716ebab7) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 208d9299339c3b89ac7fbd2100eef3aa121bf591) @@ -3080,4 +3080,97 @@ return status; } +// Blood leak functions +/*********************************************************************//** + * @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 = 0; //(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: none + * @details Outputs: fpgaActuatorSetPoints + * @return none + *************************************************************************/ +void setFPGABloodLeakUARTControl( U08 value ) +{ + fpgaActuatorSetPoints.fpgaD42UARTControl = value; +} + +/*********************************************************************//** + * @brief + * The setFPGABloodLeakUARTTransmit function sets the blood leak sensor UART + * transmit value. + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints + * @return none + *************************************************************************/ +void setFPGABloodLeakUARTTransmit( U08 value ) +{ + fpgaActuatorSetPoints.fpgaD42FIFOTx = value; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodLeakTxFIFOCount function returns the blood leak transmit + * FIFO count. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return fpgaSensorReadings.fpgaD42TxFIFOCnt + *************************************************************************/ +U08 getFPGABloodLeakTxFIFOCount( void ) +{ + return fpgaSensorReadings.fpgaD42TxFIFOCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodLeakRxFIFOCount function returns the blood leak receive + * FIFO count. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return fpgaSensorReadings.fpgaD42RxFIFOCnt + *************************************************************************/ +U16 getFPGABloodLeakRxFIFOCount( void ) +{ + return fpgaSensorReadings.fpgaD42RxFIFOCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodLeakRxErrorCount function returns the blood leak receive + * error count. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return fpgaSensorReadings.fpgaD42RxErrorCnt + *************************************************************************/ +U08 getFPGABloodLeakRxErrorCount( void ) +{ + return fpgaSensorReadings.fpgaD42RxErrorCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodLeakRxFIFODataOut function returns the blood leak receive + * FIFO data out. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return fpgaSensorReadings.fpgaD42RxFIFODataOut + *************************************************************************/ +U08 getFPGABloodLeakRxFIFODataOut( void ) +{ + return fpgaSensorReadings.fpgaD42RxFIFODataOut; +} + /**@}*/ Index: firmware/App/Services/FpgaDD.h =================================================================== diff -u -r3cc784af591b14e5d292f92c796db70bcbd5a40b -r208d9299339c3b89ac7fbd2100eef3aa121bf591 --- firmware/App/Services/FpgaDD.h (.../FpgaDD.h) (revision 3cc784af591b14e5d292f92c796db70bcbd5a40b) +++ firmware/App/Services/FpgaDD.h (.../FpgaDD.h) (revision 208d9299339c3b89ac7fbd2100eef3aa121bf591) @@ -255,6 +255,15 @@ void setFPGAD5HeaterPWMLowState( U16 count ); void setFPGAD5HeaterPWMPeriod( U16 period ); +//Blood leak detector +U08 getFPGABloodLeakStatus( void ); +void setFPGABloodLeakUARTControl( U08 value ); +void setFPGABloodLeakUARTTransmit( U08 value ); +U08 getFPGABloodLeakTxFIFOCount( void ); +U16 getFPGABloodLeakRxFIFOCount( void ); +U08 getFPGABloodLeakRxErrorCount( void ); +U08 getFPGABloodLeakRxFIFODataOut( void ); + /**@}*/ #endif Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r25dbc6221b63e20fe61b2af0ce9c9f56bf13e807 -r208d9299339c3b89ac7fbd2100eef3aa121bf591 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 25dbc6221b63e20fe61b2af0ce9c9f56bf13e807) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 208d9299339c3b89ac7fbd2100eef3aa121bf591) @@ -19,6 +19,7 @@ #include "reg_system.h" #include "BalancingChamber.h" +#include "BloodLeak.h" #include "Conductivity.h" #include "Compatible.h" #include "ConcentratePumps.h" @@ -163,6 +164,13 @@ { MSG_ID_FW_VERSIONS_REQUEST, &handleVersionRequestMessage }, { MSG_ID_DD_SAFETY_SHUTDOWN_OVERRIDE_REQUEST, &testSetResetSafetyShutdownOverride }, { MSG_ID_DD_UF_DATA_PUBLISH_OVERRIDE_REQUEST, &testDDUFDataPublishIntervalOverride }, + { MSG_ID_DD_BLOOD_LEAK_DATA_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testBloodLeakDataPublishIntervalOverride }, + { MSG_ID_DD_BLOOD_LEAK_STATUS_OVERRIDE_REQUEST, &testBloodLeakStatusOverride }, + { MSG_ID_DD_BLOOD_LEAK_SET_TO_EMBEDDED_MODE_REQUEST, &testSetBloodLeak2EmbeddedMode }, + { MSG_ID_DD_BLOOD_LEAK_SET_EMBEDDED_MODE_CMD_REQUEST, &testSetBloodLeakEmbeddedModeCommand }, + { MSG_ID_DD_BLOOD_LEAK_EMBEDDED_MODE_INFO_OVERRIDE_REQUEST, &testBloodLeakEmbeddedModeInfoOverride }, + { MSG_ID_DD_BLOOD_LEAK_INTENSITY_MOVING_AVERAGE_OVERRIDE_REQUEST, &testBloodLeakIntensityMovingAverageOverride }, + { MSG_ID_DD_BLOOD_LEAK_ZEROING_INTERVAL_IN_MS_OVERRIDE_REQUEST, &testBloodLeakZeroingIntervalInMillisecondsOverride }, #ifdef __PUMPTEST__ { MSG_ID_DD_PISTON_PUMP_DATA_PUBLISH_OVERRIDE_REQUEST, &testDDPistonPumpControlDataPublishIntervalOverride }, { MSG_ID_DD_PISTON_PUMP_START_STOP_OVERRIDE_REQUEST, &testDDPistonPumpStartStopOverride }, Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -ra9983d3e6b07e7c927fab3d16e80b715594fe221 -r208d9299339c3b89ac7fbd2100eef3aa121bf591 --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision a9983d3e6b07e7c927fab3d16e80b715594fe221) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 208d9299339c3b89ac7fbd2100eef3aa121bf591) @@ -17,6 +17,7 @@ #include "gio.h" +#include "BloodLeak.h" #include "Conductivity.h" #include "DialysatePumps.h" #include "FPGA.h" @@ -91,6 +92,12 @@ // Dialysate generation monitor execGenDialysateMonitor(); + // Exec blood leak embedded mode + execBloodLeakEmbModeCommand(); + + // Blood leak sensor + execBloodLeak(); + // Second pass for FPGA execFPGA( FALSE ); #endif