/** @file     Rte_BswM_Test.c
  * 
  * @brief    RTE Sample SWC implementation skeleton file
  * 
  * @note     Generated by ETAS GmbH  RTA-RTE v5.8.2  (R4.0 backend version: v7.8.5 (Build 46241))
  */

#include "Rte_Base_SWC.h"

/* --------------------------------------------------------------------------- */
/* RTE Event: /BswM_Test/BswM_Test/BswM_Test_IB/TimingEvent_0 */

#define SHUTDOWN_REQ 		3u
#define MODE_REQ_SHUTDOWN 	0u

typedef enum 
{
	BASE_CHECK_SHUTDOWN_REQ,
	BASE_ASK_BSWM_SHUTDOWN,
	BASE_IDLE,
} BaseStateMachine;


FUNC(void, BswM_Test_CODE) RE_Base_SWC(void)
{
	static BaseStateMachine BaseStateMachineState = BASE_CHECK_SHUTDOWN_REQ;
	
	switch (BaseStateMachineState)
	{
		case BASE_CHECK_SHUTDOWN_REQ:
			/* check for shutdown */
			if(SHUTDOWN_REQ == Rte_IRead_RE_Base_SWC_RPort_TestRequested_uint8_Impl())
			{
				/* Switch state */
				BaseStateMachineState = BASE_ASK_BSWM_SHUTDOWN;
			}					
			break;
		
		case BASE_ASK_BSWM_SHUTDOWN:
			/* request for Shutdown sent to BswM */
			Rte_Call_RPort_shutdownTarget_SelectShutdownTarget(ECUM_SHUTDOWN_TARGET_RESET,0);
			Rte_Switch_PP_BswMArbitration_BswM_MRP_SwcModeRequest_MDGP_MSI_ShutDown(MODE_REQ_SHUTDOWN);			
			/* Switch state */
			BaseStateMachineState = BASE_IDLE;			
			break;
		
		case BASE_IDLE:
		/* Do nothing here */
		break;
		
		default:
		break;		
	}
}
