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

Maintaining time since system boot. More...

Functions

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).
 

Detailed Description

Maintaining time since system boot.

This API provides methods for querying the current system boot time or uptime since KOS started at various resolutions. You can use this timing for ticks, delta time, or frame deltas for games, profilers, or media decoding.

Note
This API is used to back the C, C++, and POSIX standard date/time APIs. You may wish to favor these for platform independence.
Warning
This API and its underlying functionality are using TMU2, so any direct manipulation of it will interfere with the API's proper functioning.
Note
The highest actual tick resolution of TMU2 is 80ns.

Function Documentation

◆ timer_ms_disable()

void timer_ms_disable ( void )

Disable the millisecond timer.

This function disables the timer used for the gettime functions. Generally, you will not want to do this, unless you have some need to use the timer TMU2 for something else.

◆ timer_ms_enable()

void timer_ms_enable ( void )

Enable the millisecond timer.

This function enables the timer used for the gettime functions. This is on by default. These functions use TMU2 to do their work.

◆ timer_ms_gettime()

void timer_ms_gettime ( uint32_t * secs,
uint32_t * msecs )

Get the current uptime of the system (in secs and millisecs).

This function retrieves the number of seconds and milliseconds since KOS was started.

Parameters
secsA pointer to store the number of seconds since boot into.
msecsA pointer to store the number of milliseconds past a second since boot.
Note
To get the total number of milliseconds since boot, calculate (*secs * 1000) + *msecs, or use the timer_ms_gettime64() function.

◆ timer_ms_gettime64()

uint64_t timer_ms_gettime64 ( void )

Get the current uptime of the system (in milliseconds).

This function retrieves the number of milliseconds since KOS was started. It is equivalent to calling timer_ms_gettime() and combining the number of seconds and milliseconds into one 64-bit value.

Returns
The number of milliseconds since KOS started.

◆ timer_ns_gettime()

void timer_ns_gettime ( uint32_t * secs,
uint32_t * nsecs )

Get the current uptime of the system (in secs and nanosecs).

This function retrieves the number of seconds and nanoseconds since KOS was started.

Note
To get the total number of nanoseconds since boot, calculate (*secs * 1000000000) + *nsecs, or use the timer_ns_gettime64() function.
Parameters
secsA pointer to store the number of seconds since boot into.
nsecsA pointer to store the number of nanoseconds past a second since boot.

◆ timer_ns_gettime64()

uint64_t timer_ns_gettime64 ( void )

Get the current uptime of the system (in nanoseconds).

This function retrieves the number of nanoseconds since KOS was started.

Returns
The number of nanoseconds since KOS started.

◆ timer_us_gettime()

void timer_us_gettime ( uint32_t * secs,
uint32_t * usecs )

Get the current uptime of the system (in secs and microsecs).

This function retrieves the number of seconds and microseconds since KOS was started.

Note
To get the total number of microseconds since boot, calculate (*secs * 1000000) + *usecs, or use the timer_us_gettime64() function.
Parameters
secsA pointer to store the number of seconds since boot into.
usecsA pointer to store the number of microseconds past a second since boot.

◆ timer_us_gettime64()

uint64_t timer_us_gettime64 ( void )

Get the current uptime of the system (in microseconds).

This function retrieves the number of microseconds since KOS was started.

Returns
The number of microseconds since KOS started.