Index: App/Contollers/Buttons.c =================================================================== diff -u -rda32ce10db35ffba9532f44d0227954cbd60413f -r0e042876ff72edbbaad7e5c9cc743c5a4a8c14b3 --- App/Contollers/Buttons.c (.../Buttons.c) (revision da32ce10db35ffba9532f44d0227954cbd60413f) +++ App/Contollers/Buttons.c (.../Buttons.c) (revision 0e042876ff72edbbaad7e5c9cc743c5a4a8c14b3) @@ -49,7 +49,7 @@ static void handleOffButtonProcessing( void ); static void handleStopButtonProcessing( void ); -static void pulseOffRequestSignal( void ); +static BOOL isCurrentOpModeOkToTurnOff( void ); /************************************************************************* * @brief initButtons @@ -114,7 +114,7 @@ { BOOL result = FALSE; - result = stopButtonPressPending; + result = stopButtonPressPending; // TODO - put a timeout on pending stop button, trigger s/w fault if not consumed in reasonable time stopButtonPressPending = FALSE; return result; @@ -170,7 +170,7 @@ { OP_MODE opMode = getCurrentOperationMode(); - if ( ( opMode == MODE_STAN ) || ( opMode == MODE_SERV ) || ( opMode == MODE_FAUL ) ) + if ( TRUE == isCurrentOpModeOkToTurnOff() ) { offButtonPressPending = TRUE; offRequestPulseCount = OFF_REQUEST_PULSE_COUNT; @@ -179,6 +179,29 @@ } /************************************************************************* + * @brief isCurrentOpModeOkToTurnOff + * The isCurrentOpModeOkToTurnOff function determines whether the system can \n + * be turned off in current operation mode. + * @details + * Inputs : Current operation mode. + * Outputs : none + * @param none + * @return true if can turn system off in current mode, false if not + *************************************************************************/ +static BOOL isCurrentOpModeOkToTurnOff( void ) +{ + OP_MODE opMode = getCurrentOperationMode(); + BOOL result = FALSE; + + if ( ( opMode == MODE_STAN ) || ( opMode == MODE_SERV ) || ( opMode == MODE_FAUL ) ) + { + result = TRUE; + } + + return result; +} + +/************************************************************************* * @brief handleOffButtonProcessing * The handleOffButtonProcessing function checks for and processes off button \n * activity. @@ -198,10 +221,10 @@ OP_MODE opMode = getCurrentOperationMode(); // if off request in a valid mode, send to UI for user confirmation - if ( ( opMode == MODE_STAN ) || ( opMode == MODE_SERV ) || ( opMode == MODE_FAUL ) ) + if ( TRUE == isCurrentOpModeOkToTurnOff() ) { // TODO - send off button to UI for user confirmation - // temporary - just pretend user confirmed for now + // TODO - remove later (just pretend user confirmed for now) userConfirmOffButton(); } } @@ -219,31 +242,12 @@ { offButtonPressPending = false; } - pulseOffRequestSignal(); + toggleCPLDOffRequest(); } } } /************************************************************************* - * @brief pulseOffRequestSignal - * The pulseOffRequestSignal function pulses the off request signal. - * @details - * Inputs : none - * Outputs : off request signal pulsed - * @param none - * @return none - *************************************************************************/ -static void pulseOffRequestSignal( void ) -{ - U32 d; - - setCPLDOffRequest( PIN_SIGNAL_HIGH ); - for ( d = 0; d < 1000; d++ ) - ; // ok to block briefly because we're shutting down anyway - setCPLDOffRequest( PIN_SIGNAL_LOW ); -} - -/************************************************************************* * @brief handleStopButtonProcessing * The handleStopButtonProcessing function checks for and processes stop button \n * activity.