summaryrefslogtreecommitdiff
path: root/firmware/target/arm/pnx0101/timer-pnx0101.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/pnx0101/timer-pnx0101.c')
-rw-r--r--firmware/target/arm/pnx0101/timer-pnx0101.c81
1 files changed, 0 insertions, 81 deletions
diff --git a/firmware/target/arm/pnx0101/timer-pnx0101.c b/firmware/target/arm/pnx0101/timer-pnx0101.c
deleted file mode 100644
index 1ec1d2871f..0000000000
--- a/firmware/target/arm/pnx0101/timer-pnx0101.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2007 Tomasz Malesinski
11*
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.
16*
17* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18* KIND, either express or implied.
19*
20****************************************************************************/
21
22#include "system.h"
23#include "timer.h"
24
25static long cycles_new = 0;
26
27void TIMER1_ISR(void)
28{
29 if (cycles_new > 0)
30 {
31 TIMER1.load = cycles_new - 1;
32 cycles_new = 0;
33 }
34 if (pfn_timer != NULL)
35 {
36 cycles_new = -1;
37 /* "lock" the variable, in case timer_set_period()
38 * is called within pfn_timer() */
39 pfn_timer();
40 cycles_new = 0;
41 }
42 TIMER1.clr = 1; /* clear the interrupt */
43}
44
45bool timer_set(long cycles, bool start)
46{
47 if (start)
48 {
49 if (pfn_unregister != NULL)
50 {
51 pfn_unregister();
52 pfn_unregister = NULL;
53 }
54 TIMER1.ctrl &= ~0x80; /* disable the counter */
55 TIMER1.ctrl |= 0x40; /* reload after counting down to zero */
56 TIMER1.ctrl &= ~0xc; /* no prescaler */
57 TIMER1.clr = 1; /* clear an interrupt event */
58 }
59 if (start || (cycles_new == -1)) /* within isr, cycles_new is "locked" */
60 { /* enable timer */
61 TIMER1.load = cycles - 1;
62 TIMER1.ctrl |= 0x80; /* enable the counter */
63 }
64 else
65 cycles_new = cycles;
66
67 return true;
68}
69
70bool timer_start(void)
71{
72 irq_set_int_handler(IRQ_TIMER1, TIMER1_ISR);
73 irq_enable_int(IRQ_TIMER1);
74 return true;
75}
76
77void timer_stop(void)
78{
79 TIMER1.ctrl &= ~0x80; /* disable timer 1 */
80 irq_disable_int(IRQ_TIMER1);
81}