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_intern.h"
19 struct IORequest
*sdcard_OpenTimer(struct SDCardBase
*SDCardBase
)
21 struct MsgPort
*p
= CreateMsgPort();
24 struct IORequest
*io
= CreateIORequest(p
, sizeof(struct timerequest
));
29 * ok. ECLOCK does not have too great resolution, either.
30 * we will have to sacrifice our performance a little bit, meaning, the 400ns will turn into (worst case) 2us.
31 * hopefully we won't have to call that TOO often...
33 if (0 == OpenDevice("timer.device", UNIT_MICROHZ
, io
, 0))
35 if (NULL
== SDCardBase
->sdcard_TimerBase
)
37 SDCardBase
->sdcard_TimerBase
= io
->io_Device
;
43 bug("[SDCard ] Failed to open timer.device, unit MICROHZ\n");
49 bug("[SDCard ] Failed to create timerequest\n");
55 bug("[SDCard ] Failed to create timer port\n");
61 void sdcard_CloseTimer(struct IORequest
*tmr
)
65 struct MsgPort
*p
= tmr
->io_Message
.mn_ReplyPort
;
72 void sdcard_WaitNano(register ULONG ns
, struct SDCardBase
*SDCardBase
)
74 volatile register ULONG t
= 1;
77 asm volatile("mov r0, r0\n");
82 ULONG
sdcard_WaitTO(struct IORequest
* tmr
, ULONG secs
, ULONG micro
, ULONG sigs
)
84 ULONG sig
= 1 << tmr
->io_Message
.mn_ReplyPort
->mp_SigBit
;
86 //D(bug("[SDCard--] Timed wait %lds %ldu\n", secs, micro));
88 tmr
->io_Command
= TR_ADDREQUEST
;
89 ((struct timerequest
*)tmr
)->tr_time
.tv_secs
= secs
;
90 ((struct timerequest
*)tmr
)->tr_time
.tv_micro
= micro
;
93 sigs
= Wait(sigs
| sig
);
94 if (0 == (sigs
& sig
))