/* * The order defined here is found in 3.1.5/EcuM2411 */ void EcuM_StartupTwo(void) { //TODO: Validate that we are in state STARTUP_ONE. #if defined(USE_NVM) extern CounterType Os_Arc_OsTickCounter; TickType tickTimerStart, tickTimerElapsed; static NvM_RequestResultType readAllResult; TickType tickTimer; StatusType tickTimerStatus; #endif set_current_state(ECUM_STATE_STARTUP_TWO); // Initialize the BSW scheduler #if defined(USE_SCHM) SchM_Init(); #endif #if defined(USE_WDGM) if( EcuM_World.config->EcuMWdgMConfig != NULL ) { WdgM_SetMode(EcuM_World.config->EcuMWdgMConfig->EcuMWdgMStartupMode); } #endif // Initialize drivers that don't need NVRAM data EcuM_AL_DriverInitTwo(EcuM_World.config); #if defined(USE_NVM) // Start timer to wait for NVM job to complete tickTimerStart = GetOsTick(); #endif // Prepare the system to startup RTE // TODO EcuM_OnRTEStartup(); #if defined(USE_RTE) Rte_Start(); #endif #if defined(USE_NVM) /* Wait for the NVM job (NvM_ReadAll) to terminate. This assumes that: * - A task runs the memory MainFunctions, e.g. Ea_MainFunction(), Eep_MainFunction() * are run in a higher priority task that the task that executes this code. */ do { /* Read the multiblock status */ NvM_GetErrorStatus(0, &readAllResult); tickTimerElapsed = OS_TICKS2MS_OS_TICK(GetOsTick() - tickTimerStart); /* The timeout EcuMNvramReadAllTimeout is in ms */ } while( (readAllResult == NVM_REQ_PENDING) && (tickTimerElapsed < EcuM_World.config->EcuMNvramReadAllTimeout) ); #endif // Initialize drivers that need NVRAM data EcuM_AL_DriverInitThree(EcuM_World.config); // TODO: Indicate mode change to RTE EcuM_enter_run_mode(); }
/** * Restart drivers. Have no restart list, instead the * drivers restarted are drivers that have had it's hardware * registers reset. If memory is also lost (=all memory is not * powered during sleep), this strategy does not work. * * This calls: * - EcuM_AL_DriverInitOne() * - EcuM_AL_DriverInitTwo() * */ void EcuM_AL_DriverRestart(const struct EcuM_ConfigS* ConfigPtr) { EcuM_ConfigType* config; VALIDATE_STATE( ECUM_STATE_WAKEUP_ONE); config = EcuM_DeterminePbConfiguration(); /* Start all drivers for now */ EcuM_AL_DriverInitOne(config); /* Setup the systick interrupt */ #if defined(USE_MCU) { uint32_t sys_freq = McuE_GetSystemClock(); Os_SysTickInit(); Os_SysTickStart(sys_freq / OsTickFreq); } #endif EcuM_AL_DriverInitTwo(config); }
/** * Restart drivers. Have no restart list, instead the * drivers restarted are drivers that have had it's hardware * registers reset. If memory is also lost (=all memory is not * powered during sleep), this strategy does not work. * * This calls: * - EcuM_AL_DriverInitOne() * - EcuM_AL_DriverInitTwo() * */ void EcuM_AL_DriverRestart(const struct EcuM_ConfigS* ConfigPtr) { EcuM_ConfigType* config; VALIDATE_STATE( ECUM_STATE_WAKEUP_ONE); config = EcuM_DeterminePbConfiguration(); /* Start all drivers for now */ EcuM_AL_DriverInitOne(config); /* Setup the systick interrupt */ #if defined(USE_MCU) { #if defined(CFG_OS_SYSTICK2) Os_SysTickStart2(OsTickFreq); #else Os_SysTickStart(Mcu_Arc_GetSystemClock() / OsTickFreq); #endif } #endif EcuM_AL_DriverInitTwo(config); }