Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r8bd1ae47aa13a843aa8abd6321ddc050deacb4a6 -rc137d3c7cb17b0364d745e10ff6dbd1901eb1baa --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 8bd1ae47aa13a843aa8abd6321ddc050deacb4a6) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision c137d3c7cb17b0364d745e10ff6dbd1901eb1baa) @@ -42,6 +42,8 @@ // ********** private definitions ********** +#define START_POST_DELAY_COUNT ( ( 1 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Start POST delay in count. + /// Delay (in task intervals) after POST completes. #define POST_COMPLETED_DELAY ( 2 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) @@ -64,10 +66,12 @@ static UI_VERSIONS_T uiVersion = { 0, 0, 0, 0, 0 }; ///< Version and compatibility information reported by UI. static DG_VERSIONS_T dgVersion = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ///< Version and compatibility information reported by DG. +static U32 startPOSTDelayCounter = 0; ///< Start POST delay counter. // ********** private function prototypes ********** static HD_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ); +static HD_POST_STATE_T handlePOSTStateStart( void ); static SELF_TEST_STATUS_T execFWCompatibilityTest( void ); static SELF_TEST_STATUS_T execUITest( void ); @@ -80,16 +84,17 @@ *************************************************************************/ void initInitAndPOSTMode( void ) { - postState = POST_STATE_START; - postCompleted = FALSE; - postPassed = FALSE; - tempPOSTPassed = TRUE; - uiPOSTPassed = FALSE; - dgPOSTPassed = FALSE; - uiPOSTResultReceived = FALSE; - dgPOSTResultReceived = FALSE; - waitForUIPostTimerCtr = 0; + postState = POST_STATE_START; + postCompleted = FALSE; + postPassed = FALSE; + tempPOSTPassed = TRUE; + uiPOSTPassed = FALSE; + dgPOSTPassed = FALSE; + uiPOSTResultReceived = FALSE; + dgPOSTResultReceived = FALSE; + waitForUIPostTimerCtr = 0; postCompleteDelayTimerCtr = 0; + startPOSTDelayCounter = 0; } /*********************************************************************//** @@ -98,14 +103,16 @@ * initialize & POST mode. * @details Inputs: none * @details Outputs: none - * @return none + * @return initial state *************************************************************************/ -void transitionToInitAndPOSTMode( void ) +U32 transitionToInitAndPOSTMode( void ) { // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); + + return postState; } /*********************************************************************//** @@ -130,9 +137,7 @@ switch ( postState ) { case POST_STATE_START: - sendUIVersionRequest(); - SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_STARTUP, 0, 0 ) - postState = POST_STATE_FW_INTEGRITY; + postState = handlePOSTStateStart(); break; case POST_STATE_FW_INTEGRITY: @@ -408,6 +413,38 @@ /*********************************************************************//** * @brief + * The handlePOSTStateStart function handles the POST start state. + * @details Inputs: startPOSTDelayCounter + * @details Outputs: startPOSTDelayCounter + * @return next POST state + *************************************************************************/ +static HD_POST_STATE_T handlePOSTStateStart( void ) +{ + HD_POST_STATE_T state = POST_STATE_START; + + // There is a delay before starting POST to make sure the CAN bus is up and listening so + // when the event data can be sent + if ( ++startPOSTDelayCounter > START_POST_DELAY_COUNT ) + { + sendUIVersionRequest(); + + // Send the startup event + SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_STARTUP, 0, 0 ) + // Send the first submode change event. It is the mode Init and it does not start from a previous + // mode previous and current are both published as Init + SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_OP_MODE_CHANGE, MODE_INIT, MODE_INIT ) + state = POST_STATE_FW_INTEGRITY; +#ifdef SKIP_POST + state = DG_POST_STATE_COMPLETED; +#endif + startPOSTDelayCounter = 0; + } + + return state; +} + +/*********************************************************************//** + * @brief * The execFWCompatibilityTest function executes the firmware compatibility test. * @details Inputs: none * @details Outputs: none