2 Copyright © 2013, The AROS Development Team. All rights reserved.
7 #include <aros/debug.h>
9 #include <exec/types.h>
10 #include <devices/timer.h>
12 #include <proto/exec.h>
13 #include <aros/debug.h>
14 #include <proto/timer.h>
17 #include "sdcard_base.h"
19 #include LC_LIBDEFS_FILE
21 struct IORequest
*sdcard_OpenTimer(LIBBASETYPEPTR LIBBASE
)
23 struct MsgPort
*p
= CreateMsgPort();
26 struct IORequest
*io
= CreateIORequest(p
, sizeof(struct timerequest
));
31 * ok. ECLOCK does not have too great resolution, either.
32 * we will have to sacrifice our performance a little bit, meaning, the 400ns will turn into (worst case) 2us.
33 * hopefully we won't have to call that TOO often...
35 if (0 == OpenDevice("timer.device", UNIT_MICROHZ
, io
, 0))
37 if (NULL
== LIBBASE
->sdcard_TimerBase
)
39 LIBBASE
->sdcard_TimerBase
= io
->io_Device
;
45 bug("[SDCard ] Failed to open timer.device, unit MICROHZ\n");
51 bug("[SDCard ] Failed to create timerequest\n");
57 bug("[SDCard ] Failed to create timer port\n");
63 void sdcard_CloseTimer(struct IORequest
*tmr
)
67 struct MsgPort
*p
= tmr
->io_Message
.mn_ReplyPort
;
74 ULONG
sdcard_WaitTO(struct IORequest
* tmr
, ULONG secs
, ULONG micro
, ULONG sigs
)
76 ULONG sig
= 1 << tmr
->io_Message
.mn_ReplyPort
->mp_SigBit
;
78 tmr
->io_Command
= TR_ADDREQUEST
;
79 ((struct timerequest
*)tmr
)->tr_time
.tv_secs
= secs
;
80 ((struct timerequest
*)tmr
)->tr_time
.tv_micro
= micro
;
83 sigs
= Wait(sigs
| sig
);
84 if (0 == (sigs
& sig
))