Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r499e5de29e706d09f79ba22511068990c4044e84 -r43ec4d03e577681a98ea4ed58082ffd6ab012fd3 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 499e5de29e706d09f79ba22511068990c4044e84) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 43ec4d03e577681a98ea4ed58082ffd6ab012fd3) @@ -1,173 +1,185 @@ /************************************************************************** - * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. - * - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN - * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * @file ModeInitPOST.c - * - * @date 11-Dec-2019 - * @author L. Baloa - * - * @brief Top-level state machine for the initialize & POST mode. - * - **************************************************************************/ +* +* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file ModeInitPOST.c +* +* @author (last) Quang Nguyen +* @date (last) 29-Jul-2020 +* +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 +* +***************************************************************************/ #include "CPLD.h" #include "FPGA.h" #include "OperationModes.h" +#include "TemperatureSensors.h" #include "WatchdogMgmt.h" #include "ModeInitPOST.h" +#include "Heaters.h" +#include "Pressures.h" -// ********** private definitions ********** +/** + * @addtogroup DGInitAndPOSTMode + * @{ + */ -typedef enum POST_States -{ - POST_STATE_START = 0, - POST_STATE_FPGA, - POST_STATE_WATCHDOG, - POST_STATE_COMPLETED, - POST_STATE_FAILED, - NUM_OF_POST_STATES -} POST_STATE_T; - // ********** private data ********** -static POST_STATE_T postState = POST_STATE_START; -static BOOL postCompleted = FALSE; -static BOOL postPassed = FALSE; -static BOOL tempPOSTPassed = TRUE; +static DG_POST_STATE_T postState = DG_POST_STATE_START; ///< Currently active initialize & POST state. +static BOOL postCompleted = FALSE; ///< Flag indicating POST completed. +static BOOL postPassed = FALSE; ///< Flag indicating all POST tests passed. +static BOOL tempPOSTPassed = TRUE; ///< Temporary flag indicating all POST tests completed so far have passed. // ********** private function prototypes ********** -static POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ); +static DG_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ); -/************************************************************************* - * @brief initInitAndPOSTMode +/*********************************************************************//** + * @brief * The initInitAndPOSTMode function initializes the Initialize & POST Mode module. * @details * Inputs : none * Outputs : Initialize & POST Mode module initialized. - * @param none * @return none *************************************************************************/ void initInitAndPOSTMode( void ) { - postState = POST_STATE_START; + postState = DG_POST_STATE_START; postCompleted = FALSE; postPassed = FALSE; tempPOSTPassed = TRUE; } -/************************************************************************* - * @brief transitionToInitAndPOSTMode +/*********************************************************************//** + * @brief * The transitionToInitAndPOSTMode function prepares for transition to\n * initialize & POST mode. * @details * Inputs : none * Outputs : - * @param none * @return none *************************************************************************/ void transitionToInitAndPOSTMode( void ) { + // TODO - anything needed here? } -/************************************************************************* - * @brief execInitAndPOSTMode +/*********************************************************************//** + * @brief * The execInitAndPOSTMode function executes the Initialize & POST Mode state machine. * @details - * Inputs : none - * Outputs : - * @param none - * @return none + * Inputs : postState + * Outputs : POST state machine executed + * @return current state. *************************************************************************/ -void execInitAndPOSTMode( void ) +U32 execInitAndPOSTMode( void ) { SELF_TEST_STATUS_T testStatus = SELF_TEST_STATUS_IN_PROGRESS; // execute current POST state switch ( postState ) { - case POST_STATE_START: - postState = POST_STATE_FPGA; + case DG_POST_STATE_START: + postState = DG_POST_STATE_FPGA; + // FOR TESTING REMOVE + //postState = POST_STATE_TEMPERATURE_SENSORS; break; - case POST_STATE_FPGA: + case DG_POST_STATE_FPGA: testStatus = execFPGATest(); postState = handlePOSTStatus( testStatus ); break; - case POST_STATE_WATCHDOG: + case DG_POST_STATE_TEMPERATURE_SENSORS: + testStatus = execTemperatureSensorsSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_HEATERS: + testStatus = execHeatersSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_PRESSURES: + testStatus = execPressureSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_WATCHDOG: testStatus = execWatchdogTest(); handlePOSTStatus( testStatus ); // ignoring return value because last test if ( TRUE == tempPOSTPassed ) { - postState = POST_STATE_COMPLETED; + postState = DG_POST_STATE_COMPLETED; } else { - postState = POST_STATE_FAILED; + postState = DG_POST_STATE_FAILED; } break; - case POST_STATE_COMPLETED: + case DG_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 ); + requestNewOperationMode( DG_MODE_STAN ); break; - case POST_STATE_FAILED: + case DG_POST_STATE_FAILED: // TODO - send POST status on CAN // will want POST faults to wait for us to get here before sending us to fault mode - requestNewOperationMode( MODE_FAUL ); + requestNewOperationMode( DG_MODE_FAUL ); break; default: - postState = POST_STATE_FAILED; // TODO - s/w fault + postState = DG_POST_STATE_FAILED; break; } + + return postState; } -/************************************************************************* - * @brief isPOSTCompleted +/*********************************************************************//** + * @brief * The isPOSTCompleted function determines whether all HD POST have \n * been run and completed. If true, call the isPOSTPassed() to see final \n * result (pass/fail). * @details * Inputs : postCompleted * Outputs : none - * @param none * @return true if all HD POST tests have completed, false if not *************************************************************************/ BOOL isPOSTCompleted( void ) { return postCompleted; } -/************************************************************************* - * @brief isPOSTPassed +/*********************************************************************//** + * @brief * The isPOSTPassed function determines whether all HD POST have passed. \n * Call this function after POST is complete (call isPOSTCompleted function). * @details * Inputs : postPassed * Outputs : none - * @param none * @return true if all HD POST tests have passed, false if not *************************************************************************/ BOOL isPOSTPassed( void ) { return postPassed; } -/************************************************************************* - * @brief handlePOSTStatus +/*********************************************************************//** + * @brief * The handlePOSTStatus function handles a status result returned by a * POST function. * @details @@ -176,13 +188,13 @@ * @param testStatus * @return recommended next POST state *************************************************************************/ -static POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ) +static DG_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ) { - POST_STATE_T result = postState; + DG_POST_STATE_T result = postState; if ( ( testStatus == SELF_TEST_STATUS_PASSED ) || ( testStatus == SELF_TEST_STATUS_FAILED ) ) { - result = (POST_STATE_T)((int)postState + 1); // move on to next POST test + result = (DG_POST_STATE_T)((int)postState + 1); // move on to next POST test if ( testStatus == SELF_TEST_STATUS_FAILED ) { tempPOSTPassed = FALSE; @@ -191,3 +203,19 @@ return result; } + +/*********************************************************************//** + * @brief + * The getCurrentInitAndPOSTState function returns the current state of the \n + * initialize & POST mode. + * @details + * Inputs : postState + * Outputs : none + * @return the current state of initialize & POST mode. + *************************************************************************/ +DG_POST_STATE_T getCurrentInitAndPOSTState( void ) +{ + return postState; +} + +/**@}*/