18#include <timer_alarm.h>
19#include <delaythread.h>
22static u64 DelayThreadWakeup_callback(s32 alarm_id, u64 scheduled_time, u64 actual_time,
void *arg,
void *pc_value)
29 iSignalSema((s32)arg);
34s32 DelayThread(s32 microseconds)
41 __asm__ __volatile__ (
"mfc0\t%0, $12" :
"=r" (eie));
42 if ((eie & 0x10000) == 0)
47 sema.option = (u32)
"DelayThread";
49 sema_id = CreateSema(&sema);
54 timer_alarm_id = SetTimerAlarm(TimerUSec2BusClock(0, microseconds), DelayThreadWakeup_callback, (
void *)sema_id);
55 if (timer_alarm_id < 0)
58 return timer_alarm_id;