diff options
Diffstat (limited to 'firmware/test/kernel/timer.c')
-rw-r--r-- | firmware/test/kernel/timer.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/firmware/test/kernel/timer.c b/firmware/test/kernel/timer.c new file mode 100644 index 0000000000..be253db2b5 --- /dev/null +++ b/firmware/test/kernel/timer.c | |||
@@ -0,0 +1,63 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "sh7034.h" | ||
20 | #include "system.h" | ||
21 | #include "debug.h" | ||
22 | |||
23 | void tick_start(unsigned int interval_in_ms) | ||
24 | { | ||
25 | unsigned int count; | ||
26 | |||
27 | count = FREQ / 1000 / 8 * interval_in_ms; | ||
28 | |||
29 | if(count > 0xffff) | ||
30 | { | ||
31 | debugf("Error! The tick interval is too long (%d ms)\n", | ||
32 | interval_in_ms); | ||
33 | return; | ||
34 | } | ||
35 | |||
36 | /* We are using timer 0 */ | ||
37 | |||
38 | TSTR &= ~0x01; /* Stop the timer */ | ||
39 | TSNC &= ~0x01; /* No synchronization */ | ||
40 | TMDR &= ~0x01; /* Operate normally */ | ||
41 | |||
42 | TCNT0 = 0; /* Start counting at 0 */ | ||
43 | GRA0 = 0xfff0; | ||
44 | TCR0 = 0x23; /* Clear at GRA match, sysclock/8 */ | ||
45 | |||
46 | TSTR |= 0x01; /* Start timer 1 */ | ||
47 | |||
48 | /* Enable interrupt on level 1 */ | ||
49 | IPRC = (IPRC & ~0x00f0) | 0x0010; | ||
50 | |||
51 | TIER0 |= 0x01; /* Enable GRA match interrupt */ | ||
52 | |||
53 | while(1) | ||
54 | { | ||
55 | } | ||
56 | } | ||
57 | |||
58 | #pragma interrupt | ||
59 | void IMIA0(void) | ||
60 | { | ||
61 | TSR0 &= ~0x01; | ||
62 | debugf("Yes\n"); | ||
63 | } | ||