Index: firmware/App/Common.h =================================================================== diff -u -r9864b14f76782f1e68bf266dcd843451748715a0 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Common.h (.../Common.h) (revision 9864b14f76782f1e68bf266dcd843451748715a0) +++ firmware/App/Common.h (.../Common.h) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -23,7 +23,7 @@ #ifndef _VECTORCAST_ // #define RM46_EVAL_BOARD_TARGET 1 - #define ACK_IMPLEMENTED 1 +// #define ACK_IMPLEMENTED 1 // #define SIMULATE_UI 1 #define DEBUG_ENABLED 1 Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r9864b14f76782f1e68bf266dcd843451748715a0 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 9864b14f76782f1e68bf266dcd843451748715a0) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -622,14 +622,13 @@ F32 measMCSpd = getMeasuredBloodPumpMCSpeed(); F32 measMCCurr = getMeasuredBloodPumpMCCurrent(); F32 pumpPWMPctDutyCycle = bloodPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; -#ifdef DEBUG_ENABLED - // TODO - temporary debug code - remove later - F32 x = getFPGADialysateInletOcclusion(); +//#ifdef DEBUG_ENABLED +// // TODO - temporary debug code - remove later // char debugFlowStr[ 256 ]; - +// // sprintf( debugFlowStr, "Blood Set Pt.:%5d, Meas. Flow:%5d, Speed:%5d RPM, Current:%5d mA, PWM:%5d \n", flowStPt, (S32)measFlow, (S32)measMCSpd, (S32)measMCCurr, (S32)pumpPWMPctDutyCycle ); // sendDebugData( (U08*)debugFlowStr, strlen(debugFlowStr) ); -#endif +//#endif broadcastBloodFlowData( flowStPt, measFlow, measRotSpd, measSpd, measMCSpd, measMCCurr, pumpPWMPctDutyCycle ); bloodFlowDataPublicationTimerCounter = 0; } Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u --- firmware/App/Controllers/PresOccl.c (revision 0) +++ firmware/App/Controllers/PresOccl.c (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -0,0 +1,512 @@ +/************************************************************************** + * + * Copyright (c) 2020 Diality Inc. - All Rights Reserved. + * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * @file BloodFlow.c + * + * @date 15-Jan-2020 + * @author S. Nash + * + * @brief Monitor for pressure and occlusion sensors. + * + **************************************************************************/ + +#include "PresOccl.h" +#include "AlarmMgmt.h" +#include "FPGA.h" +#include "OperationModes.h" +#include "SystemCommMessages.h" +#include "TaskGeneral.h" +#include "Timers.h" + +// ********** private definitions ********** + +#define PRES_OCCL_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) // interval (ms/task time) at which the pressure/occlusion data is published on the CAN bus + +typedef enum PresOccl_States +{ + PRESSURE_INIT_STATE = 0, + PRESSURE_CONTINUOUS_READ_STATE, + NUM_OF_PRESSURE_STATES +} PRESSURE_STATE_T; + +typedef enum PresOccl_Self_Test_States +{ + PRESSURE_SELF_TEST_STATE_START = 0, + PRESSURE_TEST_STATE_IN_PROGRESS, + PRESSURE_FLOW_TEST_STATE_COMPLETE, + NUM_OF_PRESSURE_SELF_TEST_STATES +} PRESSURE_SELF_TEST_STATE_T; + +// ********** private data ********** + +static PRESSURE_STATE_T presOcclState = PRESSURE_INIT_STATE; // current state of blood flow controller state machine +static U32 presOcclDataPublicationTimerCounter = 0; // used to schedule blood flow data publication to CAN bus + +DATA_DECL( U32, PresOcclDataPub, presOcclDataPublishInterval, PRES_OCCL_DATA_PUB_INTERVAL, PRES_OCCL_DATA_PUB_INTERVAL ); // interval (in ms) at which to publish pressure/occlusion data to CAN bus +DATA_DECL( F32, ArterialPressure, arterialPressure, 0, 0 ); // requested blood flow rate +DATA_DECL( F32, VenousPressure, venousPressure, 0.0, 0.0 ); // measured blood flow rate +DATA_DECL( F32, BloodPumpOcclusion, bloodPumpOcclusion, 0.0, 0.0 ); // measured blood pump rotor speed +DATA_DECL( F32, DialInPumpOcclusion, dialInPumpOcclusion, 0.0, 0.0 ); // measured blood pump motor speed +DATA_DECL( F32, DialOutPumpOcclusion, dialOutPumpOcclusion, 0.0, 0.0 ); // measured blood pump motor controller speed + +static PRESSURE_SELF_TEST_STATE_T presOcclSelfTestState = PRESSURE_SELF_TEST_STATE_START; // current blood pump self test state +static U32 bloodPumpSelfTestTimerCount = 0; // timer counter for blood pump self test + +static F32 arterialPressureLowLimitmmHG = 0.0; // lower alarm limit for arterial pressure +static F32 arterialPressureHighLimitmmHG = 0.0; // upper alarm limit for arterial pressure +static F32 venousPressureLowLimitmmHG = 0.0; // lower alarm limit for venous pressure +static F32 venousPressureHighLimitmmHG = 0.0; // upper alarm limit for venous pressure +static F32 bloodPumpOcclusionPressureThresholdmmHG = 50.0; // pressure threshold for blood pump occlusion // TODO - set thresholds for occlusions +static F32 dialInPumpOcclusionPressureThresholdmmHG = 50.0; // pressure threshold for dialysate inlet pump occlusion +static F32 dialOutPumpOcclusionPressureThresholdmmHG = 50.0; // pressure threshold for dialysate outlet pump occlusion + +// ********** private function prototypes ********** + +static PRESSURE_STATE_T handlePresOcclInitState( void ); +static PRESSURE_STATE_T handlePresOcclContReadState( void ); +static void checkOcclusions( void ); +static void publishPresOcclData( void ); +static DATA_GET_PROTOTYPE( U32, getPublishPresOcclDataInterval ); + +/************************************************************************* + * @brief initPresOccl + * The initPresOccl function initializes the initPresOccl module. + * @details + * Inputs : none + * Outputs : initPresOccl module initialized. + * @param none + * @return none + *************************************************************************/ +void initPresOccl( void ) +{ + // TODO - anything to initialize? +} + +/************************************************************************* + * @brief setPressureLimits + * The setPressureLimits function sets the lower and upper alarm limits \n + * for a given pressure sensor. + * @details + * Inputs : none + * Outputs : pressure limits + * @param sensor : pressure sensor we are setting limits for + * @param low : lower alarm limit (mmHg) + * @param high : upper alarm limit (mmHg) + * @return none + *************************************************************************/ +void setPressureLimits( PRESSURE_SENSORS_T sensor, F32 low, F32 high ) +{ + switch ( sensor ) // TODO - will low/high limits be range checked by caller or should we do it here? what are valid ranges? + { + case PRESSURE_SENSOR_ARTERIAL: + arterialPressureLowLimitmmHG = low; + arterialPressureHighLimitmmHG = high; + break; + + case PRESSURE_SENSOR_VENOUS: + venousPressureLowLimitmmHG = low; + venousPressureHighLimitmmHG = high; + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_PRES_OCCL_INVALID_PRES_SENSOR, sensor ) + break; + } +} + +/************************************************************************* + * @brief setOcclusionThreshold + * The setOcclusionThreshold function sets the occlusion pressure threshold \n + * for a given occlusion sensor. + * @details + * Inputs : none + * Outputs : pressure threshold + * @param sensor : occlusion sensor we are setting threshold for + * @param threshold : pressure threshold above which indicates an occlusion (mmHg) + * @return none + *************************************************************************/ +void setOcclusionThreshold( OCCLUSION_SENSORS_T sensor, F32 threshold ) +{ + switch ( sensor ) // TODO - will threshold be range checked by caller or should we do it here? what is valid range? + { + case OCCLUSION_SENSOR_BLOOD_PUMP: + bloodPumpOcclusionPressureThresholdmmHG = threshold; + break; + + case OCCLUSION_SENSOR_DIAL_IN_PUMP: + dialInPumpOcclusionPressureThresholdmmHG = threshold; + break; + + case OCCLUSION_SENSOR_DIAL_OUT_PUMP: + dialOutPumpOcclusionPressureThresholdmmHG = threshold; + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_PRES_OCCL_INVALID_OCCL_SENSOR, sensor ) + break; + } +} + +/************************************************************************* + * @brief execPresOccl + * The execPresOccl function executes the pressure and occlusion monitor. + * @details + * Inputs : presOcclState + * Outputs : presOcclState + * @param none + * @return none + *************************************************************************/ +void execPresOccl( void ) +{ + // state machine + switch ( presOcclState ) + { + case PRESSURE_INIT_STATE: + presOcclState = handlePresOcclInitState(); + break; + + case PRESSURE_CONTINUOUS_READ_STATE: + presOcclState = handlePresOcclContReadState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_PRES_OCCL_INVALID_STATE, presOcclState ) + break; + } + + // publish pressure/occlusion data on interval + publishPresOcclData(); +} + +/************************************************************************* + * @brief handlePresOcclInitState + * The handlePresOcclInitState function handles the pres/occl initialize state \n + * of the pressure/occlusion monitor state machine. + * @details + * Inputs : TBD + * Outputs : TBD + * @param none + * @return next state + *************************************************************************/ +static PRESSURE_STATE_T handlePresOcclInitState( void ) +{ + PRESSURE_STATE_T result = PRESSURE_CONTINUOUS_READ_STATE; + + return result; +} + +/************************************************************************* + * @brief handlePresOcclContReadState + * The handlePresOcclContReadState function handles the continuous read state \n + * of the pressure/occlusion monitor state machine. + * @details + * Inputs : TBD + * Outputs : pressure sensor values updated + * @param none + * @return next state + *************************************************************************/ +static PRESSURE_STATE_T handlePresOcclContReadState( void ) +{ + PRESSURE_STATE_T result = PRESSURE_CONTINUOUS_READ_STATE; + + U16 artPres = getFPGAArterialPressure(); + U16 venPres = getFPGAVenousPressure(); + U16 bldOccl = getFPGABloodPumpOcclusion(); + U16 dliOccl = getFPGADialInPumpOcclusion(); + U16 dloOccl = getFPGADialOutPumpOcclusion(); + + // TODO - convert ADC counts to mmHg for each sensor + arterialPressure.data = (F32)artPres; + venousPressure.data = (F32)venPres; + bloodPumpOcclusion.data = (F32)bldOccl; + dialInPumpOcclusion.data = (F32)dliOccl; + dialOutPumpOcclusion.data = (F32)dloOccl; + + // TODO - any filtering required??? + + // check for occlusions + checkOcclusions(); + + // TODO - any other checks + + return result; +} + +/************************************************************************* + * @brief checkPressureLimits + * The checkPressureLimits function gets the pressure/occlusion data \n + * publication interval. + * @details + * Inputs : occlusion pressures for the pumps + * Outputs : + * @param none + * @return none + *************************************************************************/ +static void checkOcclusions( void ) +{ + F32 bpOccl = getMeasuredBloodPumpOcclusion(); + F32 diOccl = getMeasuredDialInPumpOcclusion(); + F32 doOccl = getMeasuredDialOutPumpOcclusion(); + + if ( bpOccl > bloodPumpOcclusionPressureThresholdmmHG ) + { + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_OCCLUSION_BLOOD_PUMP, bpOccl ) + // TODO - stop blood pump immediately, ... + } + if ( diOccl > dialInPumpOcclusionPressureThresholdmmHG ) + { + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_OCCLUSION_DIAL_IN_PUMP, diOccl ) + // TODO - stop dialysate inlet pump immediately, ... + } + if ( doOccl > dialOutPumpOcclusionPressureThresholdmmHG ) + { + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_OCCLUSION_DIAL_OUT_PUMP, doOccl ) + // TODO - stop dialysate outlet pump immediately, ... + } +} + +/************************************************************************* + * @brief getPublishPresOcclDataInterval + * The getPublishPresOcclDataInterval function gets the pressure/occlusion data \n + * publication interval. + * @details + * Inputs : presOcclDataPublishInterval + * Outputs : none + * @param none + * @return the current pressure/occlusion data publication interval (in ms). + *************************************************************************/ +DATA_GET( U32, getPublishPresOcclDataInterval, presOcclDataPublishInterval ) + +/************************************************************************* + * @brief getMeasuredArterialPressure + * The getMeasuredArterialPressure function gets the current arterial pressure. + * @details + * Inputs : arterialPressure + * Outputs : none + * @param none + * @return the current arterial pressure (in mmHg). + *************************************************************************/ +DATA_GET( F32, getMeasuredArterialPressure, arterialPressure ) + +/************************************************************************* + * @brief getMeasuredVenousPressure + * The getMeasuredVenousPressure function gets the measured venous pressure. + * @details + * Inputs : venousPressure + * Outputs : none + * @param none + * @return the current venous pressure (in mmHg). + *************************************************************************/ +DATA_GET( F32, getMeasuredVenousPressure, venousPressure ) + +/************************************************************************* + * @brief getMeasuredBloodPumpOcclusion + * The getMeasuredBloodPumpOcclusion function gets the measured blood pump \n + * occlusion pressure. + * @details + * Inputs : bloodPumpOcclusion + * Outputs : none + * @param none + * @return the current blood pump occlusion pressure (in mmHg). + *************************************************************************/ +DATA_GET( F32, getMeasuredBloodPumpOcclusion, bloodPumpOcclusion ) + +/************************************************************************* + * @brief getMeasuredDialInPumpOcclusion + * The getMeasuredDialInPumpOcclusion function gets the measured dialysate \n + * inlet pump occlusion pressure. + * @details + * Inputs : dialInPumpOcclusion + * Outputs : none + * @param none + * @return the current dialysis inlet pump occlusion pressure (in mmHg). + *************************************************************************/ +DATA_GET( F32, getMeasuredDialInPumpOcclusion, dialInPumpOcclusion ) + +/************************************************************************* + * @brief getMeasuredDialOutPumpOcclusion + * The getMeasuredDialOutPumpOcclusion function gets the measured dialysate \n + * outlet pump occlusion pressure. + * @details + * Inputs : dialOutPumpOcclusion + * Outputs : none + * @param none + * @return the current dialysis outlet pump occlusion pressure (in mmHg). + *************************************************************************/ +DATA_GET( F32, getMeasuredDialOutPumpOcclusion, dialOutPumpOcclusion ) + +/************************************************************************* + * @brief publishPresOcclData + * The publishPresOcclData function publishes pressure/occlusion data at the \n + * set interval. + * @details + * Inputs : TBD + * Outputs : Pressure/occlusion data are published to CAN bus. + * @param none + * @return none + *************************************************************************/ +static void publishPresOcclData( void ) +{ + // publish pressure/occlusion data on interval + if ( ++presOcclDataPublicationTimerCounter > getPublishPresOcclDataInterval() ) + { + F32 artPres = getMeasuredArterialPressure(); + F32 venPres = getMeasuredVenousPressure(); + F32 bpOccl = getMeasuredBloodPumpOcclusion(); + F32 diOccl = getMeasuredDialInPumpOcclusion(); + F32 doOccl = getMeasuredDialOutPumpOcclusion(); + + broadcastPresOcclData( artPres, venPres, bpOccl, diOccl, doOccl ); + presOcclDataPublicationTimerCounter = 0; + } +} + +/************************************************************************* + * @brief execPresOcclTest + * The execPresOcclTest function executes the state machine for the \n + * PresOccl self test. + * @details + * Inputs : none + * Outputs : none + * @param none + * @return the current state of the PresOccl self test. + *************************************************************************/ +SELF_TEST_STATUS_T execPresOcclTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED; + + // TODO - implement self test(s) + + return result; +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/************************************************************************* + * @brief testSetPresOcclDataPublishIntervalOverride + * The testSetPresOcclDataPublishIntervalOverride function overrides the \n + * pressure and occlusion data publish interval. + * @details + * Inputs : none + * Outputs : presOcclDataPublishInterval + * @param value : override pressure and occlusion data publish interval with (in ms) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetPresOcclDataPublishIntervalOverride( U32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + U32 intvl = value / TASK_GENERAL_INTERVAL; + + result = TRUE; + presOcclDataPublishInterval.ovData = intvl; + presOcclDataPublishInterval.override = OVERRIDE_KEY; + } + + return result; +} + +/************************************************************************* + * @brief testResetPresOcclDataPublishIntervalOverride + * The testResetPresOcclDataPublishIntervalOverride function resets the override \n + * of the pressure and occlusion data publish interval. + * @details + * Inputs : none + * Outputs : presOcclDataPublishInterval + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetPresOcclDataPublishIntervalOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + presOcclDataPublishInterval.override = OVERRIDE_RESET; + presOcclDataPublishInterval.ovData = presOcclDataPublishInterval.ovInitData; + } + + return result; +} + +/************************************************************************* + * @brief testSetArterialPressureOverride and testResetArterialPressureOverride + * The testSetArterialPressureOverride function overrides the measured arterial \n + * pressure. + * The testResetArterialPressureOverride function resets the override of the \n + * arterial pressure. + * @details + * Inputs : none + * Outputs : arterialPressure + * @param value : override arterial pressure (in mmHg) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +DATA_OVERRIDE_FUNC( F32, testSetArterialPressureOverride, testResetArterialPressureOverride, arterialPressure ) + +/************************************************************************* + * @brief testSetVenousPressureOverride and testResetVenousPressureOverride + * The testSetVenousPressureOverride function overrides the measured venous \n + * pressure. + * The testResetVenousPressureOverride function resets the override of the \n + * venous pressure. + * @details + * Inputs : none + * Outputs : venousPressure + * @param value : override measured vensous pressure with (in mmHg) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +DATA_OVERRIDE_FUNC( F32, testSetVenousPressureOverride, testResetVenousPressureOverride, venousPressure ) + +/************************************************************************* + * @brief testSetBloodPumpOcclusionOverride and testResetBloodPumpOcclusionOverride + * The testSetBloodPumpOcclusionOverride function overrides the measured \n + * blood pump occlusion pressure. \n + * The testResetBloodPumpOcclusionOverride function resets the override of the \n + * measured blood pump occlusion pressure. + * @details + * Inputs : none + * Outputs : bloodPumpOcclusion + * @param value : override measured blood pump occlusion pressure with (in mmHg) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +DATA_OVERRIDE_FUNC( F32, testSetBloodPumpOcclusionOverride, testResetBloodPumpOcclusionOverride, bloodPumpOcclusion ) + +/************************************************************************* + * @brief testSetDialInPumpOcclusionOverride and testResetDialInPumpOcclusionOverride + * The testSetDialInPumpOcclusionOverride function overrides the measured \n + * dialysate inlet pump occlusion pressure. \n + * The testResetDialInPumpOcclusionOverride function resets the override of the \n + * measured dialysate inlet pump occlusion pressure. + * @details + * Inputs : none + * Outputs : dialInPumpOcclusion + * @param value : override measured dialysate inlet pump occlusion pressure (in mmHg) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +DATA_OVERRIDE_FUNC( F32, testSetDialInPumpOcclusionOverride, testResetDialInPumpOcclusionOverride, dialInPumpOcclusion ) + +/************************************************************************* + * @brief testSetDialOutPumpOcclusionOverride and testResetDialOutPumpOcclusionOverride + * The testSetDialOutPumpOcclusionOverride function overrides the measured \n + * dialysate outlet pump occlusion pressure. \n + * The testResetDialOutPumpOcclusionOverride function resets the override of the \n + * measured dialysate outlet pump occlusion pressure. + * @details + * Inputs : none + * Outputs : dialOutPumpOcclusion + * @param value : override measured dialysate outlet pump occlusion pressure (in mmHg) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +DATA_OVERRIDE_FUNC( F32, testSetDialOutPumpOcclusionOverride, testResetDialOutPumpOcclusionOverride, dialOutPumpOcclusion ) + + Index: firmware/App/Controllers/PresOccl.h =================================================================== diff -u --- firmware/App/Controllers/PresOccl.h (revision 0) +++ firmware/App/Controllers/PresOccl.h (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -0,0 +1,68 @@ +/************************************************************************** + * + * Copyright (c) 2020 Diality Inc. - All Rights Reserved. + * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * @file PresOccl.h + * + * @date 15-Jan-2020 + * @author S. Nash + * + * @brief PresOccl header file. + * + **************************************************************************/ + +#ifndef __PRESSURE_OCCLUSION_H__ +#define __PRESSURE_OCCLUSION_H__ + +#include "Common.h" + +// ********** public definitions ********** + +typedef enum PressureSensors +{ + PRESSURE_SENSOR_ARTERIAL = 0, + PRESSURE_SENSOR_VENOUS, + NUM_OF_PRESSURE_SENSORS +} PRESSURE_SENSORS_T; + +typedef enum OcclusionSensors +{ + OCCLUSION_SENSOR_BLOOD_PUMP = 0, + OCCLUSION_SENSOR_DIAL_IN_PUMP, + OCCLUSION_SENSOR_DIAL_OUT_PUMP, + NUM_OF_OCCLUSION_SENSORS +} OCCLUSION_SENSORS_T; + +// ********** public function prototypes ********** + +void initPresOccl( void ); +void execPresOccl( void ); + +void setPressureLimits( PRESSURE_SENSORS_T sensor, F32 low, F32 high ); +void setOcclusionThreshold( OCCLUSION_SENSORS_T sensor, F32 threshold ); + +SELF_TEST_STATUS_T execPresOcclTest( void ); + +DATA_GET_PROTOTYPE( F32, getMeasuredArterialPressure ); +DATA_GET_PROTOTYPE( F32, getMeasuredVenousPressure); +DATA_GET_PROTOTYPE( F32, getMeasuredBloodPumpOcclusion ); +DATA_GET_PROTOTYPE( F32, getMeasuredDialInPumpOcclusion ); +DATA_GET_PROTOTYPE( F32, getMeasuredDialOutPumpOcclusion ); + +BOOL testSetPresOcclDataPublishIntervalOverride( U32 value ); +BOOL testResetPresOcclDataPublishIntervalOverride( void ); +BOOL testSetArterialPressureOverride( F32 value ); +BOOL testResetArterialPressureOverride( void ); +BOOL testSetVenousPressureOverride( F32 value ); +BOOL testResetVenousPressureOverride( void ); +BOOL testSetBloodPumpOcclusionOverride( F32 value ); +BOOL testResetBloodPumpOcclusionOverride( void ); +BOOL testSetDialInPumpOcclusionOverride( F32 value ); +BOOL testResetDialInPumpOcclusionOverride( void ); +BOOL testSetDialOutPumpOcclusionOverride( F32 value ); +BOOL testResetDialOutPumpOcclusionOverride( void ); + +#endif Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u --- firmware/App/Modes/Dialysis.c (revision 0) +++ firmware/App/Modes/Dialysis.c (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -0,0 +1,63 @@ +/************************************************************************** + * + * Copyright (c) 2020 Diality Inc. - All Rights Reserved. + * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * @file Dialysis.c + * + * @date 15-Jan-2020 + * @author S. Nash + * + * @brief State machine for the dialysis sub-mode of treatment mode. + * + **************************************************************************/ + +#include "Dialysis.h" +#include "OperationModes.h" +#include "ModeTreatment.h" + +// ********** private data ********** + +// ********** private function prototypes ********** + +/************************************************************************* + * @brief initDialysis + * The initDialysis function initializes the Dialysis module. + * @details + * Inputs : none + * Outputs : Dialysis module initialized. + * @param none + * @return none + *************************************************************************/ +void initDialysis( void ) +{ +} + +/************************************************************************* + * @brief transitionToDialysis + * The transitionToDialysis function prepares for transition to dialysis sub-mode. + * @details + * Inputs : none + * Outputs : + * @param none + * @return none + *************************************************************************/ +void transitionToDialysis( void ) +{ +} + +/************************************************************************* + * @brief execDialysis + * The execDialysis function executes the Dialysis sub-mode state machine. + * @details + * Inputs : none + * Outputs : + * @param none + * @return none + *************************************************************************/ +void execDialysis( void ) +{ +} + Index: firmware/App/Modes/Dialysis.h =================================================================== diff -u --- firmware/App/Modes/Dialysis.h (revision 0) +++ firmware/App/Modes/Dialysis.h (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -0,0 +1,26 @@ +/************************************************************************** + * + * Copyright (c) 2020 Diality Inc. - All Rights Reserved. + * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * @file Dialysis.h + * + * @date 15-Jan-2020 + * @author S. Nash + * + * @brief Header file for Dialysis sub-mode. + * + **************************************************************************/ + +#ifndef __DIALYSIS_H__ +#define __DIALYSIS_H__ + +// ********** private function prototypes ********** + +void initDialysis( void ); // initialize this module +void transitionToDialysis( void ); // prepares for transition to dialysis sub-mode +void execDialysis( void ); // execute the dialysis sub-mode state machine (call from ModeTreatment) + +#endif Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u --- firmware/App/Modes/TreatmentStop.c (revision 0) +++ firmware/App/Modes/TreatmentStop.c (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -0,0 +1,65 @@ +/************************************************************************** + * + * Copyright (c) 2020 Diality Inc. - All Rights Reserved. + * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * @file TreatmentStop.c + * + * @date 15-Jan-2020 + * @author S. Nash + * + * @brief State machine for the treatment stop sub-mode of treatment mode. + * + **************************************************************************/ + +#include "TreatmentStop.h" +#include "OperationModes.h" +#include "ModeTreatment.h" + +// ********** private data ********** + +// ********** private function prototypes ********** + +/************************************************************************* + * @brief initTreatmentStop + * The initTreatmentStop function initializes the Treatment Mode module. + * @details + * Inputs : none + * Outputs : Treatment Mode module initialized. + * @param none + * @return none + *************************************************************************/ +void initTreatmentStop( void ) +{ +} + +/************************************************************************* + * @brief transitionToTreatmentStop + * The transitionToTreatmentStop function prepares for transition to treatment \n + * stop sub-mode. + * @details + * Inputs : none + * Outputs : + * @param none + * @return none + *************************************************************************/ +void transitionToTreatmentStop( void ) +{ +} + +/************************************************************************* + * @brief execTreatmentStop + * The execTreatmentStop function executes the Treatment Stop sub-mode \n + * state machine. + * @details + * Inputs : none + * Outputs : + * @param none + * @return none + *************************************************************************/ +void execTreatmentStop( void ) +{ +} + Index: firmware/App/Modes/TreatmentStop.h =================================================================== diff -u --- firmware/App/Modes/TreatmentStop.h (revision 0) +++ firmware/App/Modes/TreatmentStop.h (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -0,0 +1,26 @@ +/************************************************************************** + * + * Copyright (c) 2020 Diality Inc. - All Rights Reserved. + * + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * @file TreatmentStop.h + * + * @date 15-Jan-2020 + * @author S. Nash + * + * @brief Header file for Treatment Stop sub-mode. + * + **************************************************************************/ + +#ifndef __TREATMENT_STOP_H__ +#define __TREATMENT_STOP_H__ + +// ********** private function prototypes ********** + +void initTreatmentStop( void ); // initialize this module +void transitionToTreatmentStop( void ); // prepares for transition to treatment stop sub-mode +void execTreatmentStop( void ); // execute the treatment stop sub-mode state machine (call from ModeTreatment) + +#endif Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -rfef7e8ec54aea7e7dc447b6240796013cc086604 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision fef7e8ec54aea7e7dc447b6240796013cc086604) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -81,7 +81,14 @@ { ALARM_PRIORITY_MEDIUM, ALM_ESC_1_MIN, ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RESUME, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_BLOOD_SITTING_WARNING { ALARM_PRIORITY_MEDIUM, ALM_ESC_5_MIN, ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RINSEBACK, FALSE, TRUE , FALSE, TRUE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RESUME { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, FALSE, TRUE , FALSE, TRUE, TRUE, FALSE, FALSE, FALSE }, // ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RINSEBACK - { ALARM_PRIORITY_HIGH, 0, ALARM_ID_BLOOD_SITTING_WARNING, TRUE, TRUE , TRUE, TRUE, TRUE, TRUE, TRUE, FALSE }, // ALARM_ID_CAN_MESSAGE_NOT_ACKED + { ALARM_PRIORITY_HIGH, 0, ALARM_ID_NO_ALARM, TRUE, TRUE , TRUE, TRUE, TRUE, TRUE, TRUE, FALSE }, // ALARM_ID_CAN_MESSAGE_NOT_ACKED + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_OCCLUSION_BLOOD_PUMP + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_OCCLUSION_DIAL_IN_PUMP + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_OCCLUSION_DIAL_OUT_PUMP + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_ARTERIAL_PRESSURE_LOW + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_ARTERIAL_PRESSURE_HIGH + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_VENOUS_PRESSURE_LOW + { ALARM_PRIORITY_HIGH, ALM_ESC_4_MIN, ALARM_ID_BLOOD_SITTING_WARNING, FALSE, TRUE , FALSE, FALSE, FALSE, FALSE, FALSE, FALSE }, // ALARM_ID_VENOUS_PRESSURE_HIGH }; const ALARM_DATA_T blankAlarmData = { ALARM_DATA_TYPE_NONE, 0 }; Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -rfef7e8ec54aea7e7dc447b6240796013cc086604 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision fef7e8ec54aea7e7dc447b6240796013cc086604) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -50,6 +50,13 @@ ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RESUME, ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RINSEBACK, ALARM_ID_CAN_MESSAGE_NOT_ACKED, + ALARM_ID_OCCLUSION_BLOOD_PUMP, + ALARM_ID_OCCLUSION_DIAL_IN_PUMP, // 30 + ALARM_ID_OCCLUSION_DIAL_OUT_PUMP, + ALARM_ID_ARTERIAL_PRESSURE_LOW, + ALARM_ID_ARTERIAL_PRESSURE_HIGH, + ALARM_ID_VENOUS_PRESSURE_LOW, + ALARM_ID_VENOUS_PRESSURE_HIGH, // 35 NUM_OF_ALARM_IDS } ALARM_ID_T; @@ -176,6 +183,9 @@ SW_FAULT_ID_RTC_EXEC_INVALID_STATE, SW_FAULT_ID_RTC_SELF_TEST_INVALID_STATE, // 45 SW_FAULT_ID_RTC_TRANSACTION_SERVICE_INVALID_STATE, + SW_FAULT_ID_PRES_OCCL_INVALID_STATE, + SW_FAULT_ID_PRES_OCCL_INVALID_PRES_SENSOR, + SW_FAULT_ID_PRES_OCCL_INVALID_OCCL_SENSOR, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r9864b14f76782f1e68bf266dcd843451748715a0 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 9864b14f76782f1e68bf266dcd843451748715a0) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -914,30 +914,30 @@ } /************************************************************************* - * @brief getFPGABloodOcclusion - * The getFPGABloodOcclusion function gets the latest blood occlusion reading. + * @brief getFPGABloodPumpOcclusion + * The getFPGABloodPumpOcclusion function gets the latest blood occlusion reading. * @details * Inputs : fpgaSensorReadings * Outputs : none * @param none * @return last blood occlusion reading *************************************************************************/ -F32 getFPGABloodOcclusion( void ) +U16 getFPGABloodPumpOcclusion( void ) { return fpgaSensorReadings.bloodOcclusionData; } /************************************************************************* - * @brief getFPGADialysateInletOcclusion - * The getFPGADialysateInletOcclusion function gets the latest dialysate \n + * @brief getFPGADialInPumpOcclusion + * The getFPGADialInPumpOcclusion function gets the latest dialysate \n * inlet occlusion reading. * @details * Inputs : fpgaSensorReadings * Outputs : none * @param none * @return last dialysate inlet occlusion reading *************************************************************************/ -F32 getFPGADialysateInletOcclusion( void ) +U16 getFPGADialInPumpOcclusion( void ) { #ifdef DEBUG_ENABLED { @@ -955,16 +955,16 @@ } /************************************************************************* - * @brief getFPGADialysateOutletOcclusion - * The getFPGADialysateOutletOcclusion function gets the latest dialysate \n + * @brief getFPGADialOutPumpOcclusion + * The getFPGADialOutPumpOcclusion function gets the latest dialysate \n * outlet occlusion reading. * @details * Inputs : fpgaSensorReadings * Outputs : none * @param none * @return last dialysate outlet occlusion reading *************************************************************************/ -F32 getFPGADialysateOutletOcclusion( void ) +U16 getFPGADialOutPumpOcclusion( void ) { return fpgaSensorReadings.dialysateOutOcclusionData; } @@ -978,12 +978,26 @@ * @param none * @return last arterial pressure reading *************************************************************************/ -F32 getFPGAArterialPressure( void ) +U16 getFPGAArterialPressure( void ) { return fpgaSensorReadings.arterialPressureData; } /************************************************************************* + * @brief getFPGAVenousPressure + * The getFPGAVenousPressure function gets the venous arterial pressure reading. + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @param none + * @return last venous pressure reading + *************************************************************************/ +U16 getFPGAVenousPressure( void ) +{ + return 0; // TODO - return reading when available +} + +/************************************************************************* * @brief consumeUnexpectedData * The consumeUnexpectedData function checks to see if a byte is sitting in \n * the SCI2 received data register. Index: firmware/App/Services/FPGA.h =================================================================== diff -u -r9864b14f76782f1e68bf266dcd843451748715a0 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 9864b14f76782f1e68bf266dcd843451748715a0) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -36,9 +36,10 @@ void setFPGAControl( U16 ctrl ); F32 getFPGABloodFlow( void ); F32 getFPGADialysateFlow( void ); -F32 getFPGABloodOcclusion( void ); -F32 getFPGADialysateInletOcclusion( void ); -F32 getFPGADialysateOutletOcclusion( void ); -F32 getFPGAArterialPressure( void ); +U16 getFPGAArterialPressure( void ); +U16 getFPGAVenousPressure( void ); +U16 getFPGABloodPumpOcclusion( void ); +U16 getFPGADialInPumpOcclusion( void ); +U16 getFPGADialOutPumpOcclusion( void ); #endif Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rfef7e8ec54aea7e7dc447b6240796013cc086604 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision fef7e8ec54aea7e7dc447b6240796013cc086604) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -93,7 +93,9 @@ static U08 pcXmitPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static U08 pcRecvPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +#ifdef ACK_IMPLEMENTED static PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; // list of outgoing messages that are awaiting an ACK +#endif // DMA control records static g_dmaCTRL pcDMAXmitControlRecord; // DMA transmit control record (UART-debug) @@ -155,11 +157,13 @@ badCRCTimeStamps[ i ] = 0; } +#ifdef ACK_IMPLEMENTED // initialize pending ACK list for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) { pendingAckList[ i ].used = FALSE; } +#endif } /************************************************************************* @@ -267,8 +271,10 @@ // check for sub-system comm timeouts checkForCommTimeouts(); +#ifdef ACK_IMPLEMENTED // check ACK list for messages that need to be re-sent because they haven't been ACK'd checkPendingACKList(); +#endif } /************************************************************************* @@ -784,12 +790,14 @@ // TODO - check CRC before processing a message if ( message.crc == crc8( (U08*)(&message), sizeof(MESSAGE_HEADER_T) + message.msg.hdr.payloadLen ) ) { +#ifdef ACK_IMPLEMENTED // if ACK, if ( MSG_ID_ACK == message.msg.hdr.msgID ) { matchACKtoPendingACKList( message.msg.hdr.seqNo ); } else +#endif { processReceivedMessage( &message.msg ); } @@ -980,11 +988,13 @@ { U16 msgID = message->hdr.msgID; +#ifdef ACK_IMPLEMENTED // if received message requires ACK, queue one up if ( ( message->hdr.seqNo & MSG_ACK_BIT ) != 0 ) { sendACKMsg( message ); } +#endif // handle any messages from other sub-systems switch ( msgID ) @@ -1080,34 +1090,58 @@ handleTestBloodPumpRotorMeasuredSpeedOverrideRequest( message ); break; - case MSG_ID_DIAL_FLOW_SET_PT_OVERRIDE: - handleTestDialFlowSetPointOverrideRequest( message ); + case MSG_ID_DIAL_IN_FLOW_SET_PT_OVERRIDE: + handleTestDialInFlowSetPointOverrideRequest( message ); break; - case MSG_ID_DIAL_FLOW_MEAS_OVERRIDE: - handleTestDialFlowMeasuredOverrideRequest( message ); + case MSG_ID_DIAL_IN_FLOW_MEAS_OVERRIDE: + handleTestDialInFlowMeasuredOverrideRequest( message ); break; - case MSG_ID_DIAL_PUMP_MC_MEAS_SPEED_OVERRIDE: - handleTestDialPumpMCMeasuredSpeedOverrideRequest( message ); + case MSG_ID_DIAL_IN_PUMP_MC_MEAS_SPEED_OVERRIDE: + handleTestDialInPumpMCMeasuredSpeedOverrideRequest( message ); break; - case MSG_ID_DIAL_PUMP_MC_MEAS_CURR_OVERRIDE: - handleTestDialPumpMCMeasuredCurrentOverrideRequest( message ); + case MSG_ID_DIAL_IN_PUMP_MC_MEAS_CURR_OVERRIDE: + handleTestDialInPumpMCMeasuredCurrentOverrideRequest( message ); break; - case MSG_ID_DIAL_FLOW_SEND_INTERVAL_OVERRIDE: - handleTestDialFlowBroadcastIntervalOverrideRequest( message ); + case MSG_ID_DIAL_IN_FLOW_SEND_INTERVAL_OVERRIDE: + handleTestDialInFlowBroadcastIntervalOverrideRequest( message ); break; - case MSG_ID_DIAL_PUMP_MEAS_SPEED_OVERRIDE: - handleTestDialPumpMeasuredSpeedOverrideRequest( message ); + case MSG_ID_DIAL_IN_PUMP_MEAS_SPEED_OVERRIDE: + handleTestDialInPumpMeasuredSpeedOverrideRequest( message ); break; - case MSG_ID_DIAL_PUMP_MEAS_ROTOR_SPEED_OVERRIDE: - handleTestDialPumpRotorMeasuredSpeedOverrideRequest( message ); + case MSG_ID_DIAL_IN_PUMP_MEAS_ROTOR_SPEED_OVERRIDE: + handleTestDialInPumpRotorMeasuredSpeedOverrideRequest( message ); break; + case MSG_ID_PRESSURE_ARTERIAL_OVERRIDE: + handleTestArterialPressureOverrideRequest( message ); + break; + + case MSG_ID_PRESSURE_VENOUS_OVERRIDE: + handleTestVenousPressureOverrideRequest( message ); + break; + + case MSG_ID_OCCLUSION_BLOOD_PUMP_OVERRIDE: + handleTestBloodPumpOcclusionOverrideRequest( message ); + break; + + case MSG_ID_OCCLUSION_DIAL_IN_PUMP_OVERRIDE: + handleTestDialysateInletPumpOcclusionOverrideRequest( message ); + break; + + case MSG_ID_OCCLUSION_DIAL_OUT_PUMP_OVERRIDE: + handleTestDialysateOutletPumpOcclusionOverrideRequest( message ); + break; + + case MSG_ID_PRES_OCCL_SEND_INTERVAL_OVERRIDE: + handleTestPresOcclBroadcastIntervalOverrideRequest( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rfef7e8ec54aea7e7dc447b6240796013cc086604 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision fef7e8ec54aea7e7dc447b6240796013cc086604) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -24,6 +24,7 @@ #include "Buttons.h" #include "DialInFlow.h" #include "MsgQueues.h" +#include "PresOccl.h" #include "WatchdogMgmt.h" #include "SystemCommMessages.h" #include "Utilities.h" @@ -60,6 +61,15 @@ F32 pwmDC; } PERISTALTIC_PUMP_STATUS_PAYLOAD_T; +typedef struct +{ + F32 arterialPressure; + F32 venousPressure; + F32 bldPumpOcclusion; + F32 diPumpOcclusion; + F32 doPumpOcclusion; +} PRESSURE_OCCLUSION_DATA_T; + #pragma pack(pop) // ********** private data ********** @@ -151,6 +161,7 @@ return result; } +#ifdef ACK_IMPLEMENTED /************************************************************************* * @brief sendACKMsg * The sendACKMsg function constructs and queues for transmit an ACK message \n @@ -179,6 +190,7 @@ return result; } +#endif // *********************************************************************** // ********************* MSG_ID_OFF_BUTTON_PRESS ************************* @@ -391,7 +403,7 @@ * Outputs : dialysate flow data msg constructed and queued. * @param flowStPt : Current set point for dialysate flow * @param measFlow : Latest measured dialysate flow - * @param measRotorSpd : Latest measured dialysate pump rotoro speed + * @param measRotorSpd : Latest measured dialysate pump rotor speed * @param measSpd : Latest measured dialysate pump speed * @param measMCspd : Latest measured dialysate pump motor controller speed * @param measSpd : Latest measured dialysate pump motor controller current @@ -427,6 +439,46 @@ } /************************************************************************* + * @brief broadcastPresOcclData + * The broadcastPresOcclData function constructs a pres/occl data msg to \n + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : pressure/occlusion data msg constructed and queued. + * @param artPres : Latest measured arterial pressure + * @param venPres : Latest measured venous pressure + * @param bpOccl : Latest measured blood pump occlusion pressure + * @param diOccl : Latest measured dialysate inlet pump occlusion pressure + * @param doOccl : Latest measured dialysate outlet pump occlusion pressure + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastPresOcclData( F32 artPres, F32 venPres, F32 bpOccl, F32 diOccl, F32 doOccl ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + PRESSURE_OCCLUSION_DATA_T payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_PRESSURE_OCCLUSION_DATA; + msg.hdr.payloadLen = sizeof( PERISTALTIC_PUMP_STATUS_PAYLOAD_T ); + + payload.arterialPressure = artPres; + payload.venousPressure = venPres; + payload.bldPumpOcclusion = bpOccl; + payload.diPumpOcclusion = diOccl; + payload.doPumpOcclusion = doOccl; + + memcpy( payloadPtr, &payload, sizeof( PRESSURE_OCCLUSION_DATA_T ) ); + + // 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 handleDGCheckIn * The handleDGCheckIn function handles a check-in from the DG. * @details @@ -745,87 +797,158 @@ DATA_OVERRIDE_HANDLER_FUNC( U32, handleTestBloodFlowBroadcastIntervalOverrideRequest, testSetBloodFlowDataPublishIntervalOverride, testResetBloodFlowDataPublishIntervalOverride ) /************************************************************************* - * @brief handleTestDialFlowSetPointOverrideRequest - * The handleTestDialFlowSetPointOverrideRequest function handles a request to \n + * @brief handleTestDialInFlowSetPointOverrideRequest + * The handleTestDialInFlowSetPointOverrideRequest function handles a request to \n * override the set point for the dialysate inlet flow rate (mL/min). * @details * Inputs : none * Outputs : message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC( U32, handleTestDialFlowSetPointOverrideRequest, testSetTargetDialInFlowRateOverride, testResetTargetDialInFlowRateOverride ) +DATA_OVERRIDE_HANDLER_FUNC( U32, handleTestDialInFlowSetPointOverrideRequest, testSetTargetDialInFlowRateOverride, testResetTargetDialInFlowRateOverride ) /************************************************************************* - * @brief handleTestDialFlowMeasuredOverrideRequest - * The handleTestDialFlowMeasuredOverrideRequest function handles a request to \n + * @brief handleTestDialInFlowMeasuredOverrideRequest + * The handleTestDialInFlowMeasuredOverrideRequest function handles a request to \n * override the measured dialysate inlet flow rate (mL/min). * @details * Inputs : none * Outputs : message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialFlowMeasuredOverrideRequest, testSetMeasuredDialInFlowRateOverride, testResetMeasuredDialInFlowRateOverride ) +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialInFlowMeasuredOverrideRequest, testSetMeasuredDialInFlowRateOverride, testResetMeasuredDialInFlowRateOverride ) /************************************************************************* - * @brief handleTestDialPumpRotorMeasuredSpeedOverrideRequest - * The handleTestDialPumpRotorMeasuredSpeedOverrideRequest function handles a request to \n + * @brief handleTestDialInPumpRotorMeasuredSpeedOverrideRequest + * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to \n * override the measured dialysate inlet pump rotor speed (RPM). * @details * Inputs : none * Outputs : message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialPumpRotorMeasuredSpeedOverrideRequest, testSetMeasuredDialInPumpRotorSpeedOverride, testResetMeasuredDialInPumpRotorSpeedOverride ) +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialInPumpRotorMeasuredSpeedOverrideRequest, testSetMeasuredDialInPumpRotorSpeedOverride, testResetMeasuredDialInPumpRotorSpeedOverride ) /************************************************************************* - * @brief handleTestDialPumpMeasuredSpeedOverrideRequest - * The handleTestDialPumpMeasuredSpeedOverrideRequest function handles a request to \n + * @brief handleTestDialInPumpMeasuredSpeedOverrideRequest + * The handleTestDialInPumpMeasuredSpeedOverrideRequest function handles a request to \n * override the measured dialysate inlet pump speed (RPM). * @details * Inputs : none * Outputs : message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialPumpMeasuredSpeedOverrideRequest, testSetMeasuredDialInPumpSpeedOverride, testResetMeasuredDialInPumpSpeedOverride ) +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialInPumpMeasuredSpeedOverrideRequest, testSetMeasuredDialInPumpSpeedOverride, testResetMeasuredDialInPumpSpeedOverride ) /************************************************************************* - * @brief handleTestDialPumpMCMeasuredSpeedOverrideRequest - * The handleTestDialPumpMCMeasuredSpeedOverrideRequest function handles a request to \n + * @brief handleTestDialInPumpMCMeasuredSpeedOverrideRequest + * The handleTestDialInPumpMCMeasuredSpeedOverrideRequest function handles a request to \n * override the measured dialysate inlet pump motor controller speed (RPM). * @details * Inputs : none * Outputs : message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialPumpMCMeasuredSpeedOverrideRequest, testSetMeasuredDialInPumpMCSpeedOverride, testResetMeasuredDialInPumpMCSpeedOverride ) +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialInPumpMCMeasuredSpeedOverrideRequest, testSetMeasuredDialInPumpMCSpeedOverride, testResetMeasuredDialInPumpMCSpeedOverride ) /************************************************************************* - * @brief handleTestDialPumpMCMeasuredCurrentOverrideRequest - * The handleTestDialPumpMCMeasuredCurrentOverrideRequest function handles a request to \n + * @brief handleTestDialInPumpMCMeasuredCurrentOverrideRequest + * The handleTestDialInPumpMCMeasuredCurrentOverrideRequest function handles a request to \n * override the measured dialysate inlet pump motor controller current (mA). * @details * Inputs : none * Outputs : message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialPumpMCMeasuredCurrentOverrideRequest, testSetMeasuredDialInPumpMCCurrentOverride, testResetMeasuredDialInPumpMCCurrentOverride ) +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialInPumpMCMeasuredCurrentOverrideRequest, testSetMeasuredDialInPumpMCCurrentOverride, testResetMeasuredDialInPumpMCCurrentOverride ) /************************************************************************* - * @brief handleTestDialFlowBroadcastIntervalOverrideRequest - * The handleTestDialFlowBroadcastIntervalOverrideRequest function handles a request to \n + * @brief handleTestDialInFlowBroadcastIntervalOverrideRequest + * The handleTestDialInFlowBroadcastIntervalOverrideRequest function handles a request to \n * override the broadcast interval for dialysate inlet flow data. * @details * Inputs : none * Outputs : message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC( U32, handleTestDialFlowBroadcastIntervalOverrideRequest, testSetDialInFlowDataPublishIntervalOverride, testResetDialInFlowDataPublishIntervalOverride ) +DATA_OVERRIDE_HANDLER_FUNC( U32, handleTestDialInFlowBroadcastIntervalOverrideRequest, testSetDialInFlowDataPublishIntervalOverride, testResetDialInFlowDataPublishIntervalOverride ) +/************************************************************************* + * @brief handleTestArterialPressureOverrideRequest + * The handleTestArterialPressureOverrideRequest function handles a request to \n + * override the arterial pressure. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestArterialPressureOverrideRequest, testSetArterialPressureOverride, testResetArterialPressureOverride ) +/************************************************************************* + * @brief handleTestVenousPressureOverrideRequest + * The handleTestVenousPressureOverrideRequest function handles a request to \n + * override the venous pressure. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestVenousPressureOverrideRequest, testSetVenousPressureOverride, testResetVenousPressureOverride ) + +/************************************************************************* + * @brief handleTestBloodPumpOcclusionOverrideRequest + * The handleTestBloodPumpOcclusionOverrideRequest function handles a request to \n + * override the blood pump occlusion sensor. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestBloodPumpOcclusionOverrideRequest, testSetBloodPumpOcclusionOverride, testResetBloodPumpOcclusionOverride ) + +/************************************************************************* + * @brief handleTestDialysateInletPumpOcclusionOverrideRequest + * The handleTestDialysateInletPumpOcclusionOverrideRequest function handles a request to \n + * override the dialysate inlet pump occlusion sensor. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialysateInletPumpOcclusionOverrideRequest, testSetDialInPumpOcclusionOverride, testResetDialInPumpOcclusionOverride ) + +/************************************************************************* + * @brief handleTestDialysateOutletPumpOcclusionOverrideRequest + * The handleTestDialysateOutletPumpOcclusionOverrideRequest function handles a request to \n + * override the dialysate outlet pump occlusion sensor. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC( F32, handleTestDialysateOutletPumpOcclusionOverrideRequest, testSetDialOutPumpOcclusionOverride, testResetDialOutPumpOcclusionOverride ) + +/************************************************************************* + * @brief handleTestPresOcclBroadcastIntervalOverrideRequest + * The handleTestPresOcclBroadcastIntervalOverrideRequest function handles a request to \n + * override the broadcast interval for pressure/occlusion data. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC( U32, handleTestPresOcclBroadcastIntervalOverrideRequest, testSetPresOcclDataPublishIntervalOverride, testResetPresOcclDataPublishIntervalOverride ) + Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r9864b14f76782f1e68bf266dcd843451748715a0 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 9864b14f76782f1e68bf266dcd843451748715a0) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -33,6 +33,7 @@ MSG_ID_DG_CHECK_IN, // 6 MSG_ID_UI_CHECK_IN, // 7 MSG_ID_DIALYSATE_FLOW_DATA, // 8 + MSG_ID_PRESSURE_OCCLUSION_DATA, // 9 // service/test CAN messages @@ -53,20 +54,28 @@ MSG_ID_ALARM_STATUS_SEND_INTERVAL_OVERRIDE, // 0x800D MSG_ID_BLOOD_PUMP_MEAS_SPEED_OVERRIDE, // 0x800E MSG_ID_BLOOD_PUMP_MEAS_ROTOR_SPEED_OVERRIDE, // 0x800F - MSG_ID_DIAL_FLOW_SET_PT_OVERRIDE, // 0x8010 - MSG_ID_DIAL_FLOW_MEAS_OVERRIDE, // 0x8011 - MSG_ID_DIAL_PUMP_MC_MEAS_SPEED_OVERRIDE, // 0x8012 - MSG_ID_DIAL_PUMP_MC_MEAS_CURR_OVERRIDE, // 0x8013 - MSG_ID_DIAL_FLOW_SEND_INTERVAL_OVERRIDE, // 0x8014 - MSG_ID_DIAL_PUMP_MEAS_SPEED_OVERRIDE, // 0x8015 - MSG_ID_DIAL_PUMP_MEAS_ROTOR_SPEED_OVERRIDE, // 0x8016 + MSG_ID_DIAL_IN_FLOW_SET_PT_OVERRIDE, // 0x8010 + MSG_ID_DIAL_IN_FLOW_MEAS_OVERRIDE, // 0x8011 + MSG_ID_DIAL_IN_PUMP_MC_MEAS_SPEED_OVERRIDE, // 0x8012 + MSG_ID_DIAL_IN_PUMP_MC_MEAS_CURR_OVERRIDE, // 0x8013 + MSG_ID_DIAL_IN_FLOW_SEND_INTERVAL_OVERRIDE, // 0x8014 + MSG_ID_DIAL_IN_PUMP_MEAS_SPEED_OVERRIDE, // 0x8015 + MSG_ID_DIAL_IN_PUMP_MEAS_ROTOR_SPEED_OVERRIDE, // 0x8016 + MSG_ID_PRESSURE_ARTERIAL_OVERRIDE, // 0x8017 + MSG_ID_PRESSURE_VENOUS_OVERRIDE, // 0x8018 + MSG_ID_OCCLUSION_BLOOD_PUMP_OVERRIDE, // 0x8019 + MSG_ID_OCCLUSION_DIAL_IN_PUMP_OVERRIDE, // 0x801A + MSG_ID_OCCLUSION_DIAL_OUT_PUMP_OVERRIDE, // 0x801B + MSG_ID_PRES_OCCL_SEND_INTERVAL_OVERRIDE, // 0x801C END_OF_MSG_IDS } MSG_ID_T; // ********** public function prototypes ********** +#ifdef ACK_IMPLEMENTED // ACK MSG BOOL sendACKMsg( MESSAGE_T *message ); +#endif // MSG_ID_OFF_BUTTON_PRESS BOOL sendOffButtonMsgToUI( U08 cmd ); @@ -85,6 +94,9 @@ // MSG_ID_DIALYSATE_FLOW_DATA BOOL broadcastDialInFlowData( U32 flowStPt, F32 measFlow, F32 measRotorSpd, F32 measSpd, F32 measMCSpd, F32 measMCCurr, F32 pwmDC ); +// MSG_ID_PRESSURE_OCCLUSION_DATA +BOOL broadcastPresOcclData( F32 artPres, F32 venPres, F32 bpOccl, F32 diOccl, F32 doOccl ); + // MSG_ID_DG_CHECK_IN void handleDGCheckIn( MESSAGE_T *message ); // MSG_ID_UI_CHECK_IN @@ -144,26 +156,44 @@ // MSG_ID_BLOOD_PUMP_MEAS_ROTOR_SPEED_OVERRIDE void handleTestBloodPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ); -// MSG_ID_DIAL_FLOW_SET_PT_OVERRIDE -void handleTestDialFlowSetPointOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIAL_IN_FLOW_SET_PT_OVERRIDE +void handleTestDialInFlowSetPointOverrideRequest( MESSAGE_T *message ); -// MSG_ID_DIAL_FLOW_MEAS_OVERRIDE -void handleTestDialFlowMeasuredOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIAL_IN_FLOW_MEAS_OVERRIDE +void handleTestDialInFlowMeasuredOverrideRequest( MESSAGE_T *message ); -// MSG_ID_DIAL_PUMP_MC_MEAS_SPEED_OVERRIDE -void handleTestDialPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIAL_IN_PUMP_MC_MEAS_SPEED_OVERRIDE +void handleTestDialInPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ); -// MSG_ID_DIAL_PUMP_MC_MEAS_CURR_OVERRIDE -void handleTestDialPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIAL_IN_PUMP_MC_MEAS_CURR_OVERRIDE +void handleTestDialInPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ); -// MSG_ID_DIAL_FLOW_SEND_INTERVAL_OVERRIDE -void handleTestDialFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIAL_IN_FLOW_SEND_INTERVAL_OVERRIDE +void handleTestDialInFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ); -// MSG_ID_DIAL_PUMP_MEAS_SPEED_OVERRIDE -void handleTestDialPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIAL_IN_PUMP_MEAS_SPEED_OVERRIDE +void handleTestDialInPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ); -// MSG_ID_DIAL_PUMP_MEAS_ROTOR_SPEED_OVERRIDE -void handleTestDialPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIAL_IN_PUMP_MEAS_ROTOR_SPEED_OVERRIDE +void handleTestDialInPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ); +// MSG_ID_PRESSURE_ARTERIAL_OVERRIDE +void handleTestArterialPressureOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_PRESSURE_VENOUS_OVERRIDE +void handleTestVenousPressureOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_OCCLUSION_BLOOD_PUMP_OVERRIDE +void handleTestBloodPumpOcclusionOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_OCCLUSION_DIAL_IN_PUMP_OVERRIDE +void handleTestDialysateInletPumpOcclusionOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_OCCLUSION_DIAL_OUT_PUMP_OVERRIDE +void handleTestDialysateOutletPumpOcclusionOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_PRES_OCCL_SEND_INTERVAL_OVERRIDE +void handleTestPresOcclBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + #endif Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r9864b14f76782f1e68bf266dcd843451748715a0 -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 9864b14f76782f1e68bf266dcd843451748715a0) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -21,6 +21,7 @@ #include "BloodFlow.h" #include "DialInFlow.h" #include "OperationModes.h" +#include "PresOccl.h" #include "SystemComm.h" #include "WatchdogMgmt.h" #include "TaskGeneral.h" @@ -57,6 +58,9 @@ if ( TRUE == uiCommunicated() ) #endif { + // monitor pressure/occlusion sensors + execPresOccl(); + // run operation mode state machine execOperationModes(); Index: firmware/source/sys_main.c =================================================================== diff -u -r22f7bcd7e26dc6be337fdb6adbc9281e8f60dbbc -r07a5add2dff254f7be3699e4efac2b99d3554847 --- firmware/source/sys_main.c (.../sys_main.c) (revision 22f7bcd7e26dc6be337fdb6adbc9281e8f60dbbc) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 07a5add2dff254f7be3699e4efac2b99d3554847) @@ -67,14 +67,17 @@ #include "CommBuffers.h" #include "CPLD.h" #include "DialInFlow.h" +#include "Dialysis.h" #include "FPGA.h" #include "InternalADC.h" #include "MsgQueues.h" #include "OperationModes.h" +#include "PresOccl.h" #include "SafetyShutdown.h" #include "SystemComm.h" #include "TaskBG.h" #include "Timers.h" +#include "TreatmentStop.h" #include "WatchdogMgmt.h" static void initProcessor( void ); @@ -156,18 +159,21 @@ { initAlarmMgmt(); initTimers(); - initSafetyShutdown(); initCPLD(); - initInternalADC(); - initBloodFlow(); - initDialInFlow(); - initAlarmLamp(); - initButtons(); + initSafetyShutdown(); initWatchdogMgmt(); initFPGA(); + initAlarmLamp(); + initButtons(); + initInternalADC(); initCommBuffers(); initMsgQueues(); initSystemComm(); + initPresOccl(); + initBloodFlow(); + initDialInFlow(); + initDialysis(); + initTreatmentStop(); initOperationModes(); }