// Declare Main application void main(void) { // Initialize variables vos_init_semaphore(&DevicesStarted, 0); vos_init_mutex(&dprintLock, VOS_MUTEX_UNLOCKED); Delay = 511; vos_init_semaphore(&EnumerationComplete, 0); vos_init_semaphore(&SendKeyboardReport, 0); // Initialise RTOS vos_init(VOS_QUANTUM, VOS_TICK_INTERVAL, NUMBER_OF_DEVICES); // Sets the CPU frequency of the connected device. vos_set_clock_frequency(VOS_48MHZ_CLOCK_FREQUENCY); // Initialise devices if (InitDevices()) { // Initialise threads - pass a ThreadID to each thread vos_create_thread(28, SIZEOF_tcb, &Blink, 1, 1); vos_create_thread(27, SIZEOF_tcb, &EnumerateSlave, 1, 2); vos_create_thread(26, SIZEOF_tcb, &FindKeyboard, 1, 4); vos_create_thread(25, SIZEOF_tcb, &SendReports, 1, 8); vos_create_thread( 1, SIZEOF_tcb, &MyIdleTask, 0); // Start Scheduler to kick off the created thread(s) vos_start_scheduler(); } // It is an error to get here, use a breakpoint to catch this while (1) { CheckStatus(1, ErrorSchedulerDidNotStart); } }
// Declare Main application void main(void) { // Initialize variables vos_init_semaphore(&DevicesStarted, 0); // Initialise RTOS vos_init(VOS_QUANTUM, VOS_TICK_INTERVAL, NUMBER_OF_DEVICES); // Sets the CPU frequency of the connected device. vos_set_clock_frequency(VOS_48MHZ_CLOCK_FREQUENCY); // Initialise devices if (InitDevices()) { // Initialise thread(s) vos_create_thread(27, SIZEOF_tcb, &HelloWorld, 0); vos_create_thread(28, SIZEOF_tcb, &Blink, 0); // Start Scheduler to kick off the created thread(s) vos_start_scheduler(); } // It is an error to get here, use a breakpoint to catch this while (1) { CheckStatus(FALSE, ErrorSchedulerDidNotStart); } }
void OpenCLContext::init(const CLDevice device, const CLVendor vendor, const bool verbose_startup) { std::lock_guard<std::mutex> lock(context_lock_); createContext(device, vendor, verbose_startup); InitDevices(device, verbose_startup); createCommandQueues(verbose_startup); // For each device }
/** Start Rexy. * * @return Return 0 */ int StartRexy(void) { // just initialization of g_scr_dev. no allocation. if ( InitDevices() < 0 ) return 0; InitStructures(); Rexy_WinMain(); return 0; }
void InputManager::Init() { InitDevices(); InitMappings(); // Init state currentKeyboardState = 0; previousKeyboardState = 0; currentMouseButtonState = 0; previousMouseButtonState = 0; abs_X = 0; abs_Y = 0; rel_X = 0; rel_Y = 0; }
/** * \brief Este es el hilo de acceso a los dispositvos de bloques AT * \param utcb */ void at_thread(void * utcb) { // Configuro inicialmente el dispositivo InitDevices(); // leo unos cuantos bloques for (int i = 0 ; i < 1000 ; i++) { if (ReadBlock(0,i,buffer)) { printf("Leido %d \n\n\n",i); } else printf("Bloque no leido\n"); } while (1) { // aqui espero por peticiones de bloques printf("Soy el hilo del ATA haraganeando\n"); //PassToKernelMode(); } }
//========================================================================= //----- (00000148) -------------------------------------------------------- __myevic__ void Main() { InitDevices(); InitVariables(); // Enable chip temp sensor sampling by ADC if ( ISRX300 ) { SYS->IVSCTL |= SYS_IVSCTL_VTEMPEN_Msk; } InitHardware(); myprintf( "\n\nJoyetech APROM\n" ); myprintf( "CPU @ %dHz(PLL@ %dHz)\n", SystemCoreClock, PllClock ); SetBatteryModel(); gFlags.sample_vbat = 1; ReadBatteryVoltage(); gFlags.sample_btemp = 1; ReadBoardTemp(); InitDisplay(); MainView(); SplashTimer = 3; CustomStartup(); if ( !PD3 ) { DrawScreen(); while ( !PD3 ) ; } while ( 1 ) { while ( gFlags.playing_fb ) { // Flappy Bird game loop fbCallTimeouts(); if ( gFlags.tick_100hz ) { // 100Hz gFlags.tick_100hz = 0; ResetWatchDog(); TimedItems(); SleepIfIdle(); GetUserInput(); if ( !PE0 ) SleepTimer = 3000; } if ( gFlags.tick_10hz ) { // 10Hz gFlags.tick_10hz = 0; DataFlashUpdateTick(); } } if ( gFlags.firing ) { ReadAtoCurrent(); } if ( gFlags.tick_5khz ) { // 5000Hz gFlags.tick_5khz = 0; if ( gFlags.firing ) { RegulateBuckBoost(); } } if ( gFlags.tick_1khz ) { // 1000Hz gFlags.tick_1khz = 0; if ( gFlags.firing ) { ReadAtomizer(); if ( ISMODETC(dfMode) ) { if ( gFlags.check_mode ) { CheckMode(); } TweakTargetVoltsTC(); } else if ( ISMODEVW(dfMode) ) { TweakTargetVoltsVW(); } } if ( dfStatus.vcom ) { VCOM_Poll(); } } if ( gFlags.tick_100hz ) { // 100Hz gFlags.tick_100hz = 0; ResetWatchDog(); if ( gFlags.read_battery ) { gFlags.read_battery = 0; } TimedItems(); SleepIfIdle(); ReadBatteryVoltage(); ReadBoardTemp(); if ( gFlags.firing && BoardTemp >= 70 ) { Overtemp(); } if ( ISVTCDUAL ) { BatteryChargeDual(); } else if ( ISCUBOID || ISCUBO200 || ISRX200S || ISRX23 || ISRX300 ) { BatteryCharge(); } if (( gFlags.anim3d ) && ( Screen == 1 ) && ( !EditModeTimer )) { anim3d( 0 ); } if ( Screen == 60 ) { AnimateScreenSaver(); } if ( gFlags.firing ) { if ( gFlags.read_bir && ( FireDuration > 10 ) ) { ReadInternalResistance(); } if ( PreheatTimer && !--PreheatTimer ) { uint16_t pwr; if ( dfMode == 6 ) { pwr = dfSavedCfgPwr[ConfigIndex]; } else { pwr = dfPower; } if ( pwr > BatteryMaxPwr ) { gFlags.limit_power = 1; PowerScale = 100 * BatteryMaxPwr / pwr; } else { gFlags.limit_power = 0; PowerScale = 100; } } } if ( KeyTicks >= 5 ) { KeyRepeat(); } GetUserInput(); } if ( gFlags.tick_10hz ) { // 10Hz gFlags.tick_10hz = 0; DataFlashUpdateTick(); LEDTimerTick(); if ( gFlags.firing ) { ++FireDuration; if ( gFlags.monitoring ) { Monitor(); } } if ( ShowWeakBatFlag ) --ShowWeakBatFlag; if ( ShowProfNum ) --ShowProfNum; if ( !( gFlags.firing && ISMODETC(dfMode) ) ) { DrawScreen(); } if ( KeyTicks < 5 ) { KeyRepeat(); } } if ( gFlags.tick_5hz ) { // 5Hz gFlags.tick_5hz = 0; if ( !gFlags.rtcinit && NumBatteries ) { InitRTC(); } if ( gFlags.firing ) { if ( TargetVolts == 0 ) { ProbeAtomizer(); } } else { if ( !dfStatus.off && Event == 0 && ( AtoProbeCount < 12 ) && ( Screen == 0 || Screen == 1 || Screen == 5 ) ) { ProbeAtomizer(); } } if ( IsClockOnScreen() ) { static uint8_t u8Seconds = 61; S_RTC_TIME_DATA_T rtd; GetRTC( &rtd ); if ( (uint8_t)rtd.u32Second != u8Seconds ) { u8Seconds = (uint8_t)rtd.u32Second; gFlags.refresh_display = 1; } } } if ( gFlags.tick_2hz ) { // 2Hz gFlags.tick_2hz = 0; gFlags.osc_1hz ^= 1; if ( gFlags.firing ) { if ( ISMODETC(dfMode) ) { DrawScreen(); } } else { if ( !dfStatus.off && Event == 0 && ( AtoProbeCount >= 12 ) && ( Screen == 0 || Screen == 1 || Screen == 5 ) ) { ProbeAtomizer(); } if ( gFlags.monitoring ) { Monitor(); } } } if ( gFlags.tick_1hz ) { // 1Hz gFlags.tick_1hz = 0; if ( SplashTimer ) { --SplashTimer; if ( !SplashTimer ) { MainView(); } } if ( !gFlags.firing && !dfStatus.off && !EditModeTimer ) { if ( HideLogo ) { if ( Screen == 1 ) { --HideLogo; if ( !HideLogo ) { gFlags.refresh_display = 1; } } } } } EventHandler(); } }
Ci8042() { m_IsScrollActive = false; m_IsNumActive = false; m_IsCapsActive = false; KeLinkIrq(1); KeLinkIrq(12); KeEnableNotification(NfKe_Irq); KeEnableNotification(NfKe_TimerTick); KeEnableNotification(NfKe_TerminateProcess); KeEnableNotification(NfKeyboard_SwitchLEDStatus); InitDevices(); CNotification<16> N; for (;;) { KeWaitFor(1); dword NfCount = KeGetNotificationCount(); for (dword z = 0; z < NfCount; z++) { N.Recv(); if (N.GetID() == NfKe_TimerTick) { m_TimeoutTimer++; if (m_TimeoutTimer >= 20) { KeDisableNotification(NfKe_TimerTick); //DebugOut("[MouseInitTimeout]", 18); KeInPortByte(0x60); m_IsInitFinished = true; } } else if (N.GetID() == NfKe_Irq) { if (N.GetByte(0) == 1) { byte D = KeInPortByte(0x60); //DebugOut("[fK:", 4); //DebugOut(D); //DebugOut("]", 1); OnKeybByte(D); KeEndOfInterrupt(1); } else if (N.GetByte(0) == 12) { bool M = false; if (KeInPortByte(0x64) & 0x20) M = true; byte D = KeInPortByte(0x60); //if (M) // DebugOut("[fM:", 4); //else // DebugOut("[fm:", 4); //DebugOut(D); //DebugOut("]", 1); if (M) OnMouseByte(D); KeEndOfInterrupt(12); } } else if (N.GetID() == NfKeyboard_SwitchLEDStatus) { SwitchLEDStatus(N.GetByte(0)); } else if (N.GetID() == NfKe_TerminateProcess) return; } if (KeGetNotificationCount() == 0) { if (m_LEDSwitchState == 1) { SendKeyboardData(0xED); m_LEDSwitchState = 2; } else if (m_LEDSwitchState == 3) { SendKeyboardData(m_LEDStatus); m_LEDSwitchState = 4; } } } }
INT NS_DIM_PREFIX InitUg (int *argcp, char ***argvp) { INT err; #ifdef Debug char buffer[256]; char debugfilename[NAMESIZE]; #endif #ifdef ModelP /* init ppif module */ if ((err = InitPPIF (argcp, argvp)) != PPIF_SUCCESS) { printf ("ERROR in InitParallel while InitPPIF.\n"); printf ("aborting ug\n"); return (1); } #endif /* init the low module */ if ((err = InitLow ()) != 0) { printf ("ERROR in InitUg while InitLow (line %d): called routine line %d\n", (int) HiWrd (err), (int) LoWrd (err)); printf ("aborting ug\n"); return (1); } /* init parallelization module */ #ifdef ModelP PRINTDEBUG (init, 1, ("%d: InitParallel()...\n", me)) if ((err = InitParallel (argcp, argvp)) != 0) { printf ("ERROR in InitUg while InitParallel (line %d): called routine line %d\n", (int) HiWrd (err), (int) LoWrd (err)); printf ("aborting ug\n"); return (1); } #endif /* create struct for configuration parameters */ if (MakeStruct (":conf")) return (__LINE__); if (SetStringVar ("conf:arch", ARCHNAME)) return (__LINE__); /* set variable for parallel modus */ #ifdef ModelP if (SetStringValue ("conf:parallel", 1.0)) return (__LINE__); if (SetStringValue ("conf:procs", (DOUBLE) procs)) return (__LINE__); if (SetStringValue ("conf:me", (DOUBLE) me)) return (__LINE__); #else if (SetStringValue ("conf:parallel", 0.0)) return (__LINE__); if (SetStringValue ("conf:procs", 1.0)) return (__LINE__); if (SetStringValue ("conf:me", 0.0)) return (__LINE__); #endif /* init the devices module */ if ((err = InitDevices (argcp, *argvp)) != 0) { printf ("ERROR in InitUg while InitDevices (line %d): called routine line %d\n", (int) HiWrd (err), (int) LoWrd (err)); printf ("aborting ug\n"); return (1); } #ifdef Debug { int i; for (i = 1; i < *argcp; i++) if (strncmp ((*argvp)[i], "-dbgfile", 8) == 0) break; if ((i < *argcp) && (GetDefaultValue (DEFAULTSFILENAME, UGDEBUGRFILE, buffer) == 0) && (sscanf (buffer, " %s ", debugfilename) == 1)) { if (SetPrintDebugToFile (debugfilename) != 0) { printf ("ERROR while opening debug file '%s'\n", debugfilename); printf ("aborting ug\n"); return (1); } UserWriteF ("debug info is captured to file '%s'\n", debugfilename); } else { SetPrintDebugProc (printf); UserWriteF ("debug info is printed to stdout\n"); } } #endif /* init the domain module */ if ((err = InitDom ()) != 0) { printf ("ERROR in InitDom while InitDom (line %d): called routine line %d\n", (int) HiWrd (err), (int) LoWrd (err)); printf ("aborting ug\n"); return (1); } /* init the gm module */ if ((err = InitGm ()) != 0) { printf ("ERROR in InitUg while InitGm (line %d): called routine line %d\n", (int) HiWrd (err), (int) LoWrd (err)); printf ("aborting ug\n"); return (1); } /* init the numerics module */ if ((err = InitNumerics ()) != 0) { printf ("ERROR in InitUg while InitNumerics (line %d): called routine line %d\n", (int) HiWrd (err), (int) LoWrd (err)); printf ("aborting ug\n"); return (1); } /* init the ui module */ if ((err = InitUi (argcp[0], argvp[0])) != 0) { printf ("ERROR in InitUg while InitUi (line %d): called routine line %d\n", (int) HiWrd (err), (int) LoWrd (err)); printf ("aborting ug\n"); return (1); } /* init the graphics module */ if ((err = InitGraphics ()) != 0) { printf ("ERROR in InitUg while InitGraphics (line %d): called routine line %d\n", (int) HiWrd (err), (int) LoWrd (err)); printf ("aborting ug\n"); return (1); } return (0); }