wip update - use the fetched mesa gallium paths and files.
[AROS.git] / arch / m68k-amiga / lowlevel / starttimerint.c
bloba6497de35effe5dc024cd1d7c0daeb466b8aefc1
1 /*
2 Copyright © 2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/libcall.h>
8 #include <proto/lowlevel.h>
9 #include <proto/cia.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)
26 AROS_LIBFUNC_INIT
28 struct CIABase *CiaBase = (struct CIABase *)LowLevelBase->ll_CIA.llciat_Base;
29 UBYTE volatile *ciacr_ptr;
30 UBYTE crflags;
31 long long ecv;
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)
41 ecv = 1;
43 /*
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;
53 crflags = CIASTART_A;
54 if (!continuous)
55 crflags |= CIACRAF_RUNMODE;
57 else
59 CiaBase->hw->ciatblo = (ecv & 0xFF);
60 CiaBase->hw->ciatbhi = ((ecv >> 8) & 0xFF);
62 ciacr_ptr = &CiaBase->hw->ciacrb;
63 crflags = CIASTART_B;
64 if (!continuous)
65 crflags |= CIACRBF_RUNMODE;
68 /* .. and start up the timer */
69 *ciacr_ptr |= crflags;
72 return;
74 AROS_LIBFUNC_EXIT