fuzev2: prevent button light flickering when accessing µSD
[kugel-rb.git] / firmware / test / kernel / main.c
blob6a20551bb1fe3c3c25e419f5ac9017614804ce8c
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "thread.h"
22 #include "kernel.h"
23 #include "sh7034.h"
24 #include "debug.h"
26 void tick_start(unsigned int interval);
28 unsigned int s1[256];
29 unsigned int s2[256];
31 void t1(void);
32 void t2(void);
34 struct event_queue main_q;
36 int tick_add_task(void (*f)(void));
38 void testfunc(void)
40 if(current_tick == 5000)
41 debugf("Yippie!\n");
44 int main(void)
46 char buf[40];
47 char str[32];
48 int i=0;
49 struct queue_event *ev;
51 /* Clear it all! */
52 SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER);
54 /* This enables the serial Rx interrupt, to be able to exit into the
55 debugger when you hit CTRL-C */
56 SCR1 |= 0x40;
57 SCR1 &= ~0x80;
58 IPRE |= 0xf000; /* Set to highest priority */
60 debugf("OK. Let's go\n");
62 kernel_init();
64 enable_irq();
66 tick_add_task(testfunc);
68 debugf("sleeping 10s...\n");
69 sleep(HZ*10);
70 debugf("woke up\n");
72 queue_init(&main_q);
74 create_thread(t1, s1, 1024, 0);
75 create_thread(t2, s2, 1024, 0);
77 while(1)
79 ev = queue_wait(&main_q);
80 debugf("Thread 0 got an event. ID: %d\n", ev->id);
84 void t1(void)
86 debugf("Thread 1 started\n");
87 while(1)
89 sleep(HZ);
90 debugf("Thread 1 posting an event\n");
91 queue_post(&main_q, 1234, 0);
92 queue_post(&main_q, 5678, 0);
96 void t2(void)
98 debugf("Thread 2 started\n");
99 while(1)
101 sleep(HZ*3);
102 debugf("Thread 2 awakened\n");