/* Timer Init */ void TimerInit(void) { *T0_MODE = 0x0000; TimerInterruptID = AddIntcHandler(9, TimerInterrupt, 0); EnableIntc(9); *T0_COUNT = 0; *T0_MODE = ( 2 << 0 )+( 1 << 7 )+( 1 << 9 ); TimerInterruptCount = 0; }
/* enum { kINTC_GS, kINTC_SBUS, kINTC_VBLANK_START, kINTC_VBLANK_END, kINTC_VIF0, kINTC_VIF1, kINTC_VU0, kINTC_VU1, kINTC_IPU, kINTC_TIMER0, kINTC_TIMER1 }; */ int gsKit_add_vsync_handler(int (*vsync_callback)()) { int callback_id; DIntr(); callback_id = AddIntcHandler(2, vsync_callback, 0); EnableIntc(kINTC_VBLANK_START); EIntr(); return callback_id; }
int gsKit_add_hsync_handler(int (*hsync_callback)()) { int callback_id; DIntr(); callback_id = AddIntcHandler(INTC_GS, hsync_callback, 0); EnableIntc(INTC_GS); // Unmask HSync interrupt GsPutIMR(GsGetIMR() & ~0x0400); EIntr(); return callback_id; }
int gsKit_add_vsync_handler(int (*vsync_callback)()) { int callback_id; DIntr(); callback_id = AddIntcHandler(INTC_VBLANK_S, vsync_callback, 0); EnableIntc(INTC_VBLANK_S); // Unmask VSync interrupt GsPutIMR(GsGetIMR() & ~0x0800); EIntr(); return callback_id; }
int SDLThread::ThreadProc(SDLThread *thread) { _gthread_async_id = GetThreadId(); T0_MODE = 0; // Deshabilito antes de tocar nada tim0_handler_id = AddIntcHandler(INTC_TIM0, ms_handler, 0); EnableIntc(INTC_TIM0); T0_COUNT = 0; T0_COMP = 586; // 150MHZ / 256 / 1000 //T0_COMP = 50; T0_MODE = 2 | (0<<2) | (0<<6) | (1<<7) | (1<<8); return thread->run(); }
int graph_add_vsync_handler(int (*vsync_callback)()) { int callback_id; DIntr(); callback_id = AddIntcHandler(2, vsync_callback, -1); EnableIntc(2); EIntr(); return callback_id; }
/* This is only called if the event thread is not running */ int SDL_SYS_TimerInit(void) { printf("initializing timer..\n"); *T1_MODE = 0; // Deshabilito antes de tocar nada tim1_handler_id = AddIntcHandler(INTC_TIM1, ms_handler, 0); EnableIntc(INTC_TIM1); *T1_COUNT = 0; *T1_COMP = 586; /* 150MHZ / 256 / 1000 */ *T1_MODE = 2 | (0<<2) | (0<<6) | (1<<7) | (1<<8); printf("timer init ended okay\n"); return 0; }
void MFSystem_InitModulePlatformSpecific() { // Init the timer and register the interrupt handler *T1_MODE = 0x0000; s_tnInterruptID = AddIntcHandler(kINTC_TIMER1, tnTimeInterrupt, 0); EnableIntc(kINTC_TIMER1); // Initialize the timer registers // CLKS: 0x02 - 1/256 of the BUSCLK (0x01 is 1/16th) // CUE: 0x01 - Start/Restart the counting // OVFE: 0x01 - An interrupt is generated when an overflow occurs // -------------------------------------------------------------- *T1_COUNT = 0; *T1_MODE = Tn_MODE(0x02, 0, 0, 0, 0, 0x01, 0, 0x01, 0, 0); s_tnInterruptCount = 0; }
void _ps2sdk_time_init(void) { *T_MODE = 0x0000; // Disable T_MODE if (s_intrOverflowID == -1) { s_intrOverflowID = AddIntcHandler(kINTC_TIMER1, intrOverflow, 0); EnableIntc(kINTC_TIMER1); } // Initialize the timer registers // CLKS: 0x02 - 1/256 of the BUSCLK (0x01 is 1/16th) // CUE: 0x01 - Start/Restart the counting // OVFE: 0x01 - An interrupt is generated when an overflow occurs *T_COUNT = 0; *T_MODE = Tn_MODE(0x02, 0, 0, 0, 0, 0x01, 0, 0x01, 0, 0); s_intrOverflowCount = 0; }
/** Initializes pg library After calculating the text size, initialize() allocates enough memory to allow fastest access to arc structures, and some more for sampling statistics. Note that this also installs a timer that runs at 1000 hertz on TIM0. You can change the definition above to hook on TIM1 instead. */ static void initialize() { initialized = 1; atexit(cleanup); memset(&gp, '\0', sizeof(gp)); gp.state = GMON_PROF_ON; gp.lowpc = (unsigned int)&_ftext; gp.highpc = (unsigned int)&_etext; gp.textsize = gp.highpc - gp.lowpc; gp.hashfraction = HISTFRACTION; gp.narcs = (gp.textsize + gp.hashfraction - 1) / gp.hashfraction; gp.arcs = (struct rawarc *)malloc(sizeof(struct rawarc) * gp.narcs); if (gp.arcs == NULL) { gp.state = GMON_PROF_ERROR; return; } gp.nsamples = (gp.textsize + gp.hashfraction - 1) / gp.hashfraction; gp.samples = (unsigned int *)malloc(sizeof(unsigned int) * gp.nsamples); if (gp.samples == NULL) { free(gp.arcs); gp.arcs = 0; gp.state = GMON_PROF_ERROR; return; } memset((void *)gp.arcs, '\0', gp.narcs * (sizeof(struct rawarc))); memset((void *)gp.samples, '\0', gp.nsamples * (sizeof(unsigned int ))); gp.timer = AddIntcHandler2(INTC_TIM, profil, 0, 0); EnableIntc(INTC_TIM); /* fire up timer, every 1 ms */ *T_COUNT = 0; *T_COMP = 586; /* 150MHZ / 256 / 1000 */ *T_MODE = 2 | (0<<2) | (0<<6) | (1<<7) | (1<<8); }
int ps2time_init( void ) { CdvdClock_t clock; struct tm tm_time; static unsigned int monthdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; // query the RTC cdInit(CDVD_INIT_NOCHECK); if( !cdReadClock(&clock) ) return -1; tm_time.tm_sec = BCD2DEC(clock.second); tm_time.tm_min = BCD2DEC(clock.minute); tm_time.tm_hour = BCD2DEC(clock.hour); // hour in Japan (GMT + 9) tm_time.tm_mday = BCD2DEC(clock.day); tm_time.tm_mon = BCD2DEC(clock.month) - 1; // RTC months range from 1 - 12 tm_time.tm_year = BCD2DEC(clock.year) + 100; // RTC returns year less 2000 if( tm_time.tm_hour < 9 ) { // go back to last month if( tm_time.tm_mday == 1 ) { // go back to last year if month is january if( tm_time.tm_mon == 0 ) { tm_time.tm_mon = 11; tm_time.tm_year = tm_time.tm_year - 1; } else { tm_time.tm_mon = tm_time.tm_mon - 1; } // if going back to february and year is a leapyear if( tm_time.tm_mon == 1 && IS_LEAP_YEAR(tm_time.tm_year + 1900)) { tm_time.tm_mday = 29; } else { tm_time.tm_mday = monthdays[ tm_time.tm_mon ]; } } else { tm_time.tm_mday = tm_time.tm_mday - 1; } tm_time.tm_hour = (24 - (9 - tm_time.tm_hour)) % 24; } else { tm_time.tm_hour -= 9; } g_ps2time_start = ps2time_mktime(&tm_time); // setup EE timer1 *T1_MODE = 0x0000; // enable the overflow interrupt handler g_interruptID = AddIntcHandler(T1_INTC, ps2time_intr_handler, 0); EnableIntc(T1_INTC); g_interruptCount = 0; *T1_COUNT = 0; *T1_MODE = Tn_MODE(0x02, 0, 0, 0, 0, 0x01, 0, 0x01, 0, 0); // set the timezone as offset in minutes from GMT ps2time_setTimezone( configGetTimezone() ); return 0; }