Index: App/Controllers/Buttons.c =================================================================== diff -u -r3323966fe741edbb36dffc78317ccf06ed93a68e -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 --- App/Controllers/Buttons.c (.../Buttons.c) (revision 3323966fe741edbb36dffc78317ccf06ed93a68e) +++ App/Controllers/Buttons.c (.../Buttons.c) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) @@ -24,13 +24,6 @@ // ********** private definitions ********** -typedef enum Button_States -{ - BUTTON_STATE_RELEASED = 0, - BUTTON_STATE_PRESSED, - NUM_OF_BUTTON_STATES -} BUTTON_STATE_T; - typedef enum Button_Self_Test_States { BUTTON_SELF_TEST_STATE_START = 0, @@ -49,11 +42,13 @@ // ********** private data ********** -static BUTTON_STATE_T offButtonState = BUTTON_STATE_RELEASED; +DATA_DECL( BUTTON_STATE_T, OffButtonState, dataOffButtonState, BUTTON_STATE_RELEASED, BUTTON_STATE_PRESSED ); +//static BUTTON_STATE_T offButtonState = BUTTON_STATE_RELEASED; static BUTTON_STATE_T prevOffButtonState = BUTTON_STATE_RELEASED; static BOOL offButtonPressPending = FALSE; -static BUTTON_STATE_T stopButtonState = BUTTON_STATE_RELEASED; +DATA_DECL( BUTTON_STATE_T, StopButtonState, dataStopButtonState, BUTTON_STATE_RELEASED, BUTTON_STATE_PRESSED ); +//static BUTTON_STATE_T stopButtonState = BUTTON_STATE_RELEASED; static BUTTON_STATE_T prevStopButtonState = BUTTON_STATE_RELEASED; static BOOL stopButtonPressPending = FALSE; static U32 stopButtonPendingTimer = 0; @@ -81,11 +76,11 @@ *************************************************************************/ void initButtons( void ) { - offButtonState = BUTTON_STATE_RELEASED; + //offButtonState = BUTTON_STATE_RELEASED; prevOffButtonState = BUTTON_STATE_RELEASED; offButtonPressPending = FALSE; - stopButtonState = BUTTON_STATE_RELEASED; + //stopButtonState = BUTTON_STATE_RELEASED; prevStopButtonState = BUTTON_STATE_RELEASED; stopButtonPressPending = FALSE; stopButtonPendingTimer = 0; @@ -112,8 +107,8 @@ PIN_SIGNAL_STATE_T stop = getCPLDStopButton(); // set current button states read from CPLD - offButtonState = ( off == PIN_SIGNAL_HIGH ? BUTTON_STATE_PRESSED : BUTTON_STATE_RELEASED ); - stopButtonState = ( stop == PIN_SIGNAL_HIGH ? BUTTON_STATE_PRESSED : BUTTON_STATE_RELEASED ); + dataOffButtonState.data = ( off == PIN_SIGNAL_HIGH ? BUTTON_STATE_PRESSED : BUTTON_STATE_RELEASED ); + dataStopButtonState.data = ( stop == PIN_SIGNAL_HIGH ? BUTTON_STATE_PRESSED : BUTTON_STATE_RELEASED ); // handle button state transitions for stop button handleStopButtonProcessing(); @@ -143,41 +138,29 @@ } /************************************************************************* - * @brief isButtonPressedRaw - * The isButtonPressedRaw function determines whether a given button is currently \n - * pressed. + * @brief getOffButtonState + * The getOffButtonState function determines whether the off button is \n + * currently pressed. * @details - * Inputs : offButtonState, prevOffButtonState, stopButtonState, prevStopButtonState + * Inputs : dataOffButtonState, prevOffButtonState * Outputs : none - * @param button - * @return true if given button is pressed, false if not + * @param none + * @return BUTTON_STATE_PRESSED if off button pressed, BUTTON_STATE_RELEASED if not *************************************************************************/ -BOOL isButtonPressedRaw( BUTTON_T button ) -{ - BOOL result = FALSE; +DATA_GET( BUTTON_STATE_T, getOffButtonState, dataOffButtonState ) - switch ( button ) - { - case BUTTON_OFF: - if ( offButtonState == BUTTON_STATE_PRESSED ) - { - result = TRUE; - } - break; - case BUTTON_STOP: - if ( stopButtonState == BUTTON_STATE_PRESSED ) - { - result = TRUE; - } - break; - default: - // TODO - s/w fault - break; - } +/************************************************************************* + * @brief getStopButtonState + * The getStopButtonState function determines whether the stop button is \n + * currently pressed. + * @details + * Inputs : dataStopButtonState, prevStopButtonState + * Outputs : none + * @param none + * @return BUTTON_STATE_PRESSED if stop button pressed, BUTTON_STATE_RELEASED if not + *************************************************************************/ +DATA_GET( BUTTON_STATE_T, getStopButtonState, dataStopButtonState ) - return result; -} - /************************************************************************* * @brief userConfirmOffButton * The userConfirmOffButton function handles user confirmation of the off \n @@ -230,7 +213,7 @@ // no break here so we pass through directly to in progress processing case BUTTON_SELF_TEST_STATE_IN_PROGRESS: - if ( ( offButtonState == BUTTON_STATE_RELEASED ) && ( stopButtonState == BUTTON_STATE_RELEASED ) ) + if ( ( dataOffButtonState.data == BUTTON_STATE_RELEASED ) && ( dataStopButtonState.data == BUTTON_STATE_RELEASED ) ) { result = SELF_TEST_STATUS_PASSED; buttonSelfTestState = BUTTON_SELF_TEST_STATE_COMPLETE; @@ -266,7 +249,7 @@ * Inputs : Current operation mode. * Outputs : none * @param none - * @return true if can turn system off in current mode, false if not + * @return TRUE if can turn system off in current mode, FALSE if not *************************************************************************/ static BOOL isCurrentOpModeOkToTurnOff( void ) { @@ -294,9 +277,9 @@ static void handleOffButtonProcessing( void ) { // handle button state transitions for off button - if ( offButtonState != prevOffButtonState ) + if ( getOffButtonState() != prevOffButtonState ) { - if ( offButtonState == BUTTON_STATE_PRESSED ) + if ( getOffButtonState() == BUTTON_STATE_PRESSED ) { // if off request in a valid mode, send to UI for user confirmation if ( TRUE == isCurrentOpModeOkToTurnOff() ) @@ -308,9 +291,10 @@ #endif } } - prevOffButtonState = offButtonState; + prevOffButtonState = getOffButtonState(); } + // if user confirmed off button press, manage off request sequence if ( TRUE == offButtonPressPending ) { offRequestPulseTimer += TASK_PRIORITY_INTERVAL; @@ -340,14 +324,14 @@ static void handleStopButtonProcessing( void ) { // handle button state transitions for stop button - if ( stopButtonState != prevStopButtonState ) + if ( getStopButtonState() != prevStopButtonState ) { - if ( stopButtonState == BUTTON_STATE_PRESSED ) + if ( getStopButtonState() == BUTTON_STATE_PRESSED ) { stopButtonPressPending = TRUE; stopButtonPendingTimer = getMSTimerCount(); } - prevStopButtonState = stopButtonState; + prevStopButtonState = getStopButtonState(); } // handle when a stop button press is pending @@ -361,3 +345,110 @@ } } + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/************************************************************************* + * @brief testSetOffButtonStateOverride + * The testSetOffButtonStateOverride function overrides the state of the \n + * off button with a given state. + * @details + * Inputs : none + * Outputs : dataOffButtonState + * @param state : override state for the off button + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetOffButtonStateOverride( BUTTON_STATE_T state ) +{ + BOOL result = FALSE; + + // verify test login successfully completed before executing override + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dataOffButtonState.ovData = state; + dataOffButtonState.override = OVERRIDE_KEY; + } + + return result; +} + +/************************************************************************* + * @brief testResetOffButtonStateOverride + * The testResetOffButtonStateOverride function resets the override of the \n + * state of the off button. + * @details + * Inputs : none + * Outputs : dataOffButtonState + * @param none + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetOffButtonStateOverride( void ) +{ + BOOL result = FALSE; + + // verify test login successfully completed before executing override reset + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dataOffButtonState.override = OVERRIDE_RESET; + dataOffButtonState.ovData = dataOffButtonState.ovInitData; + } + + return result; +} + +/************************************************************************* + * @brief testSetStopButtonStateOverride + * The testSetStopButtonStateOverride function overrides the state of the \n + * stop button with a given state. + * @details + * Inputs : none + * Outputs : dataStopButtonState + * @param state : override state for the stop button + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetStopButtonStateOverride( BUTTON_STATE_T state ) +{ + BOOL result = FALSE; + + // verify test login successfully completed before executing override + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dataStopButtonState.ovData = state; + dataStopButtonState.override = OVERRIDE_KEY; + } + + return result; +} + +/************************************************************************* + * @brief testResetStopButtonStateOverride + * The testResetStopButtonStateOverride function resets the override of the \n + * state of the stop button. + * @details + * Inputs : none + * Outputs : dataStopButtonState + * @param none + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetStopButtonStateOverride( void ) +{ + BOOL result = FALSE; + + // verify test login successfully completed before executing override reset + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dataStopButtonState.override = OVERRIDE_RESET; + dataStopButtonState.ovData = dataStopButtonState.ovInitData; + } + + return result; +} +