Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r69b93e39861c5493d273f25d9e43cacd0b5819e2 -rfbb180e9b4830dd5f890f4f33f022ce375ff4012 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 69b93e39861c5493d273f25d9e43cacd0b5819e2) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision fbb180e9b4830dd5f890f4f33f022ce375ff4012) @@ -17,6 +17,7 @@ #include "Accel.h" #include "AlarmLamp.h" +#include "Battery.h" #include "BloodFlow.h" #include "Buttons.h" #include "Compatible.h" @@ -44,6 +45,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 +57,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 +84,9 @@ tempPOSTPassed = TRUE; uiPOSTPassed = FALSE; dgPOSTPassed = FALSE; + uiPOSTResultReceived = FALSE; + dgPOSTResultReceived = FALSE; + waitForUIPostTimerCtr = 0; postCompleteDelayTimerCtr = 0; } @@ -114,8 +124,6 @@ // 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 ) { @@ -125,13 +133,11 @@ case POST_STATE_FW_INTEGRITY: testStatus = execIntegrityTest(); - testStatus = SELF_TEST_STATUS_PASSED; postState = handlePOSTStatus( testStatus ); break; case POST_STATE_BATTERY: - // TODO implement the battery self test - testStatus = SELF_TEST_STATUS_PASSED; + testStatus = execBatteryTest(); postState = handlePOSTStatus( testStatus ); break; @@ -207,8 +213,7 @@ break; case POST_STATE_UI_POST: - // TODO implement the UI POST self test - testStatus = SELF_TEST_STATUS_PASSED; + testStatus = execUITest(); postState = handlePOSTStatus( testStatus ); break; @@ -217,11 +222,10 @@ postState = handlePOSTStatus( testStatus ); break; - // Should be last POST (and last POST test must be a test that completes in a single call) + // 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; @@ -232,8 +236,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; @@ -284,6 +286,7 @@ void signalUIPOSTFinalResult( BOOL passed ) { uiPOSTPassed = passed; + uiPOSTResultReceived = TRUE; } /*********************************************************************//** @@ -298,6 +301,7 @@ void signalDGPOSTFinalResult( BOOL passed ) { dgPOSTPassed = passed; + dgPOSTResultReceived = TRUE; } /*********************************************************************//** @@ -376,9 +380,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; +} + /**@}*/