next up previous contents
Next: Maple Access (maple.c) Up: Hardware Abstraction Layer: DC Previous: CD-Rom Access (cdfs.c)   Contents

Subsections

Timer Counters (timer.c)

This module supports the SH-4's internal timer perhipherals. Support is provided for TMU0 through TMU2. WDT (watchdog) is defined but not supported yet. TMU0 through TMU2 may all be used independently and count at different rates.

The following defines and functions are available:

TMU0, TMU1, TMU2, WDT

These are constants used to identify which timer you wish to operate on.

int timer_prime(int which, uint32 speed)

Primes a timer, but does not start it. ``which'' is one of the timer constants, and ``speed'' is a times per second rate which the counter will bottom out. So if you set speed to ``1'', then the timer will hit bottom after one second, and start counting again. Returns 0 for success.

int timer_start(int which)

Starts the requested timer counting (after priming it).

int timer_stop(int which)

Stops the requested timer.

uint32 timer_count(int which)

Returns the current timer count. The only way you can really make use of this externally is to get the timer count after priming but before starting, and scale the real-time results.

int timer_clear(int which)

Clears the timer underflow bit and returns what its value was. Underflow is set when the timer counts down. So for example, you could start a timer on a 1HZ cycle and poll this function until it returns true. At that point you'd have waited for a second, and the timer is already counting down again.

void timer_sleep(int ms)

Uses TMU0 to sleep for the given number of milliseconds.

int timer_init()

Setup timers (enable and stop all).


next up previous contents
Next: Maple Access (maple.c) Up: Hardware Abstraction Layer: DC Previous: CD-Rom Access (cdfs.c)   Contents
Dan Potter 2002-07-29