Ejemplo n.º 1
0
/* @req SWS_Gpt_00328 */
void Gpt_CheckWakeup( EcuM_WakeupSourceType WakeupSource ) {

    /* @req SWS_Gpt_00325 */
    VALIDATE((STD_ON == Gpt_Global.initRun), GPT_CHECKWAKEUP_SERVICE_ID, GPT_E_UNINIT);

    for (uint8 chnlCnt = 0; chnlCnt < GPT_CHANNEL_CNT; chnlCnt++) {
        // Loop over all channels to check if Wakeup source is found
        if (Gpt_Global.Gpt_WakUpEnable[chnlCnt] && (GET_CONFIG(chnlCnt).GptWakeupSource == WakeupSource)
                && ( GPT_STATE_EXPIRED == Gpt_Global.Gpt_ChannelState[chnlCnt])) {
            /* @req SWS_Gpt_00321 */
            EcuM_SetWakeupEvent(WakeupSource);
            break;
        }
    }

    return;
}
void EcuM_CheckWakeup(EcuM_WakeupSourceType source) {

	/* Re-enable PLL again */
	EcuM_ConfigType *ecuMConfigPtr;
	ecuMConfigPtr = EcuM_DeterminePbConfiguration();
	(void) Mcu_InitClock(ecuMConfigPtr->McuConfig->McuDefaultClockSettings);

	// Wait for PLL to sync.
	while (Mcu_GetPllStatus() != MCU_PLL_LOCKED) {
		;
	}

	/* ADD CODE BELOW */
#if 0
	/* Example */
	if (ECUM_WKSOURCE_SWITCH & wakeupSource) {
		if (CRP.PSCR.R & 0x00020000) {
			EcuM_SetWakeupEvent(ECUM_WKSOURCE_SWITCH);
		}
	}
#endif

}
Ejemplo n.º 3
0
/**
 * Initialize EcuM.
 */
void EcuM_Init(void) {
	Std_ReturnType status;
	set_current_state(ECUM_STATE_STARTUP_ONE);

	// Initialize drivers that are needed to determine PostBuild configuration
	EcuM_AL_DriverInitZero();

	// Initialize the OS
	InitOS();

	// Setup interrupts
	Os_IsrInit();

	// Determine PostBuild configuration
	EcuM_World.config = EcuM_DeterminePbConfiguration();

	// TODO: Check consistency of PB configuration

	// Initialize drivers needed before the OS-starts
	EcuM_AL_DriverInitOne(EcuM_World.config);

	// Determine the reset/wakeup reason
	switch (Mcu_GetResetReason()) {
	case MCU_POWER_ON_RESET:
		EcuM_SetWakeupEvent(ECUM_WKSOURCE_POWER);
		break;
	case MCU_SW_RESET:
		EcuM_SetWakeupEvent(ECUM_WKSOURCE_RESET);
		break;
	case MCU_RESET_UNDEFINED:
		break;
	case MCU_WATCHDOG_RESET:
		EcuM_SetWakeupEvent(ECUM_WKSOURCE_INTERNAL_WDG);
		break;
	default:
		assert(0);
		break;
	}

	// Moved this here because EcuM_SelectShutdownTarget needs us to be initilized.
	EcuM_World.initiated = TRUE;

	// Set default shutdown target

	status = EcuM_SelectShutdownTarget(
					EcuM_World.config->EcuMDefaultShutdownTarget,
					EcuM_World.config->EcuMDefaultSleepMode);/** @req EcuM2181 */
	if (status != E_OK) {
		//TODO: Report error.
	}

	// Set default application mode
	status = EcuM_SelectApplicationMode(
					EcuM_World.config->EcuMDefaultAppMode);
	if (status != E_OK) {
		//TODO: Report error.
	}

#if defined(USE_COMM)
	EcuM_World.run_comm_requests = 0;
#endif
	EcuM_World.run_requests = 0;
	EcuM_World.postrun_requests = 0;

	// Start this baby up
	AppModeType appMode;
	status = EcuM_GetApplicationMode(&appMode);
	if (status != E_OK) {
		//TODO: Report error.
	}

	StartOS(appMode); /** @req EcuM2141 */
}