From 99406a6635f91f5fc716cd0ca28e8364f7a97061 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Wed, 24 Apr 2002 22:46:02 +0000 Subject: Tick timer additions git-svn-id: svn://svn.rockbox.org/rockbox/trunk@219 a1c6a512-1295-4272-9138-f99709370657 --- firmware/test/kernel/Makefile | 4 +-- firmware/test/kernel/main.c | 4 +++ firmware/test/kernel/timer.c | 63 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 firmware/test/kernel/timer.c 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 CFLAGS = -g -O -Wall -m1 -save-temps -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns -fno-builtin $(INCLUDES) $(TARGET) AFLAGS += -small -relax -OBJS= ../../crt0.o ../../drivers/lcd.o ../../system.o main.o ../../thread.o ../../debug.o +OBJS= ../../crt0.o ../../system.o main.o timer.o ../../thread.o ../../debug.o %.o: %.S $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $< @@ -41,7 +41,7 @@ dist: tar czvf dist.tar.gz Makefile main.c start.s app.lds clean: - -rm -f $(OBJS) *.x *.i *.o *.elf *.bin *.map *.mod *.bak *~ + -rm -f $(OBJS) *.s *.x *.i *.o *.elf *.bin *.map *.mod *.bak *~ install: 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 @@ #include "sh7034.h" #include "debug.h" +void tick_start(unsigned int interval); + unsigned int s1[256]; unsigned int s2[256]; @@ -43,6 +45,8 @@ int main(void) debugf("OK. Let's go\n"); + tick_start(40); + create_thread(t1, s1, 1024); create_thread(t2, s2, 1024); 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Linus Nielsen Feltzing + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "sh7034.h" +#include "system.h" +#include "debug.h" + +void tick_start(unsigned int interval_in_ms) +{ + unsigned int count; + + count = FREQ / 1000 / 8 * interval_in_ms; + + if(count > 0xffff) + { + debugf("Error! The tick interval is too long (%d ms)\n", + interval_in_ms); + return; + } + + /* We are using timer 0 */ + + TSTR &= ~0x01; /* Stop the timer */ + TSNC &= ~0x01; /* No synchronization */ + TMDR &= ~0x01; /* Operate normally */ + + TCNT0 = 0; /* Start counting at 0 */ + GRA0 = 0xfff0; + TCR0 = 0x23; /* Clear at GRA match, sysclock/8 */ + + TSTR |= 0x01; /* Start timer 1 */ + + /* Enable interrupt on level 1 */ + IPRC = (IPRC & ~0x00f0) | 0x0010; + + TIER0 |= 0x01; /* Enable GRA match interrupt */ + + while(1) + { + } +} + +#pragma interrupt +void IMIA0(void) +{ + TSR0 &= ~0x01; + debugf("Yes\n"); +} -- cgit v1.2.3