Index: firmware/App/Controllers/Buttons.c =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -r747c714d2b4f80b598a66326d62a179aeefda390 --- firmware/App/Controllers/Buttons.c (.../Buttons.c) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Controllers/Buttons.c (.../Buttons.c) (revision 747c714d2b4f80b598a66326d62a179aeefda390) @@ -382,50 +382,49 @@ offRequestPulseTimer = 0; offRequestPulseCount = OFF_REQUEST_PULSE_COUNT; offButtonPressPending = TRUE; -} - -/*********************************************************************//** - * @brief - * The handleOffButtonProcessing function checks for and processes off button - * activity. - * @details Inputs: offButtonState, prevOffButtonState - * @details Outputs: offButtonPressPending, offRequestPulseCount, offRequestPulseTimer - * @return none - *************************************************************************/ -static void handleOffButtonProcessing( void ) -{ - // Handle button state transitions for off button - if ( getOffButtonState() != prevOffButtonState ) - { - if ( getOffButtonState() == BUTTON_STATE_PRESSED ) - { - // If off request in a valid mode, send to UI for user confirmation +} + +/*********************************************************************//** + * @brief + * The handleOffButtonProcessing function checks for and processes off button + * activity. + * @details Inputs: offButtonState, prevOffButtonState + * @details Outputs: offButtonPressPending, offRequestPulseCount, offRequestPulseTimer + * @return none + *************************************************************************/ +static void handleOffButtonProcessing( void ) +{ + // Handle button state transitions for off button + if ( getOffButtonState() != prevOffButtonState ) + { + if ( getOffButtonState() == BUTTON_STATE_PRESSED ) + { + // If off request in a valid mode, send to UI for user confirmation userConfirmOffButton( OFF_BUTTON_RSP_USER_REQUESTS_POWER_OFF ); // Log off button press - sendTreatmentLogEventData( OFF_BUTTON_PRESSED_EVENT, 0.0F, 0.0F ); - SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_BUTTON, BUTTON_OFF, BUTTON_STATE_PRESSED ) + SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_BUTTON, BUTTON_OFF, BUTTON_STATE_PRESSED ) } else { SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_BUTTON, BUTTON_OFF, BUTTON_STATE_RELEASED ) - } - prevOffButtonState = getOffButtonState(); - } - - // If off request has not been confirmed by user before it expires, cancel it - if ( TRUE == offRequestAwaitingUserConfirmation ) - { - offRequestPendingTimer += TASK_PRIORITY_INTERVAL; - if ( offRequestPendingTimer >= OFF_REQUEST_EXPIRATION_TIME_MS ) - { - offRequestAwaitingUserConfirmation = FALSE; - sendOffButtonMsgToUI( OFF_BUTTON_CMD_CANCEL_USER_CONFIRM_PROMPT ); - } - } - - // If user confirmed off button press, manage off request sequence - if ( TRUE == offButtonPressPending ) + } + prevOffButtonState = getOffButtonState(); + } + + // If off request has not been confirmed by user before it expires, cancel it + if ( TRUE == offRequestAwaitingUserConfirmation ) { + offRequestPendingTimer += TASK_PRIORITY_INTERVAL; + if ( offRequestPendingTimer >= OFF_REQUEST_EXPIRATION_TIME_MS ) + { + offRequestAwaitingUserConfirmation = FALSE; + sendOffButtonMsgToUI( OFF_BUTTON_CMD_CANCEL_USER_CONFIRM_PROMPT ); + } + } + + // If user confirmed off button press, manage off request sequence + if ( TRUE == offButtonPressPending ) + { // Delay power off to provide sub-systems time to prepare for shutdown offRequestDelayTimer += TASK_PRIORITY_INTERVAL; if ( offRequestDelayTimer >= OFF_REQUEST_DELAY_TIME_MS ) @@ -442,65 +441,64 @@ } toggleCPLDOffRequest(); } - } - } -} - -/*********************************************************************//** - * @brief - * The handleStopButtonProcessing function checks for and processes stop button - * activity. - * @details Inputs: stopButtonState, prevStopButtonState - * @details Outputs: stopButtonPressPending - * @return none - *************************************************************************/ -static void handleStopButtonProcessing( void ) -{ - // Handle button state transitions for stop button - if ( getStopButtonState() != prevStopButtonState ) - { - if ( getStopButtonState() == BUTTON_STATE_PRESSED ) - { - stopButtonPressPending = TRUE; + } + } +} + +/*********************************************************************//** + * @brief + * The handleStopButtonProcessing function checks for and processes stop button + * activity. + * @details Inputs: stopButtonState, prevStopButtonState + * @details Outputs: stopButtonPressPending + * @return none + *************************************************************************/ +static void handleStopButtonProcessing( void ) +{ + // Handle button state transitions for stop button + if ( getStopButtonState() != prevStopButtonState ) + { + if ( getStopButtonState() == BUTTON_STATE_PRESSED ) + { + stopButtonPressPending = TRUE; stopButtonPendingTimer = getMSTimerCount(); // Log stop button press - sendTreatmentLogEventData( STOP_BUTTON_PRESSED_EVENT, 0.0F, 0.0F ); SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_BUTTON, BUTTON_STOP, BUTTON_STATE_PRESSED ) } else { SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_BUTTON, BUTTON_STOP, BUTTON_STATE_RELEASED ) - } - prevStopButtonState = getStopButtonState(); - } - - // 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_MS ) ) - { - stopButtonPressPending = FALSE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_BUTTONS_STOP_BUTTON_NOT_CONSUMED ) - } - } -} - - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - -/*********************************************************************//** - * @brief - * The testSetOffButtonStateOverride function overrides the state of then - * off button with a given state.n - * @details Inputs: none - * @details Outputs: dataOffButtonState - * @param value override state for the off button - * @return TRUE if override successful, FALSE if not - *************************************************************************/ + } + prevStopButtonState = getStopButtonState(); + } + + // 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_MS ) ) + { + stopButtonPressPending = FALSE; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_BUTTONS_STOP_BUTTON_NOT_CONSUMED ) + } + } +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetOffButtonStateOverride function overrides the state of then + * off button with a given state.n + * @details Inputs: none + * @details Outputs: dataOffButtonState + * @param value override state for the off button + * @return TRUE if override successful, FALSE if not + *************************************************************************/ BOOL testSetOffButtonStateOverride( U32 value ) { BOOL result = FALSE;