Index: firmware/App/Common.h =================================================================== diff -u -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Common.h (.../Common.h) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) +++ firmware/App/Common.h (.../Common.h) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -22,7 +22,7 @@ // ********** build switches ********** #ifndef _VECTORCAST_ - #define RM46_EVAL_BOARD_TARGET 1 +// #define RM46_EVAL_BOARD_TARGET 1 // #define SIMULATE_UI 1 #define DEBUG_ENABLED 1 Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -23,6 +23,7 @@ #include "FPGA.h" #include "InternalADC.h" #include "SystemCommMessages.h" +#include "TaskGeneral.h" #include "TaskPriority.h" #include "Timers.h" #include "BloodFlow.h" @@ -33,19 +34,22 @@ #define MAX_BLOOD_FLOW_RATE 600 // mL/min -#define MAX_BLOOD_PUMP_PWM_STEP_CHANGE 0.005 // duty cycle TODO - fixed or parameterized or set in motor controller? +#define MAX_BLOOD_PUMP_PWM_STEP_CHANGE 0.02 // duty cycle TODO - fixed or parameterized or set in motor controller? #define MAX_BLOOD_PUMP_PWM_DUTY_CYCLE 0.88 // controller will error if PWM duty cycle > 90%, so set max to 88% #define MIN_BLOOD_PUMP_PWM_DUTY_CYCLE 0.12 // controller will error if PWM duty cycle < 10%, so set min to 12% -#define BP_CONTROL_INTERVAL (200 / TASK_PRIORITY_INTERVAL) // interval (ms/task time) at which the blood pump is controlled -#define BP_P_COEFFICIENT 0.001 // P term for blood pump control -#define BP_I_COEFFICIENT 0.001 // I term for blood pump control -#define BP_MAX_ERROR_SUM 20.0 // for anti-wind-up in I term +#define BP_CONTROL_INTERVAL (500 / TASK_GENERAL_INTERVAL) // interval (ms/task time) at which the blood pump is controlled +#define BP_P_COEFFICIENT 0.0002 // P term for blood pump control +#define BP_I_COEFFICIENT 0.00002 // I term for blood pump control +#define BP_MAX_ERROR_SUM 10.0 // for anti-wind-up in I term +#define BP_MIN_ERROR_SUM -10.0 +#define BP_MAX_PWM_DC_DELTA 0.01 // prevents large steps in PWM duty cycle +#define BP_MIN_PWM_DC_DELTA -0.01 -#define BP_SPEED_ADC_TO_RPM_FACTOR 1.375 // conversion factor from ADC counts to RPM for blood pump motor TODO - set appropriate value -#define BP_CURRENT_ADC_TO_MA_FACTOR 2.65 // conversion factor from ADC counts to mA for blood pump motor TODO - set appropriate value +#define BP_SPEED_ADC_TO_RPM_FACTOR 1.375 // conversion factor from ADC counts to RPM for blood pump motor +#define BP_CURRENT_ADC_TO_MA_FACTOR 2.65 // conversion factor from ADC counts to mA for blood pump motor -#define BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR (80.0 / 1000.0) // 80 pump revolutions = 1 liter or 1,000 mL +#define BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR (124.0 / 1000.0)// 124 pump revolutions = 1 liter or 1,000 mL #define BP_GEAR_RATIO 32.0 // blood pump motor to blood pump gear ratio #define BP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.0003125 // ~32 BP motor RPM = 1% PWM duty cycle #define BP_PWM_ZERO_OFFSET 0.1 // 10% PWM duty cycle = zero speed @@ -55,6 +59,8 @@ #define BLOODPUMP_ADC_MID_PT_BITS ((F32)(INT_ADC_FULL_SCALE_BITS >> 1) * (BLOODPUMP_ADC_FULL_SCALE_V / INT_ADC_REF_V)) #define SIGN_FROM_12_BIT_VALUE(v) ((S16)(v) - (S16)BLOODPUMP_ADC_MID_PT_BITS) +#define SIZE_OF_ROLLING_AVG 100 // flow samples in rolling average calculations + typedef enum BloodPump_States { BLOOD_PUMP_OFF_STATE = 0, @@ -101,6 +107,10 @@ static F32 bpFlowErrorSum = 0.0; // blood flow error sum static U32 bpControlTimerCounter = 0; // determines when to perform control on blood flow +static F32 flowReadings[SIZE_OF_ROLLING_AVG]; // holds flow samples for a rolling average +static U32 flowReadingsIdx = 0; // index for next sample in rolling average array +static F32 flowReadingsTotal = 0.0; // rolling total - used to calc average + static BLOOD_FLOW_SELF_TEST_STATE_T bloodPumpSelfTestState = BLOOD_FLOW_SELF_TEST_STATE_START; // current blood pump self test state static U32 bloodPumpSelfTestTimerCount = 0; // timer counter for blood pump self test @@ -126,8 +136,16 @@ *************************************************************************/ void initBloodFlow( void ) { + U32 i; + stopBloodPump(); setBloodPumpDirection( MOTOR_DIR_FORWARD ); + + // zero rolling flow average buffer + for ( i = 0; i < SIZE_OF_ROLLING_AVG; i++ ) + { + flowReadings[i] = 0.0; + } } /************************************************************************* @@ -213,11 +231,17 @@ { U16 bpRPM = getIntADCReading( INT_ADC_BLOOD_PUMP_SPEED ); U16 bpmA = getIntADCReading( INT_ADC_BLOOD_PUMP_MOTOR_CURRENT ); + F32 bpFlow = getFPGABloodFlow(); // TODO - change to avg. blood flow when available from FPGA - measuredBloodFlowRate.data = getFPGABloodFlow(); adcBloodPumpSpeedRPM.data = (F32)(SIGN_FROM_12_BIT_VALUE(bpRPM)) * BP_SPEED_ADC_TO_RPM_FACTOR; adcBloodPumpCurrentmA.data = (F32)(SIGN_FROM_12_BIT_VALUE(bpmA)) * BP_CURRENT_ADC_TO_MA_FACTOR; + flowReadingsTotal -= flowReadings[flowReadingsIdx]; + flowReadings[flowReadingsIdx] = bpFlow; + flowReadingsTotal += bpFlow; + flowReadingsIdx = INC_WRAP( flowReadingsIdx, 0, SIZE_OF_ROLLING_AVG-1 ); + measuredBloodFlowRate.data = flowReadingsTotal / (F32)SIZE_OF_ROLLING_AVG; + // publish blood flow data on interval if ( ++bloodFlowDataPublicationTimerCounter > getPublishBloodFlowDataInterval() ) { @@ -226,10 +250,10 @@ F32 measSpd = getMeasuredBloodPumpSpeed(); F32 measCurr = getMeasuredBloodPumpCurrent(); #ifdef DEBUG_ENABLED - F32 tmp = getFPGADialysateFlow(); + S32 pwm = (S32)(100.0*bloodPumpPWMDutyCyclePctSet); char debugFlowStr[256]; - sprintf( debugFlowStr, "Target Flow:%5d, Meas. Flow:%5d, Speed:%5d RPM, Current:%5d mA, PWM%:%5d \n", flowStPt, (S32)measFlow, (S32)measSpd, (S32)measCurr, (S32)bloodPumpPWMDutyCyclePctSet ); + sprintf( debugFlowStr, "Target Flow:%5d, Meas. Flow:%5d, Speed:%5d RPM, Current:%5d mA, PWM:%5d \n", flowStPt, (S32)measFlow, (S32)measSpd, (S32)measCurr, pwm ); sendDebugData( (U08*)debugFlowStr, strlen(debugFlowStr) ); #endif broadcastBloodFlowData( flowStPt, measFlow, measSpd, measCurr ); @@ -398,12 +422,21 @@ if ( ++bpControlTimerCounter >= BP_CONTROL_INTERVAL ) { // compute P term - bpFlowError = tgtFlow - actFlow; + if ( MOTOR_DIR_FORWARD == bloodPumpDirectionSet ) + { + bpFlowError = tgtFlow - actFlow; + } + else + { + bpFlowError = (tgtFlow * -1.0) - (actFlow * -1.0); + } pTerm = bpFlowError * BP_P_COEFFICIENT; + pTerm = RANGE( pTerm, BP_MIN_PWM_DC_DELTA, BP_MAX_PWM_DC_DELTA ); // compute I term bpFlowErrorSum += bpFlowError; - iTerm = RANGE( bpFlowErrorSum, BP_MAX_ERROR_SUM * -1.0, BP_MAX_ERROR_SUM ); + iTerm = RANGE( bpFlowErrorSum, BP_MIN_ERROR_SUM, BP_MAX_ERROR_SUM ); iTerm *= BP_I_COEFFICIENT; + iTerm = RANGE( iTerm, BP_MIN_PWM_DC_DELTA, BP_MAX_PWM_DC_DELTA ); // compute new PWM duty cycle % for blood pump motor newPWM = bloodPumpPWMDutyCyclePctSet + pTerm + iTerm; newPWM = RANGE( newPWM, MIN_BLOOD_PUMP_PWM_DUTY_CYCLE, MAX_BLOOD_PUMP_PWM_DUTY_CYCLE ); Index: firmware/App/Modes/ModePrescription.c =================================================================== diff -u -r40bcef6aa65af6c93ce937c6c4aa2de13e8a78d3 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Modes/ModePrescription.c (.../ModePrescription.c) (revision 40bcef6aa65af6c93ce937c6c4aa2de13e8a78d3) +++ firmware/App/Modes/ModePrescription.c (.../ModePrescription.c) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -56,7 +56,7 @@ { // temporary test code - alarm lamp Off requestAlarmLampPattern( LAMP_PATTERN_OFF ); - setBloodPumpTargetFlowRate( 600, MOTOR_DIR_FORWARD ); + setBloodPumpTargetFlowRate( 500, MOTOR_DIR_FORWARD ); #ifdef RM46_EVAL_BOARD_TARGET start = getMSTimerCount(); #endif Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r40bcef6aa65af6c93ce937c6c4aa2de13e8a78d3 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 40bcef6aa65af6c93ce937c6c4aa2de13e8a78d3) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -55,7 +55,7 @@ { // temporary test code - alarm lamp medium alarm requestAlarmLampPattern( LAMP_PATTERN_MED_ALARM ); - setBloodPumpTargetFlowRate( 600, MOTOR_DIR_REVERSE ); + setBloodPumpTargetFlowRate( 400, MOTOR_DIR_REVERSE ); #ifdef RM46_EVAL_BOARD_TARGET start = getMSTimerCount(); #endif Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -26,6 +26,7 @@ ALARM_ID_STUCK_BUTTON_TEST_FAILED, ALARM_ID_FPGA_POST_TEST_FAILED, ALARM_ID_WATCHDOG_POST_TEST_FAILED, + ALARM_ID_UI_COMM_POST_FAILED, NUM_OF_ALARM_IDS } ALARM_ID_T; Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -71,6 +71,10 @@ static g_dmaCTRL pcDMAXmitControlRecord; static g_dmaCTRL pcDMARecvControlRecord; +static BOOL dgIsCommunicating = FALSE; +static BOOL uiIsCommunicating = FALSE; +static BOOL uiDidCommunicate = FALSE; + // ********** private function prototypes ********** static void initUARTAndDMA( void ); @@ -103,6 +107,89 @@ } /************************************************************************* + * @brief checkInFromDG + * The checkInFromDG function checks in the DG with the HD - indicating that \n + * the DG is communicating. + * @details + * Inputs : none + * Outputs : dgIsCommunicating + * @param none + * @return none + *************************************************************************/ +void checkInFromDG( void ) +{ + dgIsCommunicating = TRUE; +} + +/************************************************************************* + * @brief checkInFromUI + * The checkInFromUI function checks in the UI with the HD - indicating that \n + * the UI is communicating. + * @details + * Inputs : none + * Outputs : uiIsCommunicating + * @param none + * @return none + *************************************************************************/ +void checkInFromUI( void ) +{ + uiIsCommunicating = TRUE; + uiDidCommunicate = TRUE; +} + +/************************************************************************* + * @brief isDGCommunicating + * The isDGCommunicating function determines whether the DG is communicating \n + * with the HD. + * @details + * Inputs : dgIsCommunicating + * Outputs : none + * @param none + * @return TRUE if DG has checked in since last call, FALSE if not + *************************************************************************/ +BOOL isDGCommunicating( void ) +{ + BOOL result = dgIsCommunicating; + + dgIsCommunicating = FALSE; + + return result; +} + +/************************************************************************* + * @brief isUICommunicating + * The isUICommunicating function determines whether the UI is communicating \n + * with the HD. + * @details + * Inputs : uiIsCommunicating + * Outputs : none + * @param none + * @return TRUE if UI has checked in since last call, FALSE if not + *************************************************************************/ +BOOL isUICommunicating( void ) +{ + BOOL result = uiIsCommunicating; + + uiIsCommunicating = FALSE; + + return result; +} + +/************************************************************************* + * @brief uiCommunicated + * The uiCommunicated function determines whether the UI has communicated. + * @details + * Inputs : uiDidCommunicate + * Outputs : none + * @param none + * @return TRUE if UI has communicated since power up, FALSE if not + *************************************************************************/ +BOOL uiCommunicated( void ) +{ + return uiDidCommunicate; +} + +/************************************************************************* * @brief execSystemCommRx * The execSystemCommRx function manages received data from other sub-systems. * @details @@ -635,8 +722,16 @@ #endif break; + case MSG_ID_DG_CHECK_IN: + handleDGCheckIn( message ); + break; + case MSG_ID_UI_CHECK_IN: + handleUICheckIn( message ); + break; + + case MSG_ID_TESTER_LOGIN_REQUEST: handleTesterLogInRequest( message ); break; Index: firmware/App/Services/SystemComm.h =================================================================== diff -u -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Services/SystemComm.h (.../SystemComm.h) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) +++ firmware/App/Services/SystemComm.h (.../SystemComm.h) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -37,5 +37,10 @@ void handleCANMsgInterrupt( CAN_MESSAGE_BOX_T srcCANBox ); void handleUARTMsgRecvPacketInterrupt( void ); void handleUARTMsgXmitPacketInterrupt( void ); +void checkInFromDG( void ); +void checkInFromUI( void ); +BOOL isDGCommunicating( void ); +BOOL isUICommunicating( void ); +BOOL uiCommunicated( void ); #endif Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -117,9 +117,8 @@ // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS; - msg.hdr.payloadLen = 0; -// msg.hdr.payloadLen = 1; -// msg.payload[0] = (U08)promptUser; + msg.hdr.payloadLen = 1; + msg.payload[0] = (U08)promptUser; // serialize the message (w/ sync, CRC, and appropriate CAN padding) msgSize = serializeMessage( msg, data ); @@ -180,7 +179,6 @@ result = addToCommBuffer( COMM_BUFFER_OUT_CAN_HD_ALARM, data, msgSize ); return result; - } /************************************************************************* @@ -222,6 +220,7 @@ return result; } + /************************************************************************* * @brief broadcastAlarmCleared * The broadcastAlarmCleared function constructs an alarm cleared msg to be \n @@ -297,10 +296,37 @@ result = addToCommBuffer( COMM_BUFFER_OUT_CAN_HD_BROADCAST, data, msgSize ); return result; +} +/************************************************************************* + * @brief handleDGCheckIn + * The handleDGCheckIn function handles a check-in from the DG. + * @details + * Inputs : none + * Outputs : check in the DG with the SystemComm module. + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGCheckIn( MESSAGE_T *message ) +{ + checkInFromDG(); } +/************************************************************************* + * @brief handleUICheckIn + * The handleUICheckIn function handles a check-in from the UI. + * @details + * Inputs : none + * Outputs : check in the UI with the SystemComm module. + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUICheckIn( MESSAGE_T *message ) +{ + checkInFromUI(); +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -30,6 +30,8 @@ MSG_ID_ALARM_TRIGGERED, // 3 MSG_ID_ALARM_CLEARED, // 4 MSG_ID_BLOOD_FLOW_DATA, // 5 + MSG_ID_DG_CHECK_IN, // 6 + MSG_ID_UI_CHECK_IN, // 7 // service/test CAN messages @@ -67,6 +69,11 @@ // MSG_ID_BLOOD_FLOW_DATA BOOL broadcastBloodFlowData( U32 flowStPt, F32 measFlow, F32 measSpd, F32 measCurr ); +// MSG_ID_DG_CHECK_IN +void handleDGCheckIn( MESSAGE_T *message ); +// MSG_ID_UI_CHECK_IN +void handleUICheckIn( MESSAGE_T *message ); + // *********** public test support message functions ********** // DEBUG OUTPUT Index: firmware/App/Tasks/TaskBG.c =================================================================== diff -u -r40bcef6aa65af6c93ce937c6c4aa2de13e8a78d3 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision 40bcef6aa65af6c93ce937c6c4aa2de13e8a78d3) +++ firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -15,9 +15,19 @@ **************************************************************************/ #include "Common.h" +#include "SystemComm.h" #include "WatchdogMgmt.h" #include "TaskTimer.h" +// ********** private definitions ********** + +#define MAX_TIME_FOR_UI_TO_COMMUNICATE_MS 30000 // 30 seconds + +// ********** private data ********** + +static U32 startUICommTimeout; +static BOOL uiIsCommunicating = FALSE; + /************************************************************************* * @brief taskBackground * The taskBackground function handles the idle Background Task loop. @@ -28,10 +38,28 @@ *************************************************************************/ void taskBackground( void ) { + startUICommTimeout = getMSTimerCount(); #ifndef _VECTORCAST_ // can't have infinite loop in unit test tool while ( 1 ) #endif { + // wait for UI to come up after power up + if ( FALSE == uiIsCommunicating ) + { + if ( TRUE == uiCommunicated() ) + { + uiIsCommunicating = TRUE; + } + else + { + if ( TRUE == didTimeout( startUICommTimeout, MAX_TIME_FOR_UI_TO_COMMUNICATE_MS ) ) + { + activateAlarmNoData( ALARM_ID_UI_COMM_POST_FAILED ); + checkInFromUI(); // pretend we got something from UI to unlock task processing of HD + } + } + } + // manage the watchdog execWatchdogMgmt(); } Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -18,6 +18,7 @@ #include "Common.h" #include "AlarmLamp.h" +#include "BloodFlow.h" #include "OperationModes.h" #include "SystemComm.h" #include "WatchdogMgmt.h" @@ -29,6 +30,10 @@ static BOOL lastUserPress = FALSE; #endif +// ********** private data ********** + +static BOOL uiHasCheckedIn = FALSE; + /************************************************************************* * @brief taskGeneral * The taskGeneral function handles the scheduled General Task interrupt.\n @@ -48,34 +53,45 @@ // manage data received from other sub-systems execSystemCommRx(); - // run operation mode state machine - execOperationModes(); + // prevent most processing until UI has started communicating + if ( TRUE == uiHasCheckedIn ) + { + // control blood pump + execBloodFlowController(); - // manage alarm state - execAlarmMgmt(); + // run operation mode state machine + execOperationModes(); - // control alarm lamp - execAlarmLamp(); + // manage alarm state + execAlarmMgmt(); + // control alarm lamp + execAlarmLamp(); + #ifdef RM46_EVAL_BOARD_TARGET - if ( getUserButtonState() == PIN_SIGNAL_LOW ) - { - if ( lastUserPress == FALSE ) + if ( getUserButtonState() == PIN_SIGNAL_LOW ) { - lastUserPress = TRUE; - setUserLED( FALSE ); - sendOffButtonMsgToUI(TRUE); + if ( lastUserPress == FALSE ) + { + lastUserPress = TRUE; + setUserLED( FALSE ); + sendOffButtonMsgToUI(TRUE); + } } + else + { + lastUserPress = FALSE; + } +#endif + + // manage data to be transmitted to other sub-systems + execSystemCommTx(); } else { - lastUserPress = FALSE; + uiHasCheckedIn = uiCommunicated(); } -#endif - // manage data to be transmitted to other sub-systems - execSystemCommTx(); - // toggle GPIO to indicate general task has executed // gioToggleBit( gioPORTB, 1 ); } Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -rcb5c7321fae3036d7a3641ae49097b4b361270f5 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision cb5c7321fae3036d7a3641ae49097b4b361270f5) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -20,9 +20,12 @@ #include "BloodFlow.h" #include "Buttons.h" #include "FPGA.h" +#include "SystemComm.h" #include "WatchdogMgmt.h" #include "TaskPriority.h" +static BOOL uiHasCheckedIn = FALSE; + /************************************************************************* * @brief taskPriority * The taskPriority function handles the scheduled Priority Task interrupt. @@ -33,24 +36,29 @@ *************************************************************************/ void taskPriority( void ) { - // 1st pass for FPGA - execFPGAIn(); + // prevent most processing until UI has started communicating + if ( TRUE == uiHasCheckedIn ) + { + // 1st pass for FPGA + execFPGAIn(); - // monitor and process buttons - execButtons(); + // monitor and process buttons + execButtons(); - // monitor internal ADC channels - execInternalADC(); + // monitor internal ADC channels + execInternalADC(); - // monitor blood pump and flow - execBloodFlowMonitor(); + // monitor blood pump and flow + execBloodFlowMonitor(); - // control blood pump - execBloodFlowController(); + // 2nd pass for FPGA + execFPGAOut(); + } + else + { + uiHasCheckedIn = uiCommunicated(); + } - // 2nd pass for FPGA - execFPGAOut(); - // check in with watchdog manager checkInWithWatchdogMgmt( TASK_PRIORITY ); Index: firmware/App/Tasks/TaskPriority.h =================================================================== diff -u -reff7b1575f008f81b29ef906f6346fac6012d3ab -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/App/Tasks/TaskPriority.h (.../TaskPriority.h) (revision eff7b1575f008f81b29ef906f6346fac6012d3ab) +++ firmware/App/Tasks/TaskPriority.h (.../TaskPriority.h) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -19,7 +19,7 @@ // public definitions -#define TASK_PRIORITY_INTERVAL (5) +#define TASK_PRIORITY_INTERVAL (10) // public function prototypes Index: firmware/HD.dil =================================================================== diff -u -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/HD.dil (.../HD.dil) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) +++ firmware/HD.dil (.../HD.dil) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -1,4 +1,4 @@ -# RM46L852PGE 11/27/19 14:53:01 +# RM46L852PGE 12/02/19 18:19:10 # ARCH=RM46L852PGE # @@ -1473,17 +1473,17 @@ DRIVER.RTI.VAR.RTI_1_COMPARE_2_SOURCE.VALUE=0x00000100 DRIVER.RTI.VAR.RTI_1_COMPARE_3_FREQ.VALUE=0.000100000 DRIVER.RTI.VAR.RTI_1_FREQ.VALUE=103.335 -DRIVER.RTI.VAR.RTI_1_COMPARE_1_ACTUALTIME.VALUE=5.000 +DRIVER.RTI.VAR.RTI_1_COMPARE_1_ACTUALTIME.VALUE=10.000 DRIVER.RTI.VAR.RTI_1_COUNTER_1_UC_COMPARE.VALUE=9 -DRIVER.RTI.VAR.RTI_1_COMPARE_1_TIME.VALUE=5.000 +DRIVER.RTI.VAR.RTI_1_COMPARE_1_TIME.VALUE=10.0 DRIVER.RTI.VAR.RTI_1_COMPARE_3_UPDATE.VALUE=516675 DRIVER.RTI.VAR.RTI_1_CONTINUE_ON_SUSPEND_ENABLE.VALUE=0x00000000 DRIVER.RTI.VAR.RTI_1_COMPARE_1_INPUT_FREQ.VALUE=10.333500000 DRIVER.RTI.VAR.RTI_1_COMPARE_0_SOURCE.VALUE=0x00000000 DRIVER.RTI.VAR.RTI_1_COMPARE_2_TIME.VALUE=8.000 DRIVER.RTI.VAR.RTI_1_COMPARE_0_ACTUALTIME.VALUE=1.000 DRIVER.RTI.VAR.RTI_1_COUNTER_0_UC_COMPARE.VALUE=9 -DRIVER.RTI.VAR.RTI_1_COMPARE_1_UPDATE.VALUE=51668 +DRIVER.RTI.VAR.RTI_1_COMPARE_1_UPDATE.VALUE=103335 DRIVER.RTI.VAR.RTI_1_COMPARE_3_TIME.VALUE=50.0 DRIVER.RTI.VAR.RTI_1_COUNTER_0_NTU_SOURCE.VALUE=0 DRIVER.RTI.VAR.RTI_1_COMPARE_0_INPUT_FREQ.VALUE=10.333500000 @@ -1508,7 +1508,7 @@ DRIVER.RTI.VAR.RTI_1_NTU_3_FREQ.VALUE=220.000 DRIVER.RTI.VAR.RTI_1_COMPARE_0.VALUE=10334 DRIVER.RTI.VAR.RTI_1_COMPARE_2_ACTUALTIME.VALUE=8.000 -DRIVER.RTI.VAR.RTI_1_COMPARE_1.VALUE=51668 +DRIVER.RTI.VAR.RTI_1_COMPARE_1.VALUE=103335 DRIVER.RTI.VAR.RTI_1_COMPARE_2.VALUE=82668 DRIVER.RTI.VAR.RTI_1_COMPARE_3.VALUE=516675 DRIVER.RTI.VAR.RTI_1_COUNTER_0_NTU_FREQ.VALUE=0.000 Index: firmware/include/rti.h =================================================================== diff -u -reff7b1575f008f81b29ef906f6346fac6012d3ab -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/include/rti.h (.../rti.h) (revision eff7b1575f008f81b29ef906f6346fac6012d3ab) +++ firmware/include/rti.h (.../rti.h) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -256,7 +256,7 @@ #define RTI_CAPCTRL_CONFIGVALUE (0U | 0U) #define RTI_COMPCTRL_CONFIGVALUE (0x00000000U | 0x00000100U | 0x00000000U | 0x00000000U) #define RTI_UDCP0_CONFIGVALUE 10334U -#define RTI_UDCP1_CONFIGVALUE 51668U +#define RTI_UDCP1_CONFIGVALUE 103335U #define RTI_UDCP2_CONFIGVALUE 82668U #define RTI_UDCP3_CONFIGVALUE 516675U Index: firmware/source/rti.c =================================================================== diff -u -reff7b1575f008f81b29ef906f6346fac6012d3ab -r070554b23739bf16ea2bf9528ebabda1ce0ffeb3 --- firmware/source/rti.c (.../rti.c) (revision eff7b1575f008f81b29ef906f6346fac6012d3ab) +++ firmware/source/rti.c (.../rti.c) (revision 070554b23739bf16ea2bf9528ebabda1ce0ffeb3) @@ -123,10 +123,10 @@ rtiREG1->CMP[0U].UDCPx = 10334U; /** - Setup compare 1 value. This value is compared with selected free running counter. */ - rtiREG1->CMP[1U].COMPx = 51668U; + rtiREG1->CMP[1U].COMPx = 103335U; /** - Setup update compare 1 value. This value is added to the compare 1 value on each compare match. */ - rtiREG1->CMP[1U].UDCPx = 51668U; + rtiREG1->CMP[1U].UDCPx = 103335U; /** - Setup compare 2 value. This value is compared with selected free running counter. */ rtiREG1->CMP[2U].COMPx = 82668U;