KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Direct-Access

Low-level timer driver. More...

Functions

int timer_prime (int channel, uint32_t speed, int interrupts)
 Pre-initialize a timer channel, but do not start it.
 
int timer_start (int channel)
 Start a timer channel.
 
int timer_stop (int channel)
 Stop a timer channel.
 
int timer_running (int channel)
 Checks whether a timer channel is running.
 
uint32_t timer_count (int channel)
 Obtain the count of a timer channel.
 
int timer_clear (int channel)
 Clear the underflow bit of a timer channel.
 
void timer_enable_ints (int channel)
 Enable high-priority timer interrupts.
 
void timer_disable_ints (int channel)
 Disable timer interrupts.
 
int timer_ints_enabled (int channel)
 Check whether interrupts are enabled on a timer channel.
 

Detailed Description

Low-level timer driver.

This API provides a low-level driver abstraction around the TMU peripheral and the control, counter, and reload registers of its 3 channels.

Note
You typically want to use the higher-level APIs associated with the functionality implemented by each timer channel.

Function Documentation

◆ timer_clear()

int timer_clear ( int  channel)

Clear the underflow bit of a timer channel.

This function clears the underflow bit of a timer channel if it was set.

Parameters
channelThe timer channel to clear (Channels).
Return values
0If the underflow bit was clear (prior to calling).
1If the underflow bit was set (prior to calling).

◆ timer_count()

uint32_t timer_count ( int  channel)

Obtain the count of a timer channel.

This function simply returns the count of the timer channel.

Parameters
channelThe timer channel to inspect (Channels).
Returns
The timer's count.

◆ timer_disable_ints()

void timer_disable_ints ( int  channel)

Disable timer interrupts.

This function disables interrupts on the specified timer channel.

Parameters
channelThe timer channel to disable interrupts on (Channels).

◆ timer_enable_ints()

void timer_enable_ints ( int  channel)

Enable high-priority timer interrupts.

This function enables interrupts on the specified timer.

Parameters
channelThe timer channel to enable interrupts on (Channels).

◆ timer_ints_enabled()

int timer_ints_enabled ( int  channel)

Check whether interrupts are enabled on a timer channel.

This function checks whether or not interrupts are enabled on the specified timer channel.

Parameters
channelThe timer channel to inspect (Channels).
Return values
0If interrupts are disabled on the timer.
1If interrupts are enabled on the timer.

◆ timer_prime()

int timer_prime ( int  channel,
uint32_t  speed,
int  interrupts 
)

Pre-initialize a timer channel, but do not start it.

This function sets up a timer channel for use, but does not start it.

Parameters
channelThe timer channel to set up (Channels).
speedThe number of ticks per second.
interruptsSet to 1 to receive interrupts when the timer ticks.
Return values
0On success.

◆ timer_running()

int timer_running ( int  channel)

Checks whether a timer channel is running.

This function checks whether the given timer channel is actively counting.

Parameters
channelThe timer channel to check (Channels).
Return values
0The timer channel is stopped.
1The timer channel is running.

◆ timer_start()

int timer_start ( int  channel)

Start a timer channel.

This function starts a timer channel that has been initialized with timer_prime(), starting raising interrupts if applicable.

Parameters
channelThe timer channel to start (Channels).
Return values
0On success.

◆ timer_stop()

int timer_stop ( int  channel)

Stop a timer channel.

This function stops a timer channel that was started with timer_start(), and as a result stops interrupts coming in from the timer.

Parameters
channelThe timer channel to stop (Channels).
Return values
0On success.