Added battery profile change to correct file, removed unused powermgmt-as3525.c
[kugel-rb.git] / firmware / target / arm / as3525 / timer-as3525.c
blobf5ff60e0f83e181fd0b14360f85044f313c264ab
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
22 #include "as3525.h"
23 #include "timer.h"
24 #include "stdlib.h"
26 void INT_TIMER1(void)
28 if (pfn_timer != NULL)
29 pfn_timer();
31 TIMER1_INTCLR = 0; /* clear interrupt */
34 bool timer_set(long cycles, bool start)
36 if (start)
38 if (pfn_unregister != NULL)
40 pfn_unregister();
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)) |
49 TIMER_ENABLE |
50 TIMER_PERIODIC |
51 TIMER_INT_ENABLE |
52 TIMER_32_BIT;
53 return true;
56 bool timer_start(void)
58 CGU_PERI |= CGU_TIMER1_CLOCK_ENABLE; /* enable peripheral */
59 VIC_INT_ENABLE = INTERRUPT_TIMER1;
60 return true;
63 void timer_stop(void)
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 */