Exemplo n.º 1
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;
}
Exemplo n.º 2
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; 
} 
Exemplo n.º 3
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;
}