Index: firmware/App/Controllers/Buttons.c =================================================================== diff -u -rc0273c73da6b6dee4ad6f1d54cb6c6f27a262b5b -r8fdca8ef380555c6c93e30b517258988333ffd89 --- firmware/App/Controllers/Buttons.c (.../Buttons.c) (revision c0273c73da6b6dee4ad6f1d54cb6c6f27a262b5b) +++ firmware/App/Controllers/Buttons.c (.../Buttons.c) (revision 8fdca8ef380555c6c93e30b517258988333ffd89) @@ -56,10 +56,11 @@ } OFF_BUTTON_RSP_T; #define OFF_REQUEST_PULSE_COUNT 4 -#define OFF_REQUEST_PULSE_INTVL 50 // ms -#define STOP_BUTTON_PENDING_TIMEOUT 500 // ms -#define STUCK_BUTTON_TIMEOUT 1000 // ms -#define OFF_REQUEST_EXPIRATION_TIME (1000 * 60) // ms (1 minute) +#define OFF_REQUEST_PULSE_INTVL_MS 50 // ms +#define OFF_REQUEST_DELAY_TIME_MS 2000 // ms +#define STOP_BUTTON_PENDING_TIMEOUT_MS 500 // ms +#define STUCK_BUTTON_TIMEOUT_MS 1000 // ms +#define OFF_REQUEST_EXPIRATION_TIME_MS (1000 * 60) // ms (1 minute) #define USER_CONFIRMED 1 #define USER_REJECTED 0 @@ -72,7 +73,8 @@ static U32 offRequestPendingTimer = 0; static BOOL offButtonPressPending = FALSE; static U32 offRequestPulseCount = 0; -static U32 offRequestPulseTimer = 0; +static U32 offRequestPulseTimer = 0; +static U32 offRequestDelayTimer = 0; DATA_DECL( BUTTON_STATE_T, StopButtonState, dataStopButtonState, BUTTON_STATE_RELEASED, BUTTON_STATE_PRESSED ); static BUTTON_STATE_T prevStopButtonState = BUTTON_STATE_RELEASED; @@ -211,7 +213,7 @@ buttonSelfTestState = BUTTON_SELF_TEST_STATE_COMPLETE; result = SELF_TEST_STATUS_PASSED; } - else if ( TRUE == didTimeout( buttonSelfTestTimerCount, STUCK_BUTTON_TIMEOUT ) ) + else if ( TRUE == didTimeout( buttonSelfTestTimerCount, STUCK_BUTTON_TIMEOUT_MS ) ) { U32 almData = ( dataStopButtonState.data == BUTTON_STATE_PRESSED ? BUTTON_STOP : BUTTON_OFF ); @@ -361,7 +363,7 @@ if ( TRUE == offRequestAwaitingUserConfirmation ) { offRequestPendingTimer += TASK_PRIORITY_INTERVAL; - if ( offRequestPendingTimer >= OFF_REQUEST_EXPIRATION_TIME ) + if ( offRequestPendingTimer >= OFF_REQUEST_EXPIRATION_TIME_MS ) { offRequestAwaitingUserConfirmation = FALSE; sendOffButtonMsgToUI( OFF_BUTTON_CMD_CANCEL_USER_CONFIRM_PROMPT ); @@ -370,17 +372,23 @@ // if user confirmed off button press, manage off request sequence if ( TRUE == offButtonPressPending ) - { - offRequestPulseTimer += TASK_PRIORITY_INTERVAL; - if ( offRequestPulseTimer >= OFF_REQUEST_PULSE_INTVL ) - { - offRequestPulseTimer = 0; - offRequestPulseCount--; - if ( offRequestPulseCount == 0 ) - { - offButtonPressPending = false; - } - toggleCPLDOffRequest(); + { + // delay power off to provide sub-systems time to prepare for shutdown + offRequestDelayTimer += TASK_PRIORITY_INTERVAL; + if ( offRequestDelayTimer >= OFF_REQUEST_DELAY_TIME_MS ) + { + // power off sequence is 4 50 ms toggles of the off request output signal + offRequestPulseTimer += TASK_PRIORITY_INTERVAL; + if ( offRequestPulseTimer >= OFF_REQUEST_PULSE_INTVL_MS ) + { + offRequestPulseTimer = 0; + offRequestPulseCount--; + if ( offRequestPulseCount == 0 ) + { + offButtonPressPending = false; + } + toggleCPLDOffRequest(); + } } } } @@ -412,7 +420,7 @@ if ( TRUE == stopButtonPressPending ) { // if stop button not consumed within a reasonable time, s/w fault - if ( TRUE == didTimeout( stopButtonPendingTimer, STOP_BUTTON_PENDING_TIMEOUT ) ) + if ( TRUE == didTimeout( stopButtonPendingTimer, STOP_BUTTON_PENDING_TIMEOUT_MS ) ) { stopButtonPressPending = FALSE; SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_BUTTONS_STOP_BUTTON_NOT_CONSUMED )