2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: TimeDelay() - wait a specified time.
10 #include <exec/types.h>
11 #include <aros/asmcall.h>
12 #include <devices/timer.h>
13 #include <exec/tasks.h>
14 #include <proto/exec.h>
16 /*****************************************************************************
19 AROS_UFH3(ULONG
, TimeDelay
,
22 AROS_UFHA(LONG
, Unit
, D0
),
23 AROS_UFHA(ULONG
, Seconds
, D1
),
24 AROS_UFHA(ULONG
, MicroSeconds
, D2
))
27 TimeDelay() waits for the specified period of time before returning
31 Unit - The timer.device unit to use for this command.
32 Seconds - The number of seconds to wait.
33 MicroSeconds - The number of microseconds to wait.
36 Zero if everything went ok, non-zero if there was a problem.
39 If this function fails, the most likely reasons are:
40 - invalid timer.device unit numbers
42 This function uses the SIGF_SINGLE signal, strange things can
43 happen if you are waiting on this signal when you call this
44 function. Basically: Don't use it and call this function.
51 timer.device/TR_ADDREQUEST
57 ******************************************************************************/
61 struct timerequest tr
;
65 /* Create a message port */
66 mp
.mp_Node
.ln_Type
= NT_MSGPORT
;
67 mp
.mp_Node
.ln_Pri
= 0;
68 mp
.mp_Node
.ln_Name
= NULL
;
69 mp
.mp_Flags
= PA_SIGNAL
;
70 mp
.mp_SigTask
= FindTask(NULL
);
71 mp
.mp_SigBit
= SIGB_SINGLE
;
72 NEWLIST(&mp
.mp_MsgList
);
74 tr
.tr_node
.io_Message
.mn_Node
.ln_Type
= NT_MESSAGE
;
75 tr
.tr_node
.io_Message
.mn_Node
.ln_Pri
= 0;
76 tr
.tr_node
.io_Message
.mn_Node
.ln_Name
= NULL
;
77 tr
.tr_node
.io_Message
.mn_ReplyPort
= &mp
;
78 tr
.tr_node
.io_Message
.mn_Length
= sizeof(struct timerequest
);
80 SetSignal(0, SIGF_SINGLE
);
82 if(OpenDevice("timer.device", Unit
, (struct IORequest
*)&tr
, 0) == 0)
84 tr
.tr_node
.io_Command
= TR_ADDREQUEST
;
85 tr
.tr_node
.io_Flags
= 0;
86 tr
.tr_time
.tv_secs
= Seconds
;
87 tr
.tr_time
.tv_micro
= MicroSeconds
;
89 DoIO((struct IORequest
*)&tr
);
91 CloseDevice((struct IORequest
*)&tr
);