Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r54f45c387430e440ab4607451fc84dea61f273f1 -rddb9707d9e6e46c4b384782aeec20d41f3822996 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 54f45c387430e440ab4607451fc84dea61f273f1) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision ddb9707d9e6e46c4b384782aeec20d41f3822996) @@ -8,22 +8,34 @@ * @file ModeInitPOST.c * * @author (last) Quang Nguyen -* @date (last) 24-Aug-2020 +* @date (last) 27-Aug-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #include "Accel.h" +#include "ConcentratePumps.h" +#include "ConductivitySensors.h" #include "CPLD.h" +#include "DrainPump.h" +#include "Fans.h" #include "FPGA.h" +#include "Integrity.h" +#include "LoadCell.h" +#include "ModeInitPOST.h" +#include "NVDataMgmt.h" #include "OperationModes.h" +#include "Pressures.h" +#include "Reservoirs.h" +#include "ROPump.h" +#include "RTC.h" +#include "SystemCommMessages.h" #include "TemperatureSensors.h" +#include "Thermistors.h" +#include "UVReactors.h" #include "WatchdogMgmt.h" -#include "ModeInitPOST.h" -#include "Heaters.h" -#include "Pressures.h" /** * @addtogroup DGInitAndPOSTMode @@ -40,13 +52,13 @@ // ********** private function prototypes ********** static DG_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ); +static SELF_TEST_STATUS_T execFWCompatibilityTest( void ); /*********************************************************************//** * @brief * The initInitAndPOSTMode function initializes the Initialization and POST mode module. - * @details - * Inputs : none - * Outputs : Initialization and POST mode module initialized + * @details Inputs: none + * @details Outputs: Initialization and POST mode module initialized * @return none *************************************************************************/ void initInitAndPOSTMode( void ) @@ -61,9 +73,8 @@ * @brief * The transitionToInitAndPOSTMode function prepares for transition to * initialization and POST mode. - * @details - * Inputs : none - * Outputs : none + * @details Inputs: none + * @details Outputs: none * @return none *************************************************************************/ void transitionToInitAndPOSTMode( void ) @@ -75,9 +86,8 @@ * @brief * The execInitAndPOSTMode function executes the initialization and POST * mode state machine. - * @details - * Inputs : postState - * Outputs : Initialization and POST mode state machine executed + * @details Inputs: postState + * @details Outputs: Initialization and POST mode state machine executed * @return current state. *************************************************************************/ U32 execInitAndPOSTMode( void ) @@ -88,27 +98,45 @@ switch ( postState ) { case DG_POST_STATE_START: - postState = DG_POST_STATE_FPGA; + postState = DG_POST_STATE_FW_COMPATIBILITY; #ifdef SKIP_POST postState = DG_POST_STATE_COMPLETED; #endif break; + case DG_POST_STATE_FW_COMPATIBILITY: + testStatus = execFWCompatibilityTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_FW_INTEGRITY: + testStatus = execIntegrityTest(); + postState = handlePOSTStatus( testStatus ); + break; + case DG_POST_STATE_FPGA: testStatus = execFPGATest(); postState = handlePOSTStatus( testStatus ); break; - case DG_POST_STATE_TEMPERATURE_SENSORS: - testStatus = execTemperatureSensorsSelfTest(); + case DG_POST_STATE_RTC: + testStatus = execRTCSelfTest(); postState = handlePOSTStatus( testStatus ); break; - case DG_POST_STATE_HEATERS: - testStatus = execHeatersSelfTest(); + case DG_POST_STATE_NVDATAMGMT: + testStatus = execNVDataMgmtSelfTest(); postState = handlePOSTStatus( testStatus ); break; + // NOTE: all the actuators and sensors must execute their POST after NVDataMgmt + // NVDataMgmt must load all the calibration data into RAM so the actuators + // can query their corresponding calibration values successfully + case DG_POST_STATE_TEMPERATURE_SENSORS: + testStatus = execTemperatureSensorsSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + case DG_POST_STATE_ACCELEROMETER: #ifndef DISABLE_ACCELS testStatus = execAccelTest(); @@ -123,9 +151,61 @@ postState = handlePOSTStatus( testStatus ); break; + case DG_POST_STATE_RO_PUMP: + testStatus = execROPumpSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_DRAIN_PUMP: + testStatus = execDrainPumpSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_CONCENTRATE_PUMPS: + testStatus = execConcenratePumpsSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_CONDUCTIVITY_SENSORS: + testStatus = execConductivitySensorsSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_RESERVOIRS: + testStatus = execReservoirsSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_UV_REACTORS: + testStatus = execUVReactorsSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_THERMISTORS: + testStatus = execThermistorsSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_FANS: + testStatus = execFansSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + case DG_POST_STATE_WATCHDOG: testStatus = execWatchdogTest(); - handlePOSTStatus( testStatus ); // ignoring return value because last test + postState = handlePOSTStatus( testStatus ); + break; + + case DG_POST_STATE_SAFETY_SHUTDOWN: + testStatus = SELF_TEST_STATUS_PASSED; + postState = handlePOSTStatus( testStatus ); + break; + + // Should be last POST (and last POST test must be a test that completes in a single call) + case DG_POST_STATE_LOAD_CELL: + testStatus = execLoadCellsSelfTest(); + handlePOSTStatus( testStatus ); + // Ignoring return value because last test if ( TRUE == tempPOSTPassed ) { postState = DG_POST_STATE_COMPLETED; @@ -137,23 +217,25 @@ break; case DG_POST_STATE_COMPLETED: - // set overall HD POST status to "passed" + // Set overall HD POST status to "passed" postPassed = TRUE; - // set overall HD POST completed status to TRUE + // Set overall HD POST completed status to TRUE postCompleted = TRUE; - // TODO - send POST status on CAN - // go to standby mode + // Broadcast final POST passed + sendPOSTFinalResult( TRUE ); + // Go to standby mode requestNewOperationMode( DG_MODE_STAN ); break; 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 + // Broadcast final POST failed + sendPOSTFinalResult( FALSE ); + // Will want POST faults to wait for us to get here before sending us to fault mode requestNewOperationMode( DG_MODE_FAUL ); break; default: - // TODO - s/w fault + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_MODE_INIT_POST_INVALID_POST_STATE, postState ) postState = DG_POST_STATE_FAILED; break; } @@ -165,9 +247,8 @@ * @brief * The isPOSTCompleted function determines whether all DG POST have been run * and completed. If true, call the isPOSTPassed() to see final result (pass/fail). - * @details - * Inputs : postCompleted - * Outputs : none + * @details Inputs: postCompleted + * @details Outputs: none * @return true if all HD POST tests have completed, false if not *************************************************************************/ BOOL isPOSTCompleted( void ) @@ -179,9 +260,8 @@ * @brief * The isPOSTPassed function determines whether all HD POST have passed. * Call this function after POST is complete (call isPOSTCompleted function). - * @details - * Inputs : postPassed - * Outputs : none + * @details Inputs: postPassed + * @details Outputs: none * @return true if all HD POST tests have passed, false if not *************************************************************************/ BOOL isPOSTPassed( void ) @@ -192,20 +272,24 @@ /*********************************************************************//** * @brief * The handlePOSTStatus function handles a status result returned by a POST function. - * @details - * Inputs : postPassed - * Outputs : none + * @details Inputs: postPassed + * @details Outputs: none * @param testStatus status reported by last test * @return recommended next POST state *************************************************************************/ static DG_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus ) { DG_POST_STATE_T result = postState; - if ( ( testStatus == SELF_TEST_STATUS_PASSED ) || ( testStatus == SELF_TEST_STATUS_FAILED ) ) + if ( ( SELF_TEST_STATUS_PASSED == testStatus ) || ( SELF_TEST_STATUS_FAILED == testStatus ) ) { - result = (DG_POST_STATE_T)((int)postState + 1); // move on to next POST test - if ( testStatus == SELF_TEST_STATUS_FAILED ) + BOOL passed = ( SELF_TEST_STATUS_PASSED == testStatus ? TRUE : FALSE ); + + // Broadcast passed POST result + sendPOSTTestResult( (DG_POST_STATE_T)((int)postState), passed ); + // Move on to next POST test + result = (DG_POST_STATE_T)((int)postState + 1); + if ( SELF_TEST_STATUS_FAILED == testStatus ) { tempPOSTPassed = FALSE; } @@ -218,14 +302,29 @@ * @brief * The getCurrentInitAndPOSTState function returns the current state of the * initialization and POST mode. - * @details - * Inputs : postState - * Outputs : none + * @details Inputs: postState + * @details Outputs: none * @return the current state of initialization and POST mode *************************************************************************/ DG_POST_STATE_T getCurrentInitAndPOSTState( void ) { return postState; } +/*********************************************************************//** + * @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; +} + /**@}*/