/** * \fn Endconstructor * \brief We need to call some virtual functions in the constructor; it does not work, so we do the 2nd part of the constructor here */ void ADM_flyDialog::EndConstructor(void) { if(_isYuvProcessing) { action=new ADM_flyDialogActionYuv(this); } else { action=new ADM_flyDialogActionRgb(this); } if (_resizeMethod != RESIZE_NONE) { _zoom = calcZoomFactor(); if (_zoom == 1) { _resizeMethod = RESIZE_NONE; } } if(_resizeMethod==RESIZE_NONE) { _zoom=1; _zoomW=_w; _zoomH=_h; } else { _zoomW = uint32_t (_w * _zoom); _zoomH = uint32_t (_h * _zoom); } updateZoom(); postInit (false); }
//======================================================================= //protected bool Application::init ( HINSTANCE hInstance, DWORD style ) { myInstanceMonitor.create( resourceClassName() ); if ( !myInstanceMonitor.isThisTheOnlyInstance() ) { Logger::message( _T("More then one type of this application is running.") ); return false; } if ( !preInit( hInstance ) ) { return false; } if ( !ourClassIsRegistered ) { Application::ourHInstance = hInstance; ourClassIsRegistered = registerClass(); } if ( !preWindow() || !setupWindow( style ) || !postInit() ) { return false; } return (GetWindowLongPtr( myHWnd, GWLP_USERDATA ) == (LONG)this); }
/* * ======== Timer_reconfig ======== * * 1. Init obj using params * 2. Timer_init() * 3. Configure timer (wrt emulation, frequency, etc.) * 4. Set period * 5. Timer_start() * */ Void Timer_reconfig (Timer_Object *obj, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb) { obj->controlRegInit = params->controlRegInit.source; obj->runMode = params->runMode; obj->startMode = params->startMode; obj->period = params->period; obj->periodType = params->periodType; obj->prevThreshold = params->prevThreshold; obj->synchronous = params->synchronous; if (obj->periodType == Timer_PeriodType_MICROSECS) { if (!Timer_setPeriodMicroSecs(obj, obj->period)) { Error_raise(eb, Timer_E_cannotSupport, obj->period, 0); } } obj->arg = params->arg; obj->tickFxn = tickFxn; if (params->extFreq.lo) { /* (extFreq.hi is ignored) */ obj->frequency.lo = params->extFreq.lo; } postInit(obj, eb); if (obj->startMode == Timer_StartMode_AUTO) { Timer_start(obj); } }
/* * ======== Hwi_Instance_init ======== */ Int Hwi_Instance_init(Hwi_Object *hwi, Int intNum, Hwi_FuncPtr fxn, const Hwi_Params *params, Error_Block *eb) { Int status; if (Hwi_module->dispatchTable[intNum] != NULL) { Error_raise(eb, Hwi_E_alreadyDefined, intNum, 0); return (1); } Hwi_module->dispatchTable[intNum] = hwi; Hwi_reconfig(hwi, fxn, params); #ifndef ti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS if (Hwi_hooks.length > 0) { /* Allocate environment space for each hook instance. */ hwi->hookEnv = Memory_calloc(Hwi_Object_heap(), Hwi_hooks.length * sizeof(Ptr), 0, eb); if (hwi->hookEnv == NULL) { return (1); } } #endif hwi->irp = 0; status = postInit(hwi, eb); if (Error_check(eb)) { return (2 + status); } return (0); }
/* * ======== GateDualCore_Instance_init ======== */ Int GateDualCore_Instance_init(GateDualCore_Object *obj, const GateDualCore_Params *params, Error_Block *eb) { UInt index = params->index; if (index > GateDualCore_numGates - 1) { Error_raise(eb, GateDualCore_E_invalidIndex, index, 0); return 1; } else if (GateDualCore_module->usedGates[index] != 0) { Error_raise(eb, GateDualCore_E_gateInUse, index, 0); return 1; } else { GateDualCore_module->usedGates[index] = 1; obj->index = index; obj->stalls = 0; obj->noStalls = 0; obj->totalStalls = 0; obj->maxStall = 0; postInit(obj); } return 0; }
MicroViewProgressBarBase::MicroViewProgressBarBase(uint8_t newx, uint8_t newy, int16_t min, int16_t max, uint8_t sty): MicroViewWidget(newx, newy, min, max) { style = sty; printLabel=true; switch(sty){ case WIDGETSTYLE1: totalTicks=60; break; case WIDGETSTYLE2: totalTicks=20; break; case WIDGETSTYLE3: totalTicks=40; break; // If already 0 or invalid, just make sure it's 0. case WIDGETSTYLE0: default: style=WIDGETSTYLE0; totalTicks=30; break; } Serial.println("60"); Serial.println(printLabel); preInit(); initWidget(); postInit(); }
void ModernOpenGLGraphics::screenResized() { deleteGLObjects(); mVboBinded = 0U; mEboBinded = 0U; mAttributesBinded = 0U; postInit(); }
GLuint OpenGLImageHelper::getNewTexture() { GLuint texture = mTextures[mFreeTextureIndex]; mFreeTextureIndex ++; if (mFreeTextureIndex == texturesSize) { mFreeTextureIndex = 0; postInit(); } return texture; }
/** \brief MicroViewProgressBar class initialisation. * * Initialise the MicroViewProgressBar widget with default style. */ MicroViewProgressBarBase::MicroViewProgressBarBase(uint8_t newx, uint8_t newy, int16_t min, int16_t max): MicroViewWidget(newx, newy, min, max) { style=WIDGETSTYLE0; totalTicks=30; printLabel=true; Serial.println("24"); preInit(); initWidget(); postInit(); }
/* * ======== Timer_Module_startup ======== * Calls postInit for all statically-created & constructed * timers to initialize them. */ Int Timer_Module_startup(status) { Timer_Object *obj; if (Timer_startupNeeded) { obj = Timer_module->handle; /* if timer was statically created/constructed */ if ((obj != NULL) && (obj->staticInst)) { postInit(obj, NULL); } } return (Startup_DONE); }
/* * ======== Hwi_Module_startup ======== */ Int Hwi_Module_startup (Int phase) { int i; Hwi_Object *hwi; /* must wait for these modules to initialize first */ if (!Startup_rtsDone()) { return Startup_NOTDONE; } /* okay to proceed with initialization */ #ifndef ti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS for (i = 0; i < Hwi_hooks.length; i++) { if (Hwi_hooks.elem[i].registerFxn != NULL) { Hwi_hooks.elem[i].registerFxn(i); } } #endif Hwi_init(); // sets up FIQ/IRQ stackpointers, etc /* * Initialize the pointer to the isrStack. * * The dispatcher's SP is decremented to accomodate its local variables * BEFORE switching to the ISR stack. Consequently, the intial value of * the ISR stack SP must leave room for these variables. * * Leave room for up to 32 32 bit local variables. */ Hwi_module->isrStack = (Char *) (((UInt32) (Hwi_module->isrStackBase) & 0xfffffff8) + (UInt32) Hwi_module->isrStackSize - 32 * sizeof(Int)); Hwi_module->taskSP = (Char *)-1;/* signal that we're executing on the */ /* ISR stack */ Hwi_enableIER(Hwi_module->ierMask); /* IER per static Hwi settings */ Hwi_l1Intc.ITR = 0; Hwi_l2Intc.ITR1 = 0; Hwi_l2Intc.ITR2 = 0; for (i = 0; i < Hwi_NUM_INTERRUPTS; i++) { hwi = Hwi_module->dispatchTable[i]; if (hwi != NULL) { postInit(hwi, NULL); } } return (Startup_DONE); }
/* * ======== Timer_reconfig ======== * 1. Init obj using params * 2. Reconfig Hwi * 3. Timer_init() * 4. Timer configuration (wrt emulation, external frequency etc) * 5. Timer_setPeriod() * 6. Timer_start() */ Void Timer_reconfig(Timer_Object *obj, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb) { initObj(obj, tickFxn, params); /* since timer requires a stub func, no Hwi reconfig is needed */ /* leave it to caller to check eb */ postInit(obj, eb); if (obj->startMode == Timer_StartMode_AUTO) { Timer_start(obj); } }
/* * ======== Timer_reconfig ======== * 1. Init obj using params * 2. Reconfig Hwi * 3. Timer_init() * 4. Timer configuration (wrt emulation, external frequency etc) * 5. Timer_setPeriod() * 6. Timer_start() */ Void Timer_reconfig (Timer_Object *obj, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb) { Hwi_Params hwiParams; obj->runMode = params->runMode; obj->startMode = params->startMode; obj->period = params->period; obj->periodType = params->periodType; if (obj->periodType == Timer_PeriodType_MICROSECS) { if (!Timer_setPeriodMicroSecs(obj, obj->period)) { Error_raise(eb, Timer_E_cannotSupport, obj->period, 0); } } obj->arg = params->arg; obj->tickFxn = tickFxn; if (obj->tickFxn) { if (params->hwiParams) { Hwi_Params_copy(&hwiParams, (params->hwiParams)); } else { Hwi_Params_init(&hwiParams); } if (obj->id == 0) { hwiParams.arg = (UArg)obj; if (obj->runMode == Timer_RunMode_CONTINUOUS) { Hwi_reconfig (obj->hwi, Timer_periodicStub, &hwiParams); } else { Hwi_reconfig (obj->hwi, Timer_oneShotStub, &hwiParams); } } else { hwiParams.arg = obj->arg; Hwi_reconfig (obj->hwi, obj->tickFxn, &hwiParams); } } postInit(obj, eb); if (obj->startMode == Timer_StartMode_AUTO) { Timer_start(obj); } }
BeingId NpcHandler::getNpc(Net::MessageIn &msg) { if (msg.getId() == SMSG_NPC_CHOICE || msg.getId() == SMSG_NPC_MESSAGE || msg.getId() == SMSG_NPC_CHANGETITLE) { msg.readInt16("len"); } const BeingId npcId = msg.readBeingId("npc id"); const NpcDialogs::const_iterator diag = NpcDialog::mNpcDialogs.find(npcId); mDialog = nullptr; if (diag == NpcDialog::mNpcDialogs.end()) { // Empty dialogs don't help if (msg.getId() == SMSG_NPC_CLOSE) { closeDialog(npcId); return npcId; } else if (msg.getId() == SMSG_NPC_NEXT) { nextDialog(npcId); return npcId; } else { mDialog = new NpcDialog(npcId); mDialog->postInit(); mDialog->saveCamera(); if (localPlayer) localPlayer->stopWalking(false); NpcDialog::mNpcDialogs[npcId] = mDialog; } } else { NpcDialog *const dialog = diag->second; if (mDialog && mDialog != dialog) mDialog->restoreCamera(); mDialog = dialog; if (mDialog) mDialog->saveCamera(); } return npcId; }
/* * ======== Timer_Module_startup ======== * Calls postInit for all statically-created & constructed * timers to initialize them. */ Int Timer_Module_startup(Int status) { Int i; Timer_Object *obj; if (Timer_startupNeeded) { for (i = 0; i < Timer_NUM_TIMER_DEVICES; i++) { obj = Timer_module->handles[i]; /* if timer was statically created/constructed */ if ((obj != NULL) && (obj->staticInst)) { postInit(obj, NULL); } } } return (Startup_DONE); }
Int Timer_Module_startup(status) { Int i, j; Int mask; Timer_Object *obj; if (Timer_TimerSupportProxy_Module_startupDone()) { for (i = 0; i < Timer_numTimerDevices; i++) { obj = Timer_module->handles[i]; /* if timer was statically created/constructed */ if ((obj != NULL) && (obj->staticInst)) { /* * If timer id is set to Timer_ANY (-1), then find * an unused timer and re-assign timer id to that * of the unused timer. */ if (obj->id == Timer_ANY) { for (j = 0; j < Timer_numTimerDevices; j++) { mask = 1 << j; if ((Timer_anyMask & mask) && ((Timer_module->availMask) & mask)) { obj->id = j; (Timer_module->availMask) &= ~mask; if (obj->hwi != NULL) { ti_sysbios_family_c64p_Hwi_eventMap( obj->intNum, Timer_module->device[obj->id].eventId); } break; } } /* * Assert that a valid timer id is found. */ Assert_isTrue(obj->id != Timer_ANY, Timer_A_notAvailable); } if (Timer_startupNeeded) { postInit(obj, NULL); } } } return (Startup_DONE); } return (Startup_NOTDONE); }
/* * ======== GateDualCore_Module_startup ======== */ Int GateDualCore_Module_startup(Int phase) { UInt i; if (GateDualCore_initGates == TRUE) { /* clean the array of gates */ for (i = 0; i < GateDualCore_numGates; i++ ) { GateDualCore_gateArray[i] = 0; } } /* do post init on all statically created gates */ for (i = 0; i < GateDualCore_Object_count(); i++) { postInit(GateDualCore_Object_get(NULL, i)); } return Startup_DONE; }
void ADM_flyDialog::recomputeSize(void) { float new_zoom = calcZoomFactor(); ResizeMethod new_resizeMethod; uint32_t new_zoomW; uint32_t new_zoomH; if (new_zoom == 1) { new_resizeMethod = RESIZE_NONE; new_zoomW = _w; new_zoomH = _h; } else { new_resizeMethod = RESIZE_AUTO; new_zoomW = uint32_t (_w * new_zoom); new_zoomH = uint32_t (_h * new_zoom); } if (new_resizeMethod == _resizeMethod && new_zoom == _zoom && new_zoomW == _zoomW && new_zoomH == _zoomH) return; if (++_zoomChangeCount > 3 || new_zoomH < 30 || new_zoomW < 30) { ADM_info ("Resisting zoom size change from %dx%d (zoom %.5f) to %dx%d (zoom %.5f)\n", _zoomW, _zoomH, _zoom, new_zoomW, new_zoomH, new_zoom); return; } ADM_info ("Fixing zoom size from %dx%d (zoom %.5f) to correct %dx%d (zoom %.5f)\n", _zoomW, _zoomH, _zoom, new_zoomW, new_zoomH, new_zoom); _resizeMethod = new_resizeMethod; _zoom = new_zoom; _zoomW = new_zoomW; _zoomH = new_zoomH; updateZoom(); postInit (true); sliderChanged(); }
/* * ======== Timer_reconfig ======== * 1. Init obj using params * 2. Reconfig Hwi * 3. Timer_init() * 4. Timer configuration (wrt emulation, external frequency etc) * 5. Timer_setPeriod() * 6. Timer_start() */ Void Timer_reconfig (Timer_Object *obj, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb) { Hwi_Params hwiParams; UInt arBit; /* determine controlReg 'ar' value (continuous / oneshot) */ arBit = (params->runMode == Timer_RunMode_CONTINUOUS) ? 1 : 0; obj->controlRegInit = ((arBit << 1) | (params->controlRegInit.ptv << 2) | (params->controlRegInit.ce << 5) | (params->controlRegInit.free << 6)); obj->runMode = params->runMode; obj->startMode = params->startMode; obj->period = params->period; obj->periodType = params->periodType; obj->arg = params->arg; obj->tickFxn = tickFxn; if (params->extFreq.lo) { obj->extFreq.lo = params->extFreq.lo; } if (obj->tickFxn) { if (params->hwiParams) { Hwi_Params_copy(&hwiParams, (params->hwiParams)); } else { Hwi_Params_init(&hwiParams); } hwiParams.arg = obj->arg; Hwi_reconfig (obj->hwi, obj->tickFxn, &hwiParams); } postInit(obj, eb); if (obj->startMode == Timer_StartMode_AUTO) { Timer_start(obj); } }
Int Timer_Module_startup(status) { Int i; Timer_Object *obj; if (Timer_TimerSupportProxy_Module_startupDone()) { if (Timer_startupNeeded) { for (i = 0; i < Timer_numTimerDevices; i++) { obj = Timer_module->handles[i]; /* if timer was statically created/constructed */ if ((obj != NULL) && (obj->staticInst)) { postInit(obj, NULL); } } } return (Startup_DONE); } return (Startup_NOTDONE); }
/* * ======== Timer_Module_startup ======== * Calls postInit for all statically-created & constructed * timers to initialize them. */ Int Timer_Module_startup(status) { Int i; UInt hwiKey; Timer_Object *obj; hwiKey = Hwi_disable(); CTM_ctm.CTCNTL |= 1; /* enable the CTM */ Hwi_restore(hwiKey); if (Timer_startupNeeded) { for (i = 0; i < Timer_NUM_TIMER_DEVICES; i++) { obj = Timer_module->handles[i]; /* if timer was statically created/constructed */ if ((obj != NULL) && (obj->staticInst)) { postInit(obj, NULL); } } } return (Startup_DONE); }
void Scene::initialize( const std::vector<ActorUId>& persistent_actors ) { mSceneManager = EventManager::create("Scene "+mName+" Manager"); Controller::get()->eventManager()->addListener(fastdelegate::MakeDelegate(this, &Scene::handleInitGUI), InitGUIEvent::TYPE); Controller::get()->eventManager()->addListener( fastdelegate::MakeDelegate(this, &Scene::handleSceneUpdate), SceneUpdateEvent::TYPE ); Controller::get()->eventManager()->addListener( fastdelegate::MakeDelegate(this, &Scene::handleReturnActorCreate), ReturnActorCreatedEvent::TYPE ); Controller::get()->eventManager()->addListener( fastdelegate::MakeDelegate(this, &Scene::handleScenePreDraw), ScenePreDrawEvent::TYPE ); Controller::get()->eventManager()->addListener( fastdelegate::MakeDelegate(this, &Scene::handleSceneDraw), SceneDrawEvent::TYPE ); Controller::get()->eventManager()->addListener( fastdelegate::MakeDelegate(this, &Scene::handleShutDown), ShutDownEvent::TYPE ); if( !persistent_actors.empty() ){ for(auto &id : persistent_actors) { auto actor_weak = ActorManager::get()->retreiveUnique(id); mActors.insert( std::make_pair(id, actor_weak) ); } } auto init = ConfigManager::get()->retreiveActorsForScene( mName ); ///call to inherited initialize for sub classes to pulll custom shit out of the config initialize( ConfigManager::get()->retreiveScene(mName) ); try { //TODO: the problem with persistent actors is how to manage state across scenes, how to identify actors of the same type across scenes that are persistent, one solution is destroy all and reload referencing a serialized state file that is written out and read back in or something //for now, just sending across actors marked 'persistent' and not including them in the config for the next scene, the state has to be handled at runtime then auto & actors = init.getChildren(); auto it = actors.begin(); auto end = actors.end(); for(;it!=end;++it){ auto actor_name = it->getValueForKey("name"); CI_LOG_V("found actor: "+actor_name); auto onInit = it->getValueForKey<bool>( "create_on_scene_init" ); auto persistent = it->getValueForKey<bool>( "persistent" ); if( persistent ){ //make sure its not already in there if( !ec::ActorManager::get()->actorExists( ec::getHash(actor_name) ) ){ if( onInit ){ //make sure it shuld be created on scene init CI_LOG_V("creating actor: "+actor_name); Controller::get()->eventManager()->triggerEvent( CreateActorEvent::create( mName, actor_name) ); } } }else if (onInit){ //make sure it shuld be created on scene init CI_LOG_V("creating actor: "+actor_name); Controller::get()->eventManager()->triggerEvent( CreateActorEvent::create( mName, actor_name) ); } } } catch (const ci::JsonTree::ExcChildNotFound &e) { CI_LOG_E("actors not found in init"); } ///POST INITIALIZE ALL ACTORS auto actor = mActors.begin(); auto end = mActors.end(); while( actor != end ) { if(auto a = (*actor).second.lock()){ a->postInit(); ++actor; }else{ CI_LOG_E("Actor is missing"); ec::Controller::get()->eventManager()->triggerEvent(DestoryActorEvent::create((*actor).first)); actor = mActors.erase(actor); } } postInit(); ///run setup events; manager()->update(); }
/* * ======== Timer_Instance_init ======== * 1. Select timer based on id * 2. Mark timer as in use * 3. Save timer handle if necessary (needed by TimestampProvider on 64). * 4. Init obj using params * 5. Create Hwi if tickFxn !=NULL * 6. Timer_init() * 7. Timer configuration (wrt emulation, external frequency etc) * 8. Timer_setPeriod() * 9. Timer_start() */ Int Timer_Instance_init(Timer_Object *obj, Int id, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb) { UInt key; Int status; Hwi_Params hwiParams; UInt tempId = 0xffff; if ((id != 0) && (id != Timer_ANY)) { Error_raise(eb, Timer_E_invalidTimer, id, 0); return (1); } key = Hwi_disable(); if (id == Timer_ANY) { if ((Timer_anyMask & 1) && (Timer_module->availMask & 1)) { Timer_module->availMask &= ~(1); tempId = 0; } } else if (Timer_module->availMask & 1) { Timer_module->availMask &= ~(1); tempId = id; } Hwi_restore(key); obj->staticInst = FALSE; if (tempId == 0xffff) { Error_raise(eb, Timer_E_notAvailable, id, 0); return (NO_TIMER_AVAIL); } else { obj->id = tempId; } Timer_module->handle = obj; obj->runMode = params->runMode; obj->startMode = params->startMode; obj->period = params->period; obj->periodType = params->periodType; obj->extFreq.lo = params->extFreq.lo; obj->extFreq.hi = params->extFreq.hi; if (obj->periodType == Timer_PeriodType_MICROSECS) { if (!Timer_setPeriodMicroSecs(obj, obj->period)) { Error_raise(eb, Timer_E_cannotSupport, obj->period, 0); Hwi_restore(key); return (BAD_PERIOD); } } obj->arg = params->arg; obj->intNum = 15; obj->tickFxn = tickFxn; if (obj->tickFxn) { if (params->hwiParams) { Hwi_Params_copy(&hwiParams, (params->hwiParams)); } else { Hwi_Params_init(&hwiParams); } hwiParams.arg = (UArg)obj; if (obj->runMode == Timer_RunMode_CONTINUOUS) { obj->hwi = Hwi_create (obj->intNum, Timer_periodicStub, &hwiParams, eb); } else { obj->hwi = Hwi_create (obj->intNum, Timer_oneShotStub, &hwiParams, eb); } if (obj->hwi == NULL) { return (NO_HWI_OBJ); } } else { obj->hwi = NULL; } status = postInit(obj, eb); if (status) { return (status); } if (obj->startMode == Timer_StartMode_AUTO) { Timer_start(obj); } return (0); }
/** Initialization of the object. */ void init () { postInit (); }
int ScriptParametersDialog::exec() { QTimer::singleShot(1, this, SLOT(postInit())); return QDialog::exec(); }
/* * ======== Timer_Instance_init ======== * 1. Select timer based on id * 2. Mark timer as in use * 3. Save timer handle if necessary (needed by TimestampProvider on 64). * 4. Init obj using params * 5. Create Hwi if tickFxn !=NULL * 6. Timer_init() * 7. Timer configuration (wrt emulation, external frequency etc) * 8. Timer_setPeriod() * 9. Timer_start() */ Int Timer_Instance_init(Timer_Object *obj, Int id, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb) { UInt key; Int i, status; Hwi_Params hwiParams; UInt tempId = 0xffff; /* make sure id is not greater than number of 32-bit timer devices */ if (id >= Timer_numTimerDevices ) { if (id != Timer_ANY) { Error_raise(eb, Timer_E_invalidTimer, id, 0); return (1); } } key = Hwi_disable(); if (id == Timer_ANY) { for (i = 0; i < Timer_numTimerDevices; i++) { if ((Timer_anyMask & (1 << i)) && (Timer_module->availMask & (1 << i))) { Timer_module->availMask &= ~(1 << i); tempId = i; break; } } } else if (Timer_module->availMask & (1 << id)) { Timer_module->availMask &= ~(1 << id); tempId = id; } Hwi_restore(key); obj->staticInst = FALSE; if (tempId == 0xffff) { Error_raise(eb, Timer_E_notAvailable, id, 0); return (2); } else { obj->id = tempId; } Timer_module->handles[obj->id] = obj; /* initialize the timer state object */ initObj(obj, tickFxn, params); /* create the Hwi object if function is specified */ if (obj->tickFxn != NULL) { if (params->hwiParams) { Hwi_Params_copy(&hwiParams, params->hwiParams); } else { Hwi_Params_init(&hwiParams); } hwiParams.eventId = Timer_module->device[obj->id].eventId; hwiParams.arg = (UArg)obj; obj->hwi = Hwi_create(obj->intNum, Timer_stub, &hwiParams, eb); if (obj->hwi == NULL) { return (4); } } else { obj->hwi = NULL; } status = postInit(obj, eb); if (status) { return (status); } if (obj->startMode == Timer_StartMode_AUTO) { Timer_start(obj); } return (0); }
/* * ======== Timer_Instance_init ======== * 1. Select timer based on id * 2. Mark timer as in use * 3. Save timer handle if necessary (needed by TimestampProvider on 64). * 4. Init obj using params * 5. Create Hwi if tickFxn !=NULL * 6. Timer_init() * 7. Timer configuration (wrt emulation, external frequency etc) * 8. Timer_setPeriod() * 9. Timer_start() */ Int Timer_Instance_init(Timer_Object *obj, Int id, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb) { UInt key; Int i, status; Hwi_Params hwiParams; UInt arBit; UInt tempId = 0xffff; if (id >= Timer_NUM_TIMER_DEVICES) { if (id != Timer_ANY) { Error_raise(eb, Timer_E_invalidTimer, id, 0); return (1); } } key = Hwi_disable(); if (id == Timer_ANY) { for (i = 0; i < Timer_NUM_TIMER_DEVICES; i++) { if ((Timer_anyMask & (1 << i)) && (Timer_module->availMask & (1 << i))) { Timer_module->availMask &= ~(1 << i); tempId = i; break; } } } else if (Timer_module->availMask & (1 << id)) { Timer_module->availMask &= ~(1 << id); tempId = id; } Hwi_restore(key); obj->staticInst = FALSE; if (tempId == 0xffff) { Error_raise(eb, Timer_E_notAvailable, id, 0); return (2); } else { obj->id = tempId; } Timer_module->handles[obj->id] = obj; /* determine controlReg 'ar' value (continuous / oneshot) */ arBit = (params->runMode == Timer_RunMode_CONTINUOUS) ? 1 : 0; obj->controlRegInit = ((arBit << 1) | (params->controlRegInit.ptv << 2) | (params->controlRegInit.ce << 5) | (params->controlRegInit.free << 6)); obj->runMode = params->runMode; obj->startMode = params->startMode; obj->period = params->period; obj->periodType = params->periodType; obj->arg = params->arg; obj->intNum = intNumDef[obj->id]; obj->tickFxn = tickFxn; /* extFreq.hi is ignored */ if (params->extFreq.lo) { obj->extFreq.lo = params->extFreq.lo; } if (obj->tickFxn) { if (params->hwiParams) { Hwi_Params_copy(&hwiParams, (params->hwiParams)); } else { Hwi_Params_init(&hwiParams); } hwiParams.arg = obj->arg; obj->hwi = Hwi_create (obj->intNum, obj->tickFxn, &hwiParams, eb); if (obj->hwi == NULL) { return (3); } } else { obj->hwi = NULL; } status = postInit(obj, eb); if (status) { return (status); } if (obj->startMode == Timer_StartMode_AUTO) { Timer_start(obj); } return (0); }
/* * ======== Timer_Instance_init ======== * 1. Select timer based on id * 2. Mark timer as in use * 3. Save timer handle if necessary (needed by TimestampProvider on 64). * 4. Init obj using params * 5. Create Hwi if tickFxn !=NULL * 6. Timer_init() * 7. Timer configuration (wrt emulation, external frequency etc) * 8. Timer_setPeriod() * 9. Timer_start() */ Int Timer_Instance_init(Timer_Object *obj, Int id, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb) { UInt key; Int i, status; Hwi_Params hwiParams; UInt tempId = 0xffff; if (id >= Timer_NUM_TIMER_DEVICES) { if (id != Timer_ANY) { Error_raise(eb, Timer_E_invalidTimer, id, 0); return (1); } } key = Hwi_disable(); if (id == Timer_ANY) { for (i = 0; i < Timer_NUM_TIMER_DEVICES; i++) { if ((Timer_anyMask & (1 << i)) && (Timer_module->availMask & (1 << i))) { Timer_module->availMask &= ~(1 << i); tempId = i; break; } } } else if (Timer_module->availMask & (1 << id)) { Timer_module->availMask &= ~(1 << id); tempId = id; } Hwi_restore(key); obj->staticInst = FALSE; if (tempId == 0xffff) { Error_raise(eb, Timer_E_notAvailable, id, 0); return (2); } else { obj->id = tempId; } /* if timer id == 0, use systick */ if (obj->id == 0) { obj->ctmid = 0; obj->intNum = 15; } /* if timer id == 1, must select which CTM timer based on core id */ else { if (Core_getId() == 0) { obj->ctmid = 0; obj->intNum = 18; } else { obj->ctmid = 1; obj->intNum = 22; } } obj->runMode = params->runMode; obj->startMode = params->startMode; obj->period = params->period; obj->periodType = params->periodType; obj->extFreq.lo = params->extFreq.lo; obj->extFreq.hi = params->extFreq.hi; if (obj->periodType == Timer_PeriodType_MICROSECS) { if (!Timer_setPeriodMicroSecs(obj, obj->period)) { Error_raise(eb, Timer_E_cannotSupport, obj->period, 0); Hwi_restore(key); return (4); } } obj->arg = params->arg; obj->tickFxn = tickFxn; if (obj->tickFxn) { if (params->hwiParams) { Hwi_Params_copy(&hwiParams, (params->hwiParams)); } else { Hwi_Params_init(&hwiParams); } /* we'll enable the interrupt when we're ready */ hwiParams.enableInt = FALSE; /* SysTick needs to be acknowledged, use stub functions */ if (obj->id == 0) { hwiParams.arg = (UArg)obj; if (obj->runMode == Timer_RunMode_CONTINUOUS) { obj->hwi = Hwi_create (obj->intNum, Timer_periodicStub, &hwiParams, eb); } else { obj->hwi = Hwi_create (obj->intNum, Timer_oneShotStub, &hwiParams, eb); } } /* CTM doesn't need to be acknowledged, no stub required */ else { hwiParams.arg = obj->arg; obj->hwi = Hwi_create (obj->intNum, obj->tickFxn, &hwiParams, eb); } if (obj->hwi == NULL) { return (3); } } else { obj->hwi = NULL; } Timer_module->handles[obj->id] = obj; status = postInit(obj, eb); if (status) { return (status); } if (obj->startMode == Timer_StartMode_AUTO) { Timer_start(obj); } return (0); }
/* * ======== Timer_Instance_init ======== * 1. Select timer based on id * 2. Mark timer as in use * 3. Save timer handle if necessary (needed by TimestampProvider on 64). * 4. Init obj using params * 5. Create Hwi if tickFxn !=NULL * 6. Timer_init() * 7. Timer configuration (wrt emulation, external frequency etc) * 8. Timer_setPeriod() * 9. Timer_start() */ Int Timer_Instance_init(Timer_Object *obj, Int id, Timer_FuncPtr tickFxn, const Timer_Params *params, Error_Block *eb) { UInt key; Int i, status; Hwi_Params hwiParams; UInt tempId = 0xffff; if (id >= Timer_NUM_TIMER_DEVICES) { if (id != Timer_ANY) { Error_raise(eb, Timer_E_invalidTimer, id, 0); return (1); } } key = Hwi_disable(); if (id == Timer_ANY) { for (i = 0; i < Timer_NUM_TIMER_DEVICES; i++) { if ((Timer_anyMask & (1 << i)) && (Timer_module->availMask & (1 << i))) { Timer_module->availMask &= ~(1 << i); tempId = i; break; } } } else if (Timer_module->availMask & (1 << id)) { Timer_module->availMask &= ~(1 << id); tempId = id; } Hwi_restore(key); obj->staticInst = FALSE; if (tempId == 0xffff) { Error_raise(eb, Timer_E_notAvailable, id, 0); return (2); } else { obj->id = tempId; } /* if timer id == 0, use CTM 0 */ if (obj->id == 0) { obj->ctmid = 0; obj->intNum = 18; } /* if timer id == 1, use CTM 1 */ else { obj->ctmid = 1; obj->intNum = 22; } obj->runMode = params->runMode; obj->startMode = params->startMode; obj->period = params->period; obj->periodType = params->periodType; obj->extFreq.lo = params->extFreq.lo; obj->extFreq.hi = params->extFreq.hi; if (obj->periodType == Timer_PeriodType_MICROSECS) { if (!Timer_setPeriodMicroSecs(obj, obj->period)) { Error_raise(eb, Timer_E_cannotSupport, obj->period, 0); return (4); } } obj->arg = params->arg; obj->tickFxn = tickFxn; if (obj->tickFxn) { if (params->hwiParams) { Hwi_Params_copy(&hwiParams, (params->hwiParams)); } else { Hwi_Params_init(&hwiParams); } /* we'll enable the interrupt when we're ready */ hwiParams.enableInt = FALSE; hwiParams.arg = obj->arg; obj->hwi = Hwi_create (obj->intNum, obj->tickFxn, &hwiParams, eb); if (obj->hwi == NULL) { return (3); } } else { obj->hwi = NULL; } Timer_module->handles[obj->id] = obj; status = postInit(obj, eb); if (status) { return (status); } if (obj->startMode == Timer_StartMode_AUTO) { Timer_start(obj); } return (0); }