summaryrefslogtreecommitdiff
path: root/firmware/target/arm/timer-pp.c
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2009-06-29 14:29:35 +0000
committerRafaël Carré <rafael.carre@gmail.com>2009-06-29 14:29:35 +0000
commitb955dff268005d3d55ee3f38af0875718ab6021a (patch)
tree7c8c1eb5ec2ab0d0a7d874e10092cab8ba1d5985 /firmware/target/arm/timer-pp.c
parentb3ed33d04aec20568b8bb9616349e6d7e4c71882 (diff)
downloadrockbox-b955dff268005d3d55ee3f38af0875718ab6021a.tar.gz
rockbox-b955dff268005d3d55ee3f38af0875718ab6021a.zip
Move PP (last target) timer code in target tree
Put warnings in timer.h for incomplete targets (TIMER_FREQ not defined and/or timer-target.h inexistant) Correct TIMER_STOP & TIMER_START macros arguments for target without timers TIMER_START takes an extra argument in multicore builds (macro in macro doesn't work fine..) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21557 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/timer-pp.c')
-rw-r--r--firmware/target/arm/timer-pp.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/firmware/target/arm/timer-pp.c b/firmware/target/arm/timer-pp.c
new file mode 100644
index 0000000000..01c691f79e
--- /dev/null
+++ b/firmware/target/arm/timer-pp.c
@@ -0,0 +1,87 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2006 Thom Johansen
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 "cpu.h"
23#include "system.h"
24#include "timer.h"
25#include "timer-target.h"
26
27static long SHAREDBSS_ATTR cycles_new = 0;
28
29void TIMER2(void)
30{
31 TIMER2_VAL; /* ACK interrupt */
32 if (cycles_new > 0)
33 {
34 TIMER2_CFG = 0xc0000000 | (cycles_new - 1);
35 cycles_new = 0;
36 }
37 if (pfn_timer != NULL)
38 {
39 cycles_new = -1;
40 /* "lock" the variable, in case timer_set_period()
41 * is called within pfn_timer() */
42 pfn_timer();
43 cycles_new = 0;
44 }
45}
46
47bool __timer_set(long cycles, bool start)
48{
49 if (cycles > 0x20000000 || cycles < 2)
50 return false;
51
52 if (start)
53 {
54 if (pfn_unregister != NULL)
55 {
56 pfn_unregister();
57 pfn_unregister = NULL;
58 }
59 CPU_INT_DIS = TIMER2_MASK;
60 COP_INT_DIS = TIMER2_MASK;
61 }
62 if (start || (cycles_new == -1)) /* within isr, cycles_new is "locked" */
63 TIMER2_CFG = 0xc0000000 | (cycles - 1); /* enable timer */
64 else
65 cycles_new = cycles;
66
67 return true;
68}
69
70bool __timer_start(IF_COP_VOID(int core))
71{
72 /* unmask interrupt source */
73#if NUM_CORES > 1
74 if (core == COP)
75 COP_INT_EN = TIMER2_MASK;
76 else
77#endif
78 CPU_INT_EN = TIMER2_MASK;
79 return true;
80}
81
82void __timer_stop(void)
83{
84 TIMER2_CFG = 0; /* stop timer 2 */
85 CPU_INT_DIS = TIMER2_MASK;
86 COP_INT_DIS = TIMER2_MASK;
87}