Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r499e5de29e706d09f79ba22511068990c4044e84 -rf43eb1e9e0803776ec7420b16e1db8760b020bd9 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 499e5de29e706d09f79ba22511068990c4044e84) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision f43eb1e9e0803776ec7420b16e1db8760b020bd9) @@ -1,4 +1,4 @@ -/************************************************************************** +/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * @@ -18,11 +18,30 @@ #include "ModeStandby.h" #include "CPLD.h" +/** + * @addtogroup StandbyMode + * @{ + */ + +// ********** private definitions ********** + +/// Enumeration of standby mode states. +typedef enum Standby_Mode_States +{ + STANDBY_MODE_STATE_START = 0, ///< Start standby mode state. + STANDBY_MODE_STATE_IDLE, ///< Idle standby mode state. + NUM_OF_STANDBY_MODE_STATES ///< Number of standby mode states. +} STANDBY_MODE_STATE_T; + // ********** private data ********** +static STANDBY_MODE_STATE_T standbyState = STANDBY_MODE_STATE_START; ///< Currently active standby state. + // ********** private function prototypes ********** -/************************************************************************* +STANDBY_MODE_STATE_T handleStandbyIdleState( void ); + +/*********************************************************************//** * @brief initStandbyMode * The initStandbyMode function initializes the Standby Mode module. * @details @@ -35,7 +54,7 @@ { } -/************************************************************************* +/*********************************************************************//** * @brief transitionToStandbyMode * The transitionToStandbyMode function prepares for transition to standby mode. * @details @@ -46,9 +65,11 @@ *************************************************************************/ void transitionToStandbyMode( void ) { + // reset to start state each time we transition to standby mode + standbyState = STANDBY_MODE_STATE_START; } -/************************************************************************* +/*********************************************************************//** * @brief execStandbyMode * The execStandbyMode function executes the Standby Mode state machine. * @details @@ -59,6 +80,47 @@ *************************************************************************/ void execStandbyMode( void ) { + // execute current Standby state + switch ( standbyState ) + { + case STANDBY_MODE_STATE_START: + standbyState = STANDBY_MODE_STATE_IDLE; + break; + case STANDBY_MODE_STATE_IDLE: + standbyState = handleStandbyIdleState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, 0, standbyState ) // TODO - add s/w fault enum to 1st data param + standbyState = STANDBY_MODE_STATE_START; + break; + } } +/*********************************************************************//** + * @brief + * The handleStandbyIdleState function executes the Idle state of the \n + * Standby Mode state machine. + * @details + * Inputs : none + * Outputs : + * @param none + * @return the next state + *************************************************************************/ +STANDBY_MODE_STATE_T handleStandbyIdleState( void ) +{ + STANDBY_MODE_STATE_T result = STANDBY_MODE_STATE_IDLE; + + // go to standby or standby solo mode depending on whether HD is connected +// if ( FALSE == isHDCommunicating() ) // TODO - handle switching between standby and standby-solo modes +// { +// requestNewOperationMode( MODE_SOLO ); +// } + + // TODO - what is DG supposed to be doing while in standby mode? + + return result; +} + +/**@}*/