sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
timer.h File Reference
#include <tamtypes.h>

Go to the source code of this file.

Macros

#define T0_COUNT   ((volatile unsigned int *)0x10000000)
#define T0_MODE   ((volatile unsigned int *)0x10000010)
#define T0_COMP   ((volatile unsigned int *)0x10000020)
#define T0_HOLD   ((volatile unsigned int *)0x10000030)
#define T1_COUNT   ((volatile unsigned int *)0x10000800)
#define T1_MODE   ((volatile unsigned int *)0x10000810)
#define T1_COMP   ((volatile unsigned int *)0x10000820)
#define T1_HOLD   ((volatile unsigned int *)0x10000830)
#define T2_COUNT   ((volatile unsigned int *)0x10001000)
#define T2_MODE   ((volatile unsigned int *)0x10001010)
#define T2_COMP   ((volatile unsigned int *)0x10001020)
#define T3_COUNT   ((volatile unsigned int *)0x10001800)
#define T3_MODE   ((volatile unsigned int *)0x10001810)
#define T3_COMP   ((volatile unsigned int *)0x10001820)
#define K_T2_COUNT   ((volatile unsigned int *)0xB0001000)
#define K_T2_MODE   ((volatile unsigned int *)0xB0001010)
#define K_T2_COMP   ((volatile unsigned int *)0xB0001020)
#define Tn_MODE(CLKS, GATE, GATS, GATM, ZRET, CUE, CMPE, OVFE, EQUF, OVFF)
#define kBUSCLK   (147456000)
#define kBUSCLKBY16   (kBUSCLK / 16)
#define kBUSCLKBY256   (kBUSCLK / 256)
#define kHBLNK_NTSC   (15734)
#define kHBLNK_PAL   (15625)
#define kHBLNK_DTV480p   (31469)
#define kHBLNK_DTV1080i   (33750)

Typedefs

typedef u64(*) timer_alarm_handler_t(s32 id, u64 scheduled_time, u64 actual_time, void *arg, void *pc_value)

Functions

void _ps2sdk_init_timer_impl (void)
void _ps2sdk_init_timer (void)
void _ps2sdk_deinit_timer_impl (void)
void _ps2sdk_deinit_timer (void)
s32 InitTimer (s32 in_mode)
s32 EndTimer (void)
s32 GetTimerPreScaleFactor (void)
s32 StartTimerSystemTime (void)
s32 StopTimerSystemTime (void)
void SetNextComp (u64 time)
u64 iGetTimerSystemTime (void)
u64 GetTimerSystemTime (void)
s32 iAllocTimerCounter (void)
s32 AllocTimerCounter (void)
s32 iFreeTimerCounter (s32 id)
s32 FreeTimerCounter (s32 id)
s32 iGetTimerUsedUnusedCounters (u32 *used_counters, u32 *unused_counters)
s32 GetTimerUsedUnusedCounters (u32 *used_counters, u32 *unused_counters)
s32 iStartTimerCounter (s32 id)
s32 StartTimerCounter (s32 id)
s32 iStopTimerCounter (s32 id)
s32 StopTimerCounter (s32 id)
u64 SetTimerCount (s32 id, u64 timer_count)
u64 iGetTimerBaseTime (s32 id)
u64 GetTimerBaseTime (s32 id)
u64 iGetTimerCount (s32 id)
u64 GetTimerCount (s32 id)
s32 iSetTimerHandler (s32 id, u64 scheduled_time, timer_alarm_handler_t callback_handler, void *arg)
s32 SetTimerHandler (s32 id, u64 scheduled_time, timer_alarm_handler_t callback_handler, void *arg)
void TimerBusClock2USec (u64 clocks, u32 *seconds_result, u32 *microseconds_result)
u64 TimerUSec2BusClock (u32 seconds, u32 microseconds)
float TimerBusClock2Freq (s64 clocks)
u64 TimerFreq2BusClock (float timer_frequency)
u32 cpu_ticks (void)

Detailed Description

Timer prototypes

Definition in file timer.h.

Macro Definition Documentation

◆ K_T2_COMP

#define K_T2_COMP   ((volatile unsigned int *)0xB0001020)

Definition at line 46 of file timer.h.

◆ K_T2_COUNT

#define K_T2_COUNT   ((volatile unsigned int *)0xB0001000)

Definition at line 44 of file timer.h.

◆ K_T2_MODE

#define K_T2_MODE   ((volatile unsigned int *)0xB0001010)

Definition at line 45 of file timer.h.

◆ kBUSCLK

#define kBUSCLK   (147456000)

Definition at line 56 of file timer.h.

◆ kBUSCLKBY16

#define kBUSCLKBY16   (kBUSCLK / 16)

Definition at line 57 of file timer.h.

◆ kBUSCLKBY256

#define kBUSCLKBY256   (kBUSCLK / 256)

Definition at line 58 of file timer.h.

◆ kHBLNK_DTV1080i

#define kHBLNK_DTV1080i   (33750)

Definition at line 62 of file timer.h.

◆ kHBLNK_DTV480p

#define kHBLNK_DTV480p   (31469)

Definition at line 61 of file timer.h.

◆ kHBLNK_NTSC

#define kHBLNK_NTSC   (15734)

Definition at line 59 of file timer.h.

◆ kHBLNK_PAL

#define kHBLNK_PAL   (15625)

Definition at line 60 of file timer.h.

◆ T0_COMP

#define T0_COMP   ((volatile unsigned int *)0x10000020)

Definition at line 25 of file timer.h.

◆ T0_COUNT

#define T0_COUNT   ((volatile unsigned int *)0x10000000)

Definition at line 23 of file timer.h.

◆ T0_HOLD

#define T0_HOLD   ((volatile unsigned int *)0x10000030)

Definition at line 26 of file timer.h.

◆ T0_MODE

#define T0_MODE   ((volatile unsigned int *)0x10000010)

Definition at line 24 of file timer.h.

◆ T1_COMP

#define T1_COMP   ((volatile unsigned int *)0x10000820)

Definition at line 30 of file timer.h.

◆ T1_COUNT

#define T1_COUNT   ((volatile unsigned int *)0x10000800)

Definition at line 28 of file timer.h.

◆ T1_HOLD

#define T1_HOLD   ((volatile unsigned int *)0x10000830)

Definition at line 31 of file timer.h.

◆ T1_MODE

#define T1_MODE   ((volatile unsigned int *)0x10000810)

Definition at line 29 of file timer.h.

◆ T2_COMP

#define T2_COMP   ((volatile unsigned int *)0x10001020)

Definition at line 37 of file timer.h.

◆ T2_COUNT

#define T2_COUNT   ((volatile unsigned int *)0x10001000)

Definition at line 35 of file timer.h.

◆ T2_MODE

#define T2_MODE   ((volatile unsigned int *)0x10001010)

Definition at line 36 of file timer.h.

◆ T3_COMP

#define T3_COMP   ((volatile unsigned int *)0x10001820)

Definition at line 41 of file timer.h.

◆ T3_COUNT

#define T3_COUNT   ((volatile unsigned int *)0x10001800)

Definition at line 39 of file timer.h.

◆ T3_MODE

#define T3_MODE   ((volatile unsigned int *)0x10001810)

Definition at line 40 of file timer.h.

◆ Tn_MODE

#define Tn_MODE ( CLKS,
GATE,
GATS,
GATM,
ZRET,
CUE,
CMPE,
OVFE,
EQUF,
OVFF )
Value:
(u32)((u32)(CLKS) | ((u32)(GATE) << 2) | \
((u32)(GATS) << 3) | ((u32)(GATM) << 4) | \
((u32)(ZRET) << 6) | ((u32)(CUE) << 7) | \
((u32)(CMPE) << 8) | ((u32)(OVFE) << 9) | \
((u32)(EQUF) << 10) | ((u32)(OVFF) << 11))

Definition at line 48 of file timer.h.

Typedef Documentation

◆ timer_alarm_handler_t

typedef u64(*) timer_alarm_handler_t(s32 id, u64 scheduled_time, u64 actual_time, void *arg, void *pc_value)

Definition at line 64 of file timer.h.

Function Documentation

◆ _ps2sdk_deinit_timer_impl()

void _ps2sdk_deinit_timer_impl ( void )
extern

Definition at line 472 of file timer.c.

◆ _ps2sdk_init_timer_impl()

void _ps2sdk_init_timer_impl ( void )
extern

Definition at line 466 of file timer.c.

◆ AllocTimerCounter()

s32 AllocTimerCounter ( void )
extern

Definition at line 520 of file timer.c.

◆ cpu_ticks()

u32 cpu_ticks ( void )
extern

Definition at line 869 of file timer.c.

◆ FreeTimerCounter()

s32 FreeTimerCounter ( s32 id)
extern

Definition at line 559 of file timer.c.

◆ GetTimerBaseTime()

u64 GetTimerBaseTime ( s32 id)
extern

Definition at line 742 of file timer.c.

◆ GetTimerCount()

u64 GetTimerCount ( s32 id)
extern

Definition at line 774 of file timer.c.

◆ GetTimerPreScaleFactor()

s32 GetTimerPreScaleFactor ( void )
extern

Definition at line 188 of file timer.c.

◆ GetTimerSystemTime()

u64 GetTimerSystemTime ( void )
extern

Get current System Time

This function gets the current system time Can be called from an interrupt handler Can be called from a thread Multithread safe

Returns
current system time in BUSCLK units, 0 in case the InitTimer wasn't called at init.

Definition at line 487 of file timer.c.

◆ GetTimerUsedUnusedCounters()

s32 GetTimerUsedUnusedCounters ( u32 * used_counters,
u32 * unused_counters )
extern

Definition at line 590 of file timer.c.

◆ iAllocTimerCounter()

s32 iAllocTimerCounter ( void )
extern

Definition at line 501 of file timer.c.

◆ iFreeTimerCounter()

s32 iFreeTimerCounter ( s32 id)
extern

Definition at line 534 of file timer.c.

◆ iGetTimerBaseTime()

u64 iGetTimerBaseTime ( s32 id)
extern

Definition at line 726 of file timer.c.

◆ iGetTimerCount()

u64 iGetTimerCount ( s32 id)
extern

Definition at line 756 of file timer.c.

◆ iGetTimerSystemTime()

u64 iGetTimerSystemTime ( void )
extern

Get current System Time

This function gets the current system time Can be called from an interrupt handler Cannot be called from a thread

Returns
current system time in BUSCLK units, 0 in case the InitTimer wasn't called at init.

Definition at line 448 of file timer.c.

◆ iGetTimerUsedUnusedCounters()

s32 iGetTimerUsedUnusedCounters ( u32 * used_counters,
u32 * unused_counters )
extern

Definition at line 573 of file timer.c.

◆ iSetTimerHandler()

s32 iSetTimerHandler ( s32 id,
u64 scheduled_time,
timer_alarm_handler_t callback_handler,
void * arg )
extern

Definition at line 788 of file timer.c.

◆ iStartTimerCounter()

s32 iStartTimerCounter ( s32 id)
extern

Definition at line 604 of file timer.c.

◆ iStopTimerCounter()

s32 iStopTimerCounter ( s32 id)
extern

Definition at line 647 of file timer.c.

◆ SetNextComp()

void SetNextComp ( u64 time)
extern

Definition at line 259 of file timer.c.

◆ SetTimerCount()

u64 SetTimerCount ( s32 id,
u64 timer_count )
extern

Definition at line 690 of file timer.c.

◆ SetTimerHandler()

s32 SetTimerHandler ( s32 id,
u64 scheduled_time,
timer_alarm_handler_t callback_handler,
void * arg )
extern

Definition at line 825 of file timer.c.

◆ StartTimerCounter()

s32 StartTimerCounter ( s32 id)
extern

Definition at line 633 of file timer.c.

◆ StopTimerCounter()

s32 StopTimerCounter ( s32 id)
extern

Definition at line 676 of file timer.c.

◆ TimerBusClock2Freq()

float TimerBusClock2Freq ( s64 clocks)
extern

Definition at line 859 of file timer.c.

◆ TimerBusClock2USec()

void TimerBusClock2USec ( u64 clocks,
u32 * seconds_result,
u32 * microseconds_result )
extern

Definition at line 839 of file timer.c.

◆ TimerFreq2BusClock()

u64 TimerFreq2BusClock ( float timer_frequency)
extern

Definition at line 864 of file timer.c.

◆ TimerUSec2BusClock()

u64 TimerUSec2BusClock ( u32 seconds,
u32 microseconds )
extern

Definition at line 854 of file timer.c.