Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r2df21d2472a8d79d78af7e359518acf3614accc5 -rd5c5b1d2bc42b166f1ccff1aa4b2441db8f06d4b --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 2df21d2472a8d79d78af7e359518acf3614accc5) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision d5c5b1d2bc42b166f1ccff1aa4b2441db8f06d4b) @@ -1,28 +1,33 @@ /************************************************************************** - * - * 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 19-Sep-2019 - * @author S. Nash - * - * @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) Dara Navaei +* @date (last) 02-Oct-2020 +* +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 +* +***************************************************************************/ +#include "Accel.h" #include "AlarmLamp.h" +#include "BloodFlow.h" #include "Buttons.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 "Valves.h" /** * @addtogroup HDInitAndPOSTMode @@ -33,22 +38,21 @@ // ********** private data ********** -static HD_POST_STATE_T postState = POST_STATE_START; -static BOOL postCompleted = FALSE; -static BOOL postPassed = FALSE; -static BOOL tempPOSTPassed = TRUE; +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. // ********** private function prototypes ********** static HD_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 ) @@ -59,27 +63,25 @@ tempPOSTPassed = TRUE; } -/************************************************************************* - * @brief transitionToInitAndPOSTMode - * The transitionToInitAndPOSTMode function prepares for transition to\n +/*********************************************************************//** + * @brief + * The transitionToInitAndPOSTMode function prepares for transition to * initialize & POST mode. * @details * Inputs : none - * Outputs : - * @param none + * Outputs : none * @return none *************************************************************************/ void transitionToInitAndPOSTMode( void ) { } -/************************************************************************* - * @brief execInitAndPOSTMode +/*********************************************************************//** + * @brief * The execInitAndPOSTMode function executes the Initialize & POST Mode state machine. * @details - * Inputs : none - * Outputs : - * @param none + * Inputs : postState + * Outputs : postState, postPassed, postCompleted * @return current state (sub-mode) *************************************************************************/ U32 execInitAndPOSTMode( void ) @@ -93,12 +95,16 @@ { case POST_STATE_START: postState = POST_STATE_WATCHDOG; + #ifdef RM46_EVAL_BOARD_TARGET postState = POST_STATE_COMPLETED; #endif #ifdef SKIP_POST postState = POST_STATE_COMPLETED; #endif + // TODO FOR TESTING ONLY REMOVE + postState = POST_STATE_VALVES; + // TODO FOR TESTING ONLY REMOVE break; case POST_STATE_WATCHDOG: @@ -126,6 +132,31 @@ postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_BLOOD_FLOW: + testStatus = execBloodFlowTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case POST_STATE_DIALYSATE_FLOW: + testStatus = execDialInFlowTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case POST_STATE_VALVES: + testStatus = execValvesSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + + case POST_STATE_ACCELEROMETER: +#ifndef DISABLE_ACCELS + testStatus = execAccelTest(); +#else + testStatus = SELF_TEST_STATUS_PASSED; +#endif + postState = handlePOSTStatus( testStatus ); + break; + + // Should be last POST case POST_STATE_STUCK_BUTTON: testStatus = execStuckButtonTest(); handlePOSTStatus( testStatus ); @@ -153,53 +184,51 @@ 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_SOFTWARE_FAULT, SW_FAULT_ID_MODE_INIT_POST_INVALID_POST_STATE, postState ) + 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; } return postState; } -/************************************************************************* - * @brief isPOSTCompleted - * The isPOSTCompleted function determines whether all HD POST have \n - * been run and completed. If true, call the isPOSTPassed() to see final \n +/*********************************************************************//** + * @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). * @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 - * The isPOSTPassed function determines whether all HD POST have passed. \n +/*********************************************************************//** + * @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 - * @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 * Inputs : postPassed * Outputs : none - * @param testStatus + * @param testStatus status reported by last test * @return recommended next POST state *************************************************************************/ static HD_POST_STATE_T handlePOSTStatus( SELF_TEST_STATUS_T testStatus )