Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -rb7318644527939f0b8b01bd3999a9c187c64f40e -r91aa11a47f3b3c744cbbfd9e9c1bd240263aa1bd --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision b7318644527939f0b8b01bd3999a9c187c64f40e) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 91aa11a47f3b3c744cbbfd9e9c1bd240263aa1bd) @@ -19,15 +19,18 @@ #include "AlarmLamp.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 "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 +39,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 +73,9 @@ postCompleted = FALSE; postPassed = FALSE; tempPOSTPassed = TRUE; + uiPOSTPassed = FALSE; + dgPOSTPassed = FALSE; + postCompleteDelayTimerCtr = 0; } /*********************************************************************//** @@ -101,7 +117,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,13 +127,17 @@ #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: + postState = POST_STATE_WATCHDOG; + break; + + case POST_STATE_WATCHDOG: + testStatus = execWatchdogTest(); postState = handlePOSTStatus( testStatus ); break; @@ -152,6 +172,8 @@ postState = POST_STATE_COMPLETED; testStatus = SELF_TEST_STATUS_PASSED; #endif + testStatus = execAlarmAudioSelfTest(); + postState = handlePOSTStatus( testStatus ); break; case POST_STATE_ALARM_LAMP: @@ -173,9 +195,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 ) @@ -188,14 +215,20 @@ } 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: @@ -220,11 +253,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). @@ -265,12 +326,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 @@ -280,3 +348,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; +} + +/**@}*/