KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
timer.h File Reference

Low-level timer functionality. More...

#include <stdint.h>
#include <sys/cdefs.h>
#include <arch/irq.h>

Go to the source code of this file.

Macros

#define TMU0   0
 SH4 Timer Channel 0.
 
#define TMU1   1
 SH4 Timer Channel 1.
 
#define TMU2   2
 SH4 Timer Channel 2.
 

Typedefs

typedef void(* timer_primary_callback_t) (irq_context_t *)
 Primary timer callback type.
 

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.
 
void timer_ms_enable (void)
 Enable the millisecond timer.
 
void timer_ms_disable (void)
 Disable the millisecond timer.
 
void timer_ms_gettime (uint32_t *secs, uint32_t *msecs)
 Get the current uptime of the system (in secs and millisecs).
 
uint64_t timer_ms_gettime64 (void)
 Get the current uptime of the system (in milliseconds).
 
void timer_us_gettime (uint32_t *secs, uint32_t *usecs)
 Get the current uptime of the system (in secs and microsecs).
 
uint64_t timer_us_gettime64 (void)
 Get the current uptime of the system (in microseconds).
 
void timer_ns_gettime (uint32_t *secs, uint32_t *nsecs)
 Get the current uptime of the system (in secs and nanosecs).
 
uint64_t timer_ns_gettime64 (void)
 Get the current uptime of the system (in nanoseconds).
 
void timer_spin_sleep (int ms)
 Spin-loop sleep function.
 
void timer_spin_delay_us (unsigned short us)
 Spin-loop delay function with microsecond granularity.
 
void timer_spin_delay_ns (unsigned short ns)
 Spin-loop delay function with nanosecond granularity.
 
timer_primary_callback_t timer_primary_set_callback (timer_primary_callback_t callback)
 Set the primary timer callback.
 
void timer_primary_wakeup (uint32_t millis)
 Request a primary timer wakeup.
 

Detailed Description

Low-level timer functionality.

This file contains functions for interacting with the timer sources on the SH4. Many of these functions may interfere with thread operation or other such things, and should thus be used with caution. Basically, the only functionality that you might use in practice in here in normal programs is the gettime functions.

See also
arch/rtc.h
arch/wdt.h
Author
Megan Potter
Falco Girgis