diff options
Diffstat (limited to 'firmware/test/kernel')
-rw-r--r-- | firmware/test/kernel/Makefile | 4 | ||||
-rw-r--r-- | firmware/test/kernel/main.c | 4 | ||||
-rw-r--r-- | firmware/test/kernel/timer.c | 63 |
3 files changed, 69 insertions, 2 deletions
diff --git a/firmware/test/kernel/Makefile b/firmware/test/kernel/Makefile index cec39b1d49..f632b3f6de 100644 --- a/firmware/test/kernel/Makefile +++ b/firmware/test/kernel/Makefile | |||
@@ -14,7 +14,7 @@ TARGET = -DARCHOS_PLAYER_OLD=1 | |||
14 | CFLAGS = -g -O -Wall -m1 -save-temps -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns -fno-builtin $(INCLUDES) $(TARGET) | 14 | CFLAGS = -g -O -Wall -m1 -save-temps -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns -fno-builtin $(INCLUDES) $(TARGET) |
15 | AFLAGS += -small -relax | 15 | AFLAGS += -small -relax |
16 | 16 | ||
17 | OBJS= ../../crt0.o ../../drivers/lcd.o ../../system.o main.o ../../thread.o ../../debug.o | 17 | OBJS= ../../crt0.o ../../system.o main.o timer.o ../../thread.o ../../debug.o |
18 | 18 | ||
19 | %.o: %.S | 19 | %.o: %.S |
20 | $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $< | 20 | $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $< |
@@ -41,7 +41,7 @@ dist: | |||
41 | tar czvf dist.tar.gz Makefile main.c start.s app.lds | 41 | tar czvf dist.tar.gz Makefile main.c start.s app.lds |
42 | 42 | ||
43 | clean: | 43 | clean: |
44 | -rm -f $(OBJS) *.x *.i *.o *.elf *.bin *.map *.mod *.bak *~ | 44 | -rm -f $(OBJS) *.s *.x *.i *.o *.elf *.bin *.map *.mod *.bak *~ |
45 | 45 | ||
46 | install: | 46 | install: |
47 | mount /mnt/archos; cp archos.mod /mnt/archos; umount /mnt/archos | 47 | mount /mnt/archos; cp archos.mod /mnt/archos; umount /mnt/archos |
diff --git a/firmware/test/kernel/main.c b/firmware/test/kernel/main.c index 5ac24a7971..6ce99c8065 100644 --- a/firmware/test/kernel/main.c +++ b/firmware/test/kernel/main.c | |||
@@ -20,6 +20,8 @@ | |||
20 | #include "sh7034.h" | 20 | #include "sh7034.h" |
21 | #include "debug.h" | 21 | #include "debug.h" |
22 | 22 | ||
23 | void tick_start(unsigned int interval); | ||
24 | |||
23 | unsigned int s1[256]; | 25 | unsigned int s1[256]; |
24 | unsigned int s2[256]; | 26 | unsigned int s2[256]; |
25 | 27 | ||
@@ -43,6 +45,8 @@ int main(void) | |||
43 | 45 | ||
44 | debugf("OK. Let's go\n"); | 46 | debugf("OK. Let's go\n"); |
45 | 47 | ||
48 | tick_start(40); | ||
49 | |||
46 | create_thread(t1, s1, 1024); | 50 | create_thread(t1, s1, 1024); |
47 | create_thread(t2, s2, 1024); | 51 | create_thread(t2, s2, 1024); |
48 | 52 | ||
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 | } | ||