summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-10-27 07:07:54 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-10-27 07:07:54 +0000
commit9c4423f01085305530b1eeb493436894da541e36 (patch)
tree14d5be788aa6834a67278a6bdca1f1e947792533
parent75a9a9b9a7f7115c8e59a6c390ad462394bd711b (diff)
downloadrockbox-9c4423f01085305530b1eeb493436894da541e36.tar.gz
rockbox-9c4423f01085305530b1eeb493436894da541e36.zip
Coldfire: System tick at 10ms
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5367 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/kernel.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c
index a9c7711003..221f8a3b38 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -20,7 +20,7 @@
20#include <string.h> 20#include <string.h>
21#include "kernel.h" 21#include "kernel.h"
22#include "thread.h" 22#include "thread.h"
23#include "sh7034.h" 23#include "cpu.h"
24#include "system.h" 24#include "system.h"
25#include "panic.h" 25#include "panic.h"
26 26
@@ -154,6 +154,7 @@ int queue_broadcast(int id, void *data)
154/**************************************************************************** 154/****************************************************************************
155 * Timer tick 155 * Timer tick
156 ****************************************************************************/ 156 ****************************************************************************/
157#if CONFIG_CPU == SH7034
157static void tick_start(unsigned int interval_in_ms) 158static void tick_start(unsigned int interval_in_ms)
158{ 159{
159 unsigned int count; 160 unsigned int count;
@@ -205,6 +206,52 @@ void IMIA0(void)
205 206
206 TSR0 &= ~0x01; 207 TSR0 &= ~0x01;
207} 208}
209#elif CONFIG_CPU == MCF5249
210static void tick_start(unsigned int interval_in_ms)
211{
212 unsigned int count;
213
214 count = FREQ/2 * interval_in_ms / 1000 / 16;
215
216 if(count > 0xffff)
217 {
218 panicf("Error! The tick interval is too long (%d ms)\n",
219 interval_in_ms);
220 return;
221 }
222
223 /* We are using timer 0 */
224
225 TRR0 = count; /* The reference count */
226 TCN0 = 0; /* reset the timer */
227 TMR0 = 0x001d; /* no prescaler, restart, CLK/16, enabled */
228
229 TER0 = 0xff; /* Clear all events */
230
231 ICR0 = (ICR0 & 0xff00ffff) | 0x008c0000; /* Interrupt on level 3.0 */
232 IMR &= ~0x200;
233}
234
235void TIMER0(void) __attribute__ ((interrupt_handler));
236void TIMER0(void)
237{
238 int i;
239
240 /* Run through the list of tick tasks */
241 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
242 {
243 if(tick_funcs[i])
244 {
245 tick_funcs[i]();
246 }
247 }
248
249 current_tick++;
250 wake_up_thread();
251
252 TER0 = 0xff; /* Clear all events */
253}
254#endif
208 255
209int tick_add_task(void (*f)(void)) 256int tick_add_task(void (*f)(void))
210{ 257{