Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r40a0bc77c53a4eb538580d44f1117d26f1d37fb2 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 40a0bc77c53a4eb538580d44f1117d26f1d37fb2) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -33,7 +33,7 @@ // ********** private definitions ********** /// Default publication interval for pressure and occlusion data. -#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. +#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. #define ARTERIAL_PRESSURE_V_BIAS ( 3.0 ) ///< Bias voltage for arterial pressure sensor. #define ARTERIAL_PRESSURE_SENSITIVITY ( 0.000005 ) ///< Sensitivity for arterial pressure sensor is 5 uV / mmHg @@ -77,22 +77,22 @@ // ********** private data ********** -static PRESSURE_STATE_T presOcclState = PRESSURE_INIT_STATE; ///< current state of pressure monitor state machine. -static U32 presOcclDataPublicationTimerCounter = 0; ///< used to schedule pressure data publication to CAN bus. +static PRESSURE_STATE_T presOcclState = PRESSURE_INIT_STATE; ///< Current state of pressure monitor state machine. +static U32 presOcclDataPublicationTimerCounter = 0; ///< Used to schedule pressure data publication to CAN bus. -/// interval (in ms) at which to publish pressure/occlusion data to CAN bus. +/// Interval (in ms) at which to publish pressure/occlusion data to CAN bus. static OVERRIDE_U32_T presOcclDataPublishInterval = { PRES_OCCL_DATA_PUB_INTERVAL, PRES_OCCL_DATA_PUB_INTERVAL, 0, 0 }; -static OVERRIDE_F32_T arterialPressure = {0.0, 0.0, 0.0, 0 }; ///< measured arterial pressure. -static OVERRIDE_F32_T venousPressure = {0.0, 0.0, 0.0, 0 }; ///< measured venous pressure. -static OVERRIDE_U32_T bloodPumpOcclusion = {0, 0, 0, 0 }; ///< measured blood pump occlusion pressure. -static OVERRIDE_U32_T dialInPumpOcclusion = {0, 0, 0, 0 }; ///< measured dialysate inlet pump occlusion pressure. -static OVERRIDE_U32_T dialOutPumpOcclusion = {0, 0, 0, 0 }; ///< measured dialysate outlet pump occlusion pressure. +static OVERRIDE_F32_T arterialPressure = {0.0, 0.0, 0.0, 0 }; ///< Measured arterial pressure. +static OVERRIDE_F32_T venousPressure = {0.0, 0.0, 0.0, 0 }; ///< Measured venous pressure. +static OVERRIDE_U32_T bloodPumpOcclusion = {0, 0, 0, 0 }; ///< Measured blood pump occlusion pressure. +static OVERRIDE_U32_T dialInPumpOcclusion = {0, 0, 0, 0 }; ///< Measured dialysate inlet pump occlusion pressure. +static OVERRIDE_U32_T dialOutPumpOcclusion = {0, 0, 0, 0 }; ///< Measured dialysate outlet pump occlusion pressure. -/// current pressure self-test state. +/// Current pressure self-test state. static PRESSURE_SELF_TEST_STATE_T presOcclSelfTestState = PRESSURE_SELF_TEST_STATE_START; -static U32 bloodPumpSelfTestTimerCount = 0; ///< timer counter for pressure self-test. +static U32 bloodPumpSelfTestTimerCount = 0; ///< Timer counter for pressure self-test. -static U32 staleVenousPressureCtr = 0; ///< timer counter for stale venous pressure reading. +static U32 staleVenousPressureCtr = 0; ///< Timer counter for stale venous pressure reading. // ********** private function prototypes ********** @@ -104,7 +104,7 @@ static void checkVenousPressureInRange( void ); static void checkOcclusions( void ); static void publishPresOcclData( void ); -static DATA_GET_PROTOTYPE( U32, getPublishPresOcclDataInterval ); +static U32 getPublishPresOcclDataInterval( void ); /*********************************************************************//** * @brief @@ -115,7 +115,7 @@ *************************************************************************/ void initPresOccl( void ) { - // initialize persistent pressure alarms + // Initialize persistent pressure alarms initPersistentAlarm( PERSISTENT_ALARM_ARTERIAL_PRESSURE_LOW, ALARM_ID_ARTERIAL_PRESSURE_LOW, isAlarmRecoverable( ALARM_ID_ARTERIAL_PRESSURE_LOW ), PRES_ALARM_PERSISTENCE, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( PERSISTENT_ALARM_ARTERIAL_PRESSURE_HIGH, ALARM_ID_ARTERIAL_PRESSURE_HIGH, @@ -160,7 +160,7 @@ *************************************************************************/ void execPresOccl( void ) { - // state machine + // State machine switch ( presOcclState ) { case PRESSURE_INIT_STATE: @@ -176,7 +176,7 @@ break; } - // publish pressure/occlusion data on interval + // Publish pressure/occlusion data on interval publishPresOcclData(); } @@ -207,17 +207,17 @@ { PRESSURE_STATE_T result = PRESSURE_CONTINUOUS_READ_STATE; - // read latest in-line (arterial and venous) pressures + // Read latest in-line (arterial and venous) pressures convertInlinePressures(); - // read latest occlusion pressures + // Read latest occlusion pressures convertOcclusionPressures(); - // check in-line pressures are in range + // Check in-line pressures are in range checkArterialPressureInRange(); checkVenousPressureInRange(); - // check for occlusions + // Check for occlusions checkOcclusions(); return result; @@ -234,16 +234,16 @@ static void convertInlinePressures( void ) { U32 fpgaArtPres = getFPGAArterialPressure(); - S32 artPres = (S32)( fpgaArtPres & MASK_OFF_U32_MSB ) - 0x800000; // subtract 2^23 from low 24 bits to get signed reading - U08 artPresAlarm = (U08)( fpgaArtPres >> 24 ); // high byte is alarm code for arterial pressure + S32 artPres = (S32)( fpgaArtPres & MASK_OFF_U32_MSB ) - 0x800000; // Subtract 2^23 from low 24 bits to get signed reading + U08 artPresAlarm = (U08)( fpgaArtPres >> 24 ); // High byte is alarm code for arterial pressure U16 fpgaVenPres = getFPGAVenousPressure(); U16 venPres = fpgaVenPres & 0x3FFF; // 14-bit data - U08 venPresStatus = (U08)( fpgaVenPres >> 14 ); // high 2 bits is status code for venous pressure + U08 venPresStatus = (U08)( fpgaVenPres >> 14 ); // High 2 bits is status code for venous pressure F32 venPresPSI; // TODO - any filtering required??? - // convert arterial pressure to mmHg if no alarm + // Convert arterial pressure to mmHg if no alarm if ( 0 == artPresAlarm ) { arterialPressure.data = ARTERIAL_PRESSURE_V_PER_BIT * ( (F32)(artPres) / ( ARTERIAL_PRESSURE_SENSITIVITY * ARTERIAL_PRESSURE_V_BIAS ) ); @@ -255,15 +255,15 @@ #endif } - // convert venous pressure to PSI + // Convert venous pressure to PSI venPresPSI = ( (F32)(venPres - VENOUS_PRESSURE_OFFSET) * (VENOUS_PRESSURE_MAX - VENOUS_PRESSURE_MIN) / (F32)VENOUS_PRESSURE_SCALE ) + VENOUS_PRESSURE_MIN; - // convert venous pressure from PSI to mmHg if sensor status is normal + // Convert venous pressure from PSI to mmHg if sensor status is normal if ( VENOUS_PRESSURE_NORMAL_OP == venPresStatus ) { venousPressure.data = venPresPSI * PSI_TO_MMHG; staleVenousPressureCtr = 0; } - // if venous pressure sensor status is not normal or reading is stale for too long, fault + // If venous pressure sensor status is not normal or reading is stale for too long, fault else { if ( ++staleVenousPressureCtr > MAX_TIME_BETWEEN_VENOUS_READINGS ) @@ -274,7 +274,7 @@ } } - // check for venous pressure sensor alarm or in wrong (cmd) mode + // Check for venous pressure sensor alarm or in wrong (cmd) mode if ( ( VENOUS_PRESSURE_DIAG_CONDITION == venPresStatus ) || ( VENOUS_PRESSURE_CMD_MODE == venPresStatus ) ) { #ifndef DISABLE_PRESSURE_CHECKS @@ -294,7 +294,7 @@ { // TODO - any filtering required??? - // occlusion sensor values have no unit - take as is + // Occlusion sensor values have no unit - take as is bloodPumpOcclusion.data = (U32)getFPGABloodPumpOcclusion(); dialInPumpOcclusion.data = (U32)getFPGADialInPumpOcclusion(); dialOutPumpOcclusion.data = (U32)getFPGADialOutPumpOcclusion(); @@ -312,7 +312,7 @@ { F32 artPres = getMeasuredArterialPressure(); - // check arterial pressure during treatment mode + // Check arterial pressure during treatment mode if ( MODE_TREA == getCurrentOperationMode() ) { F32 artLowLimit = (F32)getTreatmentParameterS32( TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT ); @@ -337,7 +337,7 @@ { F32 venPres = getMeasuredVenousPressure(); - // check arterial pressure during treatment mode + // Check arterial pressure during treatment mode if ( MODE_TREA == getCurrentOperationMode() ) { F32 venLowLimit = (F32)getTreatmentParameterS32( TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT ); @@ -512,7 +512,7 @@ *************************************************************************/ static void publishPresOcclData( void ) { - // publish pressure/occlusion data on interval + // Publish pressure/occlusion data on interval if ( ++presOcclDataPublicationTimerCounter >= getPublishPresOcclDataInterval() ) { PRESSURE_OCCLUSION_DATA_T data;