/* * 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(); }
static inline void in_state_goOffOne(void){ /* @req EcuMf2328 */ /* !req EcuM2756 */ #if defined(USE_NVM) if (EcuM_World_go_off_one_state_timeout){ EcuM_World_go_off_one_state_timeout--; } // Wait for the NVM job (NvmWriteAll) to terminate Std_ReturnType ret = NvM_GetErrorStatus(0, &writeAllResult); if (((ret == E_OK) && (writeAllResult != NVM_REQ_PENDING)) || (EcuM_World_go_off_one_state_timeout == 0)) { ShutdownOS(E_OK); } #else ShutdownOS(E_OK); #endif }
void EcuM_Callout_DriverInitListTwo(void) { /* status of NvM initialization */ NvM_RequestResultType Result; BswM_Init(BswM_ConfigPtr); Fls_Init(NULL_PTR); #ifdef BASE_EA_ENABLED EA_INIT_FUNC(); #endif #ifdef BASE_FEE_ENABLED FEE_INIT_FUNC(); /* wait for FEE to complete the init sequence */ do { Fee_MainFunction(); Fls_MainFunction(); } while (MEMIF_IDLE != Fee_GetStatus()); #endif #ifdef BASE_NVM_ENABLED NVM_INIT_FUNC(); NvM_ReadAll(); /* wait for the NvM_ReadAll() to complete - some of the remaining modules need valid NvRam data... */ do { NvM_MainFunction(); Fee_MainFunction(); Fls_MainFunction(); (void)NvM_GetErrorStatus(NvMConf_NvMBlockDescriptor_NvMBlock_ConfigID, &Result); } while (Result == NVM_REQ_PENDING); #endif LinEmuUart_Init(); Can_InitMemory(); Can_Init(&CanConfigSet); CanIf_InitMemory(); CanIf_Init(&CanIf_Config); //CanNm_Init(&CanNmGlobalConfig); //Nm_Init(&Nm_Configuration0); PduR_InitMemory(); PduR_Init(&PduRGlobalConfig); Com_InitMemory(); Com_Init(&ComConfig); CanSM_InitMemory(); CanSM_Init(); CanTp_InitMemory(); CanTp_Init(); ComM_InitMemory(); ComM_Init(&ComMConfig); Xcp_Init(NULL); FiM_Init(&FiM_Config_0); DiagMeas_Init(); DiagCtrl_Init(); SCI_B6Bridge_Init(); SCI_Pfc_Init(); SCI_IOHW_Init(); #ifdef BASE_DEM_ENABLED DEM_INIT_FUNC(); /* start the standard operation cycle */ /* (void) Dem_SetOperationCycleState(DEM_OPCYC_POWER, DEM_CYCLE_STATE_START); */ #endif Dcm_Init(); }
/** In GO SLEEP state (in state ECUM_STATE_GO_SLEEP) */ static void in_state_goSleep( void ) { /* !req EcuMf0026: * The ECU State Manager Fixed module shall put all communication interfaces to standby state and shall arm the * wake up source before the ECU State Manager Fixed module may put the ECU into SLEEP state. */ /* We only wait for NvM_WriteAll() for so long */ if (EcuM_World_go_sleep_state_timeout) { EcuM_World_go_sleep_state_timeout--; #if defined(USE_NVM) { NvM_RequestResultType nvmResult; if((NvM_GetErrorStatus(0, &nvmResult) != E_OK) || (nvmResult != NVM_REQ_PENDING)) { /* Done or something is wrong...continue */ EcuM_World_go_sleep_state_timeout = 0; } } #endif } if( (EcuM_World_go_sleep_state_timeout == 0) ) { /* * We should go to sleep , enable source that should wake us */ uint32 cMask; uint8 source; const EcuM_SleepModeType *sleepModePtr; /* Get the current sleep mode */ /* @req EcuM2185 */ /* @req EcuMf2185 */ sleepModePtr = &EcuM_World.config->EcuMSleepModeConfig[EcuM_World.sleep_mode]; cMask = sleepModePtr->EcuMWakeupSourceMask; /* Loop over the WKSOURCE for this sleep mode */ /* @req EcuM2389 */ /* @req EcuM2546 */ for (; cMask; cMask &= ~(1ul << source)) { source = ilog2(cMask); /* @req 3.1.5/ECUM2389 */ // DEBUG_ECUM_CALLOUT_W_ARG("EcuM_EnableWakeupSources","0x%lx",(1ul<< source)); EcuM_EnableWakeupSources( 1<< source ); } /* Let no one else run */ (void)GetResource(RES_SCHEDULER); SetCurrentState(ECUM_STATE_SLEEP); } else if( EcuM_GetPendingWakeupEvents() != 0 ) { /* @req EcuM2188 */ /* @req EcuMf2188 */ /* We have pending wakeup events, need to startup again */ #if defined(USE_NVM) NvM_CancelWriteAll(); SetCurrentState(ECUM_STATE_SLEEP); #endif } }
Std_ReturnType NvMService_GetErrorStatus(NvM_BlockIdType BlockId, NvM_RequestResultType* RequestResultPtr) { NvM_GetErrorStatus( BlockId, (uint8*)RequestResultPtr ); return E_OK; }