Index: App/Contollers/Buttons.c =================================================================== diff -u -r0e042876ff72edbbaad7e5c9cc743c5a4a8c14b3 -rad8ad611c910747eef92336a30b6520a83409532 --- App/Contollers/Buttons.c (.../Buttons.c) (revision 0e042876ff72edbbaad7e5c9cc743c5a4a8c14b3) +++ App/Contollers/Buttons.c (.../Buttons.c) (revision ad8ad611c910747eef92336a30b6520a83409532) @@ -17,6 +17,7 @@ #include "Common.h" #include "CPLD.h" #include "TaskPriority.h" +#include "Timers.h" #include "OperationModes.h" #include "Buttons.h" @@ -29,8 +30,9 @@ NUM_OF_BUTTON_STATES } BUTTON_STATE_T; -#define OFF_REQUEST_PULSE_COUNT 4 -#define OFF_REQUEST_PULSE_INTVL 50 // ms +#define OFF_REQUEST_PULSE_COUNT 4 +#define OFF_REQUEST_PULSE_INTVL 50 // ms +#define STOP_BUTTON_PENDING_TIMEOUT 500 // ms // ********** private data ********** @@ -41,6 +43,7 @@ static BUTTON_STATE_T stopButtonState = BUTTON_STATE_RELEASED; static BUTTON_STATE_T prevStopButtonState = BUTTON_STATE_RELEASED; static BOOL stopButtonPressPending = FALSE; +static U32 stopButtonPendingTimer = 0; static U32 offRequestPulseCount = 0; static U32 offRequestPulseTimer = 0; @@ -69,6 +72,7 @@ stopButtonState = BUTTON_STATE_RELEASED; prevStopButtonState = BUTTON_STATE_RELEASED; stopButtonPressPending = FALSE; + stopButtonPendingTimer = 0; offRequestPulseCount = 0; offRequestPulseTimer = 0; @@ -259,14 +263,25 @@ *************************************************************************/ static void handleStopButtonProcessing( void ) { - // handle button state transitions for stop button if ( stopButtonState != prevStopButtonState ) + // handle button state transitions for stop button if ( stopButtonState != prevStopButtonState ) { if ( stopButtonState == BUTTON_STATE_PRESSED ) { stopButtonPressPending = TRUE; + stopButtonPendingTimer = getMSTimerCount(); } prevStopButtonState = stopButtonState; } + + // handle when a stop button press is pending + if ( TRUE == stopButtonPressPending ) + { + // if stop button not consumed within a reasonable time, s/w fault + if ( TRUE == didTimeout( stopButtonPendingTimer, STOP_BUTTON_PENDING_TIMEOUT ) ) + { + // TODO - s/w fault + } + } }