Example #1
0
/* stop the stopwatch, and return the time */
u32 timer_stop(void)
{
	/* stop the timer */
	BIT_CLR(TIMER32(TMRCONTROL), RUN);
	/* get access to counter */
	BIT_SET(TIMER32(TMRCONTROL), LDCNT);

	return TIMER32(TMRCOUNT);
}
Example #2
0
/* start the stopwatch */
void timer_start(void)
{
	/* make sure the timer is stopped */
	BIT_CLR(TIMER32(TMRCONTROL), RUN);

	/* zero out the timer */
	TIMER32(TMRCOUNT) = 0;

	/* run the timer */
	BIT_SET(TIMER32(TMRCONTROL), RUN);
}
Example #3
0
/* Pre-initialize a timer; set values but don't start it */
int timer_prime(int which, uint32 speed, int interrupts) {
	/* P0/64 scalar, maybe interrupts */
	if (interrupts)
		TIMER16(tcrs[which]) = 32 | 2;
	else
		TIMER16(tcrs[which]) = 2;
		
	/* Initialize counters; formula is P0/(tps*64) */
	TIMER32(tcnts[which]) = 50000000 / (speed*64);
	TIMER32(tcors[which]) = 50000000 / (speed*64);
	
	return 0;
}
Example #4
0
void tmr_poll_start(u16 val)
{
	/* make sure the timer is stopped */
	BIT_CLR(TIMER32(TMRCONTROL), RUN);

	/* zero out the timer */
	TIMER32(TMRCOUNT) = 0;

	/* run the timer */
	BIT_SET(TIMER32(TMRCONTROL), RUN);
	
	value = val;
}
Example #5
0
/* Pre-initialize a timer as do it the BIOS; set values but don't start it */
int timer_prime_bios(int which) {

	/* Stop timer */
	TIMER8(TSTR) &= ~(1 << which);
	
	TIMER16(tcrs[which]) = 2;
	TIMER32(tcnts[which]) = 0xFFFFFFFF;
	TIMER32(tcors[which]) = 0xFFFFFFFF;
	
	/* Clears the timer underflow bit */
	TIMER16(tcrs[which]) &= ~0x100;
	
	return 0;
}
Example #6
0
void timer_init(void)
{
	// commented out due to bug!?
	/* make sure the timer is stopped */
	//BIT_CLR(TIMER32(TMRCONTROL), RUN);
	
	/* set up the clock */
	//TIMER32(TMRCONTROL) &= ~(3<<SETCLK);
	//TIMER32(TMRCONTROL) |= (TIMER_CLK<<SETCLK);
	
	
	TIMER32(TMRCLKGEN) = (TIMER_PRES<<TCLKDIV)|(TIMER_CLK_SRC<<TCLKSRCSEL);
	BIT_SET(TIMER32(TMRCLKENB), TCLKGENENB);
}
Example #7
0
u8 tmr_poll_has_expired(void)
{
   BIT_CLR(TIMER32(TMRCONTROL), RUN);
   BIT_SET(TIMER32(TMRCONTROL), LDCNT);
   u32 timer = TIMER32(TMRCOUNT);
   //db_puts("TIMER:");db_int (timer);db_puts(" ");
   //db_puts("VALUE:");db_int (value * 8197);db_puts("\n");
   BIT_SET(TIMER32(TMRCONTROL), RUN);
   
	if (timer >= (value * 8197))
		return 1;
		
	else
		return 0;
		
}
Example #8
0
/* Pre-initialize a timer for CDDA; set values but don't start it */
int timer_prime_cdda(int which, uint32 count) {

	/* Stop timer */
	TIMER8(TSTR) &= ~(1 << which);
	
	/* External clock */
	TIMER16(tcrs[which]) = 3;
		
	/* Initialize counters */
	TIMER32(tcnts[which]) = count;
	TIMER32(tcors[which]) = count;
	
	/* Clears the timer underflow bit */
	TIMER16(tcrs[which]) &= ~0x100;
	
	return 0;
}
Example #9
0
/* Returns the count value of a timer */
uint32 timer_count(int which) {
    return TIMER32(tcnts[which]);
}