Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -rdd1c45cd9a612aaf63de14ffddecab573ead6095 -r8acad167bcf7ad07043192007e59d253a5216e3a --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision dd1c45cd9a612aaf63de14ffddecab573ead6095) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 8acad167bcf7ad07043192007e59d253a5216e3a) @@ -17,17 +17,22 @@ #include "Accel.h" #include "AlarmLamp.h" +#include "Battery.h" #include "BloodFlow.h" #include "Buttons.h" +#include "Compatible.h" #include "CPLD.h" #include "DialInFlow.h" #include "FPGA.h" -#include "OperationModes.h" -#include "RTC.h" -#include "WatchdogMgmt.h" +#include "Integrity.h" #include "ModeInitPOST.h" #include "NVDataMgmt.h" +#include "OperationModes.h" +#include "RTC.h" +#include "SystemCommMessages.h" +#include "TaskGeneral.h" #include "Valves.h" +#include "WatchdogMgmt.h" /** * @addtogroup HDInitAndPOSTMode @@ -36,16 +41,26 @@ // ********** private definitions ********** +/// Delay (in task intervals) after POST completes. +#define POST_COMPLETED_DELAY ( 2 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) + + // ********** private data ********** -static HD_POST_STATE_T postState = POST_STATE_START; ///< Current state of initialize and POST mode. -static BOOL postCompleted = FALSE; ///< Flag indicates whether POST is completed. -static BOOL postPassed = FALSE; ///< Flag indicates all POST tests passed. -static BOOL tempPOSTPassed = TRUE; ///< Flag indicates all POST tests have passed so far. +static HD_POST_STATE_T postState; ///< Current state of initialize and POST mode. +static BOOL postCompleted; ///< Flag indicates whether POST is completed. +static BOOL postPassed; ///< Flag indicates all POST tests passed. +static BOOL tempPOSTPassed; ///< Flag indicates all POST tests have passed so far. +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 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 ); /*********************************************************************//** * @brief @@ -60,6 +75,9 @@ postCompleted = FALSE; postPassed = FALSE; tempPOSTPassed = TRUE; + uiPOSTPassed = FALSE; + dgPOSTPassed = FALSE; + postCompleteDelayTimerCtr = 0; } /*********************************************************************//** @@ -101,7 +119,7 @@ switch ( postState ) { case POST_STATE_START: - postState = POST_STATE_WATCHDOG; + postState = POST_STATE_FW_COMPATIBILITY; #ifdef SKIP_POST postState = POST_STATE_COMPLETED; #endif @@ -111,16 +129,26 @@ #endif break; - case POST_STATE_WATCHDOG: - testStatus = execWatchdogTest(); + case POST_STATE_FW_COMPATIBILITY: + testStatus = execFWCompatibilityTest(); postState = handlePOSTStatus( testStatus ); break; - case POST_STATE_FPGA: - testStatus = execFPGATest(); + case POST_STATE_FW_INTEGRITY: + testStatus = execIntegrityTest(); postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_BATTERY: + testStatus = execBatteryTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case POST_STATE_WATCHDOG: + testStatus = execWatchdogTest(); + postState = handlePOSTStatus( testStatus ); + break; + case POST_STATE_RTC: testStatus = execRTCSelfTest(); postState = handlePOSTStatus( testStatus ); @@ -146,6 +174,17 @@ postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_ALARM_AUDIO: +#ifdef DONT_SKIP_NV_POST + // Skip the rest of the POSTs + postState = POST_STATE_COMPLETED; + testStatus = SELF_TEST_STATUS_PASSED; +#else + testStatus = execAlarmAudioSelfTest(); + postState = handlePOSTStatus( testStatus ); +#endif + break; + case POST_STATE_ALARM_LAMP: #ifdef DONT_SKIP_NV_POST // Skip the rest of the POSTs @@ -169,9 +208,14 @@ postState = handlePOSTStatus( testStatus ); break; - // Should be last POST case POST_STATE_STUCK_BUTTON: testStatus = execStuckButtonTest(); + 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 ) @@ -184,21 +228,26 @@ } 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; // Set overall HD POST completed status to TRUE postCompleted = TRUE; - // TODO - send POST status on CAN - // Go to standby mode - requestNewOperationMode( MODE_STAN ); + // Broadcast final POST passed + sendPOSTFinalResult( TRUE ); + // Delay before going to standby mode + if ( ++postCompleteDelayTimerCtr > POST_COMPLETED_DELAY ) + { + requestNewOperationMode( MODE_STAN ); + } break; case POST_STATE_FAILED: // Should not get here - any failed post test should have already triggered a fault and taken us to fault mode default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_INIT_POST_INVALID_POST_STATE, postState ) - postState = POST_STATE_FAILED; break; } @@ -216,11 +265,39 @@ *************************************************************************/ void signalAlarmActionToInitAndPOSTMode( ALARM_ACTION_T action ) { + // TODO - anything required here? +} +/*********************************************************************//** + * @brief + * The signalUIPOSTFinalResult function records the final POST result for + * the UI. + * @details Inputs: none + * @details Outputs: uiPOSTPassed + * @param passed TRUE if UI POST tests all passed, FALSE if any UI POST test failed + * @return none + *************************************************************************/ +void signalUIPOSTFinalResult( BOOL passed ) +{ + uiPOSTPassed = passed; } /*********************************************************************//** * @brief + * The signalDGPOSTFinalResult function records the final POST result for + * the DG. + * @details Inputs: none + * @details Outputs: dgPOSTPassed + * @param passed TRUE if DG POST tests all passed, FALSE if any DG POST test failed + * @return none + *************************************************************************/ +void signalDGPOSTFinalResult( BOOL passed ) +{ + dgPOSTPassed = passed; +} + +/*********************************************************************//** + * @brief * The isPOSTCompleted function determines whether all HD POST have * been run and completed. If true, call the isPOSTPassed() to see final * result (pass/fail). @@ -261,12 +338,19 @@ if ( testStatus == SELF_TEST_STATUS_PASSED ) { - result = (HD_POST_STATE_T)((int)postState + 1); // Move on to next POST test + // Broadcast passed POST result + sendPOSTTestResult( (HD_POST_STATE_T)((int)postState), TRUE ); + // Move on to next POST test + result = (HD_POST_STATE_T)((int)postState + 1); } else if ( testStatus == SELF_TEST_STATUS_FAILED ) { - requestAlarmLampPattern( LAMP_PATTERN_FAULT ); + // At least one POST has failed tempPOSTPassed = FALSE; + // Broadcast failed POST results + sendPOSTTestResult( (HD_POST_STATE_T)((int)postState), FALSE ); + sendPOSTFinalResult( FALSE ); + // Test that failed should have triggered a fault which will request fault mode, so should POST state machine should never see FAILED state and will fault if it does result = POST_STATE_FAILED; } else @@ -276,3 +360,21 @@ return result; } + +/*********************************************************************//** + * @brief + * The execFWCompatibilityTest function executes the firmware compatibility test. + * @details Inputs: none + * @details Outputs: none + * @return in progress, passed, or failed + *************************************************************************/ +static SELF_TEST_STATUS_T execFWCompatibilityTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; + + // TODO - implement + + return result; +} + +/**@}*/