1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 Rafaël Carré
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
28 if (pfn_timer
!= NULL
)
31 TIMER1_INTCLR
= 0; /* clear interrupt */
34 bool timer_set(long cycles
, bool start
)
38 if (pfn_unregister
!= NULL
)
41 pfn_unregister
= NULL
;
45 TIMER1_LOAD
= TIMER1_BGLOAD
= cycles
;
46 /* /!\ bit 4 (reserved) must not be modified
47 * periodic mode, interrupt enabled, no prescale, 32 bits counter */
48 TIMER1_CONTROL
= (TIMER1_CONTROL
& (1<<4)) |
56 bool timer_start(void)
58 CGU_PERI
|= CGU_TIMER1_CLOCK_ENABLE
; /* enable peripheral */
59 VIC_INT_ENABLE
= INTERRUPT_TIMER1
;
65 TIMER1_CONTROL
&= 0x10; /* disable timer 1 (don't modify bit 4) */
66 VIC_INT_EN_CLEAR
= INTERRUPT_TIMER1
; /* disable interrupt */
67 CGU_PERI
&= ~CGU_TIMER1_CLOCK_ENABLE
; /* disable peripheral */