Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r8acad167bcf7ad07043192007e59d253a5216e3a -rafa9d4924d55ac4fc98270a012e92dd1f6ee65d0 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 8acad167bcf7ad07043192007e59d253a5216e3a) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision afa9d4924d55ac4fc98270a012e92dd1f6ee65d0) @@ -44,6 +44,8 @@ /// Delay (in task intervals) after POST completes. #define POST_COMPLETED_DELAY ( 2 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) +/// Maximum wait time for UI to send its final POST result. +#define POST_UI_MAX_WAIT_TIME ( 2 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) // ********** private data ********** @@ -54,13 +56,17 @@ static BOOL uiPOSTPassed; ///< Final result for UI POST tests (TRUE = passed, FALSE = failed). static BOOL dgPOSTPassed; ///< Final result for DG POST tests (TRUE = passed, FALSE = failed). +static BOOL uiPOSTResultReceived; ///< Have we received a final POST result from the UI? +static BOOL dgPOSTResultReceived; ///< Have we received a final POST result from the DG? +static U32 waitForUIPostTimerCtr; ///< Timer counter to limit wait for UI final POST result. static U32 postCompleteDelayTimerCtr; ///< Timer counter for 2 second delay after POST completes and before transitioning to Standbymode. // ********** private function prototypes ********** static HD_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ); static SELF_TEST_STATUS_T execFWCompatibilityTest( void ); +static SELF_TEST_STATUS_T execUITest( void ); /*********************************************************************//** * @brief @@ -77,6 +83,9 @@ tempPOSTPassed = TRUE; uiPOSTPassed = FALSE; dgPOSTPassed = FALSE; + uiPOSTResultReceived = FALSE; + dgPOSTResultReceived = FALSE; + waitForUIPostTimerCtr = 0; postCompleteDelayTimerCtr = 0; } @@ -113,13 +122,11 @@ // Ignore stop button in this mode. } - // TODO - send POST status on CAN - // Execute current POST state *Note - these switch cases must be in same order as enum HD_POST_States switch ( postState ) { case POST_STATE_START: - postState = POST_STATE_FW_COMPATIBILITY; + postState = POST_STATE_FW_INTEGRITY; #ifdef SKIP_POST postState = POST_STATE_COMPLETED; #endif @@ -129,11 +136,6 @@ #endif break; - case POST_STATE_FW_COMPATIBILITY: - testStatus = execFWCompatibilityTest(); - postState = handlePOSTStatus( testStatus ); - break; - case POST_STATE_FW_INTEGRITY: testStatus = execIntegrityTest(); postState = handlePOSTStatus( testStatus ); @@ -213,11 +215,20 @@ postState = handlePOSTStatus( testStatus ); break; - // Should be last POST (and last POST test must be a test that completes in a single call) + case POST_STATE_UI_POST: + testStatus = execUITest(); + postState = handlePOSTStatus( testStatus ); + break; + + case POST_STATE_FW_COMPATIBILITY: + testStatus = execFWCompatibilityTest(); + postState = handlePOSTStatus( testStatus ); + break; + + // Should be last POST (and last POST test must be a test that completes in a single call) case POST_STATE_FPGA: testStatus = execFPGATest(); handlePOSTStatus( testStatus ); // Ignoring return value because last test - if ( TRUE == tempPOSTPassed ) { postState = POST_STATE_COMPLETED; @@ -228,8 +239,6 @@ } break; - // TODO - add POST test requiring all DG and UI POST tests to pass - case POST_STATE_COMPLETED: // Set overall HD POST status to "passed" postPassed = TRUE; @@ -280,6 +289,7 @@ void signalUIPOSTFinalResult( BOOL passed ) { uiPOSTPassed = passed; + uiPOSTResultReceived = TRUE; } /*********************************************************************//** @@ -294,6 +304,7 @@ void signalDGPOSTFinalResult( BOOL passed ) { dgPOSTPassed = passed; + dgPOSTResultReceived = TRUE; } /*********************************************************************//** @@ -372,9 +383,48 @@ { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; - // TODO - implement + // TODO - implement (need UI to include its version/compatibility info in its request for f/w versions so we can check compatibility) + //SW_COMPATIBILITY_REV return result; } +/*********************************************************************//** + * @brief + * The execUITest function executes the UI POST passed test. + * @details Inputs: uiPOSTResultReceived, uiPOSTPassed, waitForUIPostTimerCtr + * @details Outputs: waitForUIPostTimerCtr + * @return in progress, passed, or failed + *************************************************************************/ +static SELF_TEST_STATUS_T execUITest( void ) +{ +#ifndef DISABLE_UI_POST_TEST + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + + // UI should have sent POST results before we start this test + if ( TRUE == uiPOSTResultReceived ) + { + if ( TRUE == uiPOSTPassed ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_UI_POST_FAILED, 0 ) + result = SELF_TEST_STATUS_FAILED; + } + } + // If UI had not already sent POST results before we started, allow finite period for UI to send. + else if ( ++waitForUIPostTimerCtr > POST_UI_MAX_WAIT_TIME ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_UI_POST_FAILED, 1 ) + result = SELF_TEST_STATUS_FAILED; + } +#else + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; +#endif + + return result; +} + /**@}*/