2 Copyright © 2017, The AROS Development Team. All rights reserved.
6 #include <aros/libcall.h>
8 #include <proto/lowlevel.h>
11 #include <exec/types.h>
12 #include <libraries/lowlevel.h>
13 #include <hardware/cia.h>
14 #include <resources/cia.h>
16 #include "lowlevel_intern.h"
17 #include "cia_intern.h"
18 #include "cia_timer.h"
20 AROS_LH3(VOID
, StartTimerInt
,
21 AROS_LHA(APTR
, intHandle
, A1
),
22 AROS_LHA(ULONG
, timeInterval
, D0
),
23 AROS_LHA(BOOL
, continuous
, D1
),
24 struct LowLevelBase
*, LowLevelBase
, 16, LowLevel
)
28 struct CIABase
*CiaBase
= (struct CIABase
*)LowLevelBase
->ll_CIA
.llciat_Base
;
29 UBYTE
volatile *ciacr_ptr
;
33 if (intHandle
&& (timeInterval
> 0))
35 /* Stop the timer if it is currently running */
36 StopTimerInt(intHandle
);
38 /* convert to EClock's */
39 ecv
= ((long long)timeInterval
* LowLevelBase
->ll_EClockMult
) >> 15;
40 if ((ecv
& 0xFFFF) == 0)
44 * Set the requested interval, and Choose appropriate flags
45 * for the used CIA timer...
47 if (LowLevelBase
->ll_CIA
.llciat_iCRBit
== CIAICRB_TA
)
49 CiaBase
->hw
->ciatalo
= (ecv
& 0xFF);
50 CiaBase
->hw
->ciatahi
= ((ecv
>> 8) & 0xFF);
52 ciacr_ptr
= &CiaBase
->hw
->ciacra
;
55 crflags
|= CIACRAF_RUNMODE
;
59 CiaBase
->hw
->ciatblo
= (ecv
& 0xFF);
60 CiaBase
->hw
->ciatbhi
= ((ecv
>> 8) & 0xFF);
62 ciacr_ptr
= &CiaBase
->hw
->ciacrb
;
65 crflags
|= CIACRBF_RUNMODE
;
68 /* .. and start up the timer */
69 *ciacr_ptr
|= crflags
;