/************************************************************************** * * Copyright (c) 2019-2022 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 ModeService.c * * @author (last) Michael Garthwaite * @date (last) 07-Sep-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #include "OperationModes.h" #include "ModeService.h" #include "CPLD.h" /** * @addtogroup DGServiceMode * @{ */ // ********** private definitions ********** // ********** private data ********** static DG_SERVICE_STATE_T serviceState = DG_SERVICE_STATE_START; ///< Currently active service state. // ********** private function prototypes ********** /*********************************************************************//** * @brief * The initServiceMode function initializes the service mode module. * @details Inputs: none * @details Outputs: Service mode module initialized * @return none *************************************************************************/ void initServiceMode( void ) { serviceState = DG_SERVICE_STATE_START; } /*********************************************************************//** * @brief * The transitionToServiceMode function prepares for transition to service mode. * @details Inputs: none * @details Outputs: none * @return initial state *************************************************************************/ U32 transitionToServiceMode( void ) { deenergizeActuators(); initServiceMode(); return serviceState; } /*********************************************************************//** * @brief * The execServiceMode function executes the service mode state machine. * @details Inputs: none * @details Outputs: Service mode state machine executed * @return current state. *************************************************************************/ U32 execServiceMode( void ) { // execute current service state switch ( serviceState ) { case DG_SERVICE_STATE_START: break; default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_SERVICE_MODE_INVALID_EXEC_STATE, serviceState ) serviceState = DG_SERVICE_STATE_START; break; } return serviceState; } /*********************************************************************//** * @brief * The getCurrentServiceState function returns the current state of the service mode. * @details Inputs: serviceState * @details Outputs: none * @return the current state of service mode *************************************************************************/ DG_SERVICE_STATE_T getCurrentServiceState( void ) { return serviceState; } /**@}*/