2 * Amiga Generic Set - set of libraries and includes to ease sw development for all Amiga platforms
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <libclass/exec.h>
22 #include <devices/timer.h>
23 #include <exec/ports.h>
24 #include "LibrarySpool.h"
26 using namespace GenNS
;
31 port
= Exec
->CreateMsgPort();
32 treq
= (timerequest
*)Exec
->CreateIORequest(port
, sizeof(timerequest
));
33 Exec
->OpenDevice("timer.device", UNIT_VBLANK
, (IORequest
*)treq
, 0);
40 Exec
->CloseDevice((IORequest
*)treq
);
41 Exec
->DeleteIORequest((IORequest
*)treq
);
42 Exec
->DeleteMsgPort(port
);
45 void Timer::WaitRequest()
51 treq
= (timerequest
*)Exec
->GetMsg(port
);
56 void Timer::AbortRequest()
60 Exec
->AbortIO((IORequest
*)treq
);
65 void Timer::AddRequest(unsigned long duration
) // milliseconds ?
68 * don't initiate another request unless this one is finished.
72 struct timerequest
*tr
= (struct timerequest
*)Exec
->GetMsg(port
);
79 treq
->tr_node
.io_Command
= TR_ADDREQUEST
;
80 treq
->tr_time
.tv_secs
= (duration
/1000);
81 treq
->tr_time
.tv_micro
= (duration
% 1000) * 1000;
82 Exec
->SendIO((IORequest
*)treq
);
86 unsigned long Timer::GetSignals(void)
88 return 1<<port
->mp_SigBit
;