Exemple #1
0
/* 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;
}
Exemple #2
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;
}
Exemple #3
0
void start_ps2_timer()
{
	T0_MODE=0; // disable timer
	id_TIM=AddIntcHandler(INT_TIMER0,handlerItim,0); // set handler
	H_EnableIntcHandler(INT_TIMER0); // enable handler

	count_time=0; // counter

	T0_COMP=(unsigned) (TIME_MS/(256.0/CLOCK_BUS)); //  adjust comparator to 2 ms
	T0_COUNT=0; // counter at zero
	T0_MODE=256+128+64+2; // set mode to clock=BUSCLK/256, reset to 0,count and interrupt if comparator equal...
}
Exemple #4
0
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;
}
Exemple #5
0
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();
}
Exemple #7
0
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;
}
Exemple #9
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;
}
Exemple #10
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; 
} 
Exemple #11
0
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;
}