Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -rf3a26c402a2ec88f5ee7dbb8eb7127ab5b4692aa -rf1d812de6fbaf4943d05bbee2271bcb61138325a --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision f3a26c402a2ec88f5ee7dbb8eb7127ab5b4692aa) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision f1d812de6fbaf4943d05bbee2271bcb61138325a) @@ -361,6 +361,7 @@ bloodPumpSetSpeedRPM = 0; isBloodPumpOn = FALSE; bpControlTimerCounter = 0; + setPeristalticPumpSetSpeed( bloodPumpSetSpeedRPM ); // resetPIController( PI_CONTROLLER_ID_BLOOD_FLOW, MIN_BLOOD_PUMP_PWM_DUTY_CYCLE ); } @@ -596,6 +597,7 @@ { isBloodPumpOn = FALSE; bloodPumpSetSpeedRPM = 0; + setPeristalticPumpSetSpeed( bloodPumpSetSpeedRPM ); } return result; Index: firmware/App/Drivers/LevelSensors.c =================================================================== diff -u -r961784c895cb8f551a2623cd02dcbfe42d04b7c2 -rf1d812de6fbaf4943d05bbee2271bcb61138325a --- firmware/App/Drivers/LevelSensors.c (.../LevelSensors.c) (revision 961784c895cb8f551a2623cd02dcbfe42d04b7c2) +++ firmware/App/Drivers/LevelSensors.c (.../LevelSensors.c) (revision f1d812de6fbaf4943d05bbee2271bcb61138325a) @@ -81,8 +81,8 @@ // Get latest raw level sensor states from FPGA getFPGAAirTrapLevels( &lowAir, &highAir ); - currentLevelStates[ H17_LEVL ].data = (U32)( FALSE == lowAir ? AIR_TRAP_LEVEL_FLUID : AIR_TRAP_LEVEL_AIR ); - currentLevelStates[ H16_LEVL ].data = (U32)( FALSE == highAir ? AIR_TRAP_LEVEL_FLUID : AIR_TRAP_LEVEL_AIR ); + rawLevelStates[ H17_LEVL ].data = (U32)( FALSE == lowAir ? AIR_TRAP_LEVEL_FLUID : AIR_TRAP_LEVEL_AIR ); + rawLevelStates[ H16_LEVL ].data = (U32)( FALSE == highAir ? AIR_TRAP_LEVEL_FLUID : AIR_TRAP_LEVEL_AIR ); // Debounce raw air trap level sensor readings for( airTrapLevelSensor = AIR_TRAP_LEVEL_FIRST; airTrapLevelSensor < NUM_OF_AIR_TRAP_LEVEL_SENSORS; airTrapLevelSensor++ ) Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r552a7de419344b43a3307c61141c99bfbbee7345 -rf1d812de6fbaf4943d05bbee2271bcb61138325a --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 552a7de419344b43a3307c61141c99bfbbee7345) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision f1d812de6fbaf4943d05bbee2271bcb61138325a) @@ -104,7 +104,7 @@ MSG_ID_TD_AIR_TRAP_LEVEL_OVERRIDE_REQUEST, MSG_ID_TD_AIR_TRAP_LEVEL_RAW_OVERRIDE_REQUEST, MSG_ID_TD_AIR_TRAP_PUBLISH_INTERVAL_OVERRIDE_REQUEST, - MSG_ID_TD_2_WAY_VALVE_SET_STATE_REQUEST, + MSG_ID_TD_3_WAY_VALVE_SET_STATE_REQUEST, MSG_ID_TD_ROTARY_PINCH_VALVE_SET_POS_REQUEST, MSG_ID_TD_ROTARY_PINCH_VALVE_STATUS_OVERRIDE_REQUEST, MSG_ID_TD_ROTARY_PINCH_VALVE_POSITION_OVERRIDE_REQUEST, @@ -218,6 +218,10 @@ U08 crc; U08 data[ MAX_ACK_MSG_SIZE ]; // Byte array to populate with message data +#ifdef TEST_AIR_TRAP_ALPHA_TESTING + return 0; +#endif + // Check to see if tester has requested this message not be transmited if ( TRUE == isTestingActivated() ) { Index: firmware/App/TDCommon.h =================================================================== diff -u -r380b0afc95467d0861ff3aa2cdcde5d5d7ac85e7 -rf1d812de6fbaf4943d05bbee2271bcb61138325a --- firmware/App/TDCommon.h (.../TDCommon.h) (revision 380b0afc95467d0861ff3aa2cdcde5d5d7ac85e7) +++ firmware/App/TDCommon.h (.../TDCommon.h) (revision f1d812de6fbaf4943d05bbee2271bcb61138325a) @@ -32,6 +32,7 @@ #ifndef _RELEASE_ #ifndef _VECTORCAST_ // #define TASK_TIMING_OUTPUT_ENABLED 1 // Re-purposes alarm lamp pins for task timing + #define TEST_AIR_TRAP_ALPHA_TESTING 1 // Alpha unit air trap testing #include #include Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r051326e2671e8d5b3e99eaa109ea549e94a929f3 -rf1d812de6fbaf4943d05bbee2271bcb61138325a --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 051326e2671e8d5b3e99eaa109ea549e94a929f3) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision f1d812de6fbaf4943d05bbee2271bcb61138325a) @@ -22,53 +22,61 @@ #include "OperationModes.h" #include "Pressures.h" #include "Switches.h" -#include "SystemCommTD.h" +#include "SystemCommTD.h" #include "TaskGeneral.h" #include "Valves.h" #include "Voltages.h" #include "WatchdogMgmt.h" +#ifdef TEST_AIR_TRAP_ALPHA_TESTING +#include "GLXferPump.h" +#include "LevelSensors.h" +#include "Valve3Way.h" +#endif + /** * @addtogroup TaskGeneral * @{ */ // ********** private data ********** - - -/*********************************************************************//** - * @brief - * The taskGeneral function handles the scheduled General Task interrupt. - * Calls the executive functions for most monitors and controllers, the - * operation modes, the system communications, and alarms. - * @details \b Inputs: none - * @details \b Outputs: Executive functions running in general task are called. - * @return none - *************************************************************************/ -void taskGeneral( void ) + + +/*********************************************************************//** + * @brief + * The taskGeneral function handles the scheduled General Task interrupt. + * Calls the executive functions for most monitors and controllers, the + * operation modes, the system communications, and alarms. + * @details \b Inputs: none + * @details \b Outputs: Executive functions running in general task are called. + * @return none + *************************************************************************/ +void taskGeneral( void ) { #ifdef TASK_TIMING_OUTPUT_ENABLED // Set GPIO high to indicate general task has begun executing setCPLDLampGreen( PIN_SIGNAL_HIGH ); #endif - // Check in with watchdog manager - checkInWithWatchdogMgmt( TASK_GENERAL ); // Do this first to keep timing consistent with watchdog management + // Check in with watchdog manager + checkInWithWatchdogMgmt( TASK_GENERAL ); // Do this first to keep timing consistent with watchdog management - // Manage data received from other sub-systems + // Manage data received from other sub-systems +#ifndef TEST_AIR_TRAP_ALPHA_TESTING execSystemCommRx(); - +#endif + // Prevent most processing until UI has started communicating or if DG is active and alarm (ALARM_ID_HD_UI_COMM_POST_FAILED) is raised - // proceed to further operations since UI likely failed to come up. + // proceed to further operations since UI likely failed to come up. if ( ( TRUE == uiCommunicated() ) || ( ( FALSE == isOnlyCANNode() ) && ( TRUE == isAlarmActive( ALARM_ID_TD_UI_COMM_POST_FAILED ) ) ) ) { // Monitor voltages execVoltagesMonitor(); - // Monitor DD + // Monitor DD // execDDInterfaceMonitor(); - + // Monitor pressure sensors execPressure(); @@ -79,23 +87,23 @@ // execTemperatures(); // Monitor processor RAM status -// execRAMMonitor(); - +// execRAMMonitor(); + // Monitor blood pump/flow execBloodFlowMonitor(); - // Run operation mode state machine + // Run operation mode state machine execOperationModes(); // Control air trap valve execAirTrapController(); // Control pinch valves - execValvesController(); - - // Control blood pump - execBloodFlowController(); - + execValvesController(); + + // Control blood pump + execBloodFlowController(); + // Control Air Pump execAirPumpController(); @@ -105,17 +113,136 @@ // Manage NVDataMgmt process record state machine // execNVDataMgmtProcessRecord(); - // Manage alarm state + // Manage alarm state execAlarmMgmt(); - // Manage data to be transmitted to other sub-systems - execSystemCommTx(); - } - + // Manage data to be transmitted to other sub-systems + execSystemCommTx(); + } + + // ****************** Start Air Trap Test Code ************************ +#ifdef TEST_AIR_TRAP_ALPHA_TESTING +#if 0 + { + static U32 tmpCtr = 0; + + ++tmpCtr; + if ( tmpCtr == ( 5 * 20 ) ) + { + setAirPumpMotorPower( 255 ); + set3WayValveState( H13_VALV, STATE_OPEN ); + } + else if ( tmpCtr == ( 10 * 20 ) ) + { + setAirPumpMotorPower( 0 ); + set3WayValveState( H13_VALV, STATE_CLOSED ); + } + else if ( tmpCtr == ( 15 * 20 ) ) + { + setAirPumpMotorPower( 255 ); + set3WayValveState( H20_VALV, STATE_OPEN ); + } + else if ( tmpCtr >= ( 20 * 20 ) ) + { + setAirPumpMotorPower( 0 ); + set3WayValveState( H20_VALV, STATE_CLOSED ); + tmpCtr = 0; + } + } +#endif +#if 1 + static U32 ctr = 0; + static U32 sta = 0; + static BOOL start = FALSE; + static BOOL bpStart = FALSE; + static BOOL bpStop = FALSE; + + if ( FALSE == bpStart ) + { + setBloodPumpTargetRPM( 1700, MOTOR_DIR_FORWARD ); + bpStart = TRUE; + } + if ( TRUE == bpStop ) + { + signalBloodPumpHardStop(); + bpStop = FALSE; + } + + // Get level sensor data + readLevelSensors(); + // Control blood pump + execBloodFlowController(); + execAirPumpController(); + + switch ( sta ) + { + case 0: + set3WayValveState( H13_VALV, STATE_CLOSED ); + set3WayValveState( H20_VALV, STATE_CLOSED ); + setAirPumpState( AIR_PUMP_STATE_ON, AIR_PUMP_MOTOR_OFF ); + + if ( TRUE == start ) + { + sta = 1; + // lower the level + set3WayValveState( H13_VALV, STATE_OPEN ); + setAirPumpState( AIR_PUMP_STATE_ON, 255 ); + } + break; + case 1: + // look for low level and stop + if ( AIR_TRAP_LEVEL_AIR == getRawLevelSensorState( H17_LEVL ) ) + { + // stop lowering level + set3WayValveState( H13_VALV, STATE_CLOSED ); + setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); + ctr = 0; + sta = 2; + } + break; + case 2: + // stay low for 10 sec + if ( ++ctr > ( 10 * 20 ) ) + { + // raise the level + set3WayValveState( H20_VALV, STATE_OPEN ); + setAirPumpState( AIR_PUMP_STATE_ON, 255 ); + sta = 3; + } + break; + case 3: + // look for low level and stop + if ( AIR_TRAP_LEVEL_FLUID == getRawLevelSensorState( H16_LEVL ) ) + { + // stop raising level + set3WayValveState( H20_VALV, STATE_CLOSED ); + setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); + ctr = 0; + sta = 4; + } + break; + case 4: + // stay high for 10 sec + if ( ++ctr > ( 10 * 20 ) ) + { + // lower the level + set3WayValveState( H13_VALV, STATE_OPEN ); + setAirPumpState( AIR_PUMP_STATE_ON, 255 ); + sta = 1; + } + break; + default: + sta = 0; + break; + } +#endif +#endif + // ******************* End Air Trap Test Code ************************* + #ifdef TASK_TIMING_OUTPUT_ENABLED - // Set GPIO low to indicate general task has finished executing + // Set GPIO low to indicate general task has finished executing setCPLDLampGreen( PIN_SIGNAL_LOW ); #endif -} +} -/**@}*/ +/**@}*/ Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r56100135135bb715d316b5fd002a4a4951b9334a -rf1d812de6fbaf4943d05bbee2271bcb61138325a --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 56100135135bb715d316b5fd002a4a4951b9334a) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision f1d812de6fbaf4943d05bbee2271bcb61138325a) @@ -44,6 +44,10 @@ setCPLDLampRed( PIN_SIGNAL_HIGH ); #endif +#ifdef TEST_AIR_TRAP_ALPHA_TESTING + execFPGA( TRUE ); +#endif + // Prevent most processing until UI has started communicating if ( TRUE == uiCommunicated() ) { @@ -69,6 +73,10 @@ execFPGA( FALSE ); } +#ifdef TEST_AIR_TRAP_ALPHA_TESTING + execFPGA( FALSE ); +#endif + // Check in with watchdog manager checkInWithWatchdogMgmt( TASK_PRIORITY );