Rob Purchase | 47ea030 | 2008-01-14 22:04:48 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2008 by Rob Purchase |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Rob Purchase | 47ea030 | 2008-01-14 22:04:48 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #include "config.h" |
| 23 | #include "cpu.h" |
| 24 | #include "system.h" |
| 25 | #include "timer.h" |
| 26 | #include "logf.h" |
| 27 | |
| 28 | /* Use the TC32 counter [sourced by Xin:12Mhz] for this timer, as it's the |
| 29 | only one that allows a 32-bit counter (Timer0-5 are 16/20 bit only). */ |
| 30 | |
| 31 | bool __timer_set(long cycles, bool start) |
| 32 | { |
Rob Purchase | 47ea030 | 2008-01-14 22:04:48 +0000 | [diff] [blame] | 33 | (void)cycles; |
| 34 | (void)start; |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | bool __timer_register(void) |
| 39 | { |
Rob Purchase | 47ea030 | 2008-01-14 22:04:48 +0000 | [diff] [blame] | 40 | return false; |
| 41 | } |
| 42 | |
| 43 | void __timer_unregister(void) |
| 44 | { |
Rob Purchase | 47ea030 | 2008-01-14 22:04:48 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | |
| 48 | /* Timer interrupt processing - all timers (inc. tick) have a single IRQ */ |
| 49 | |
| 50 | extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); |
| 51 | |
Rob Purchase | 4dc2d8d | 2008-03-22 19:41:51 +0000 | [diff] [blame] | 52 | void TIMER0(void) |
Rob Purchase | 47ea030 | 2008-01-14 22:04:48 +0000 | [diff] [blame] | 53 | { |
| 54 | if (TIREQ & TF0) /* Timer0 reached ref value */ |
| 55 | { |
| 56 | int i; |
| 57 | |
| 58 | /* Run through the list of tick tasks */ |
| 59 | for(i = 0; i < MAX_NUM_TICK_TASKS; i++) |
| 60 | { |
| 61 | if(tick_funcs[i]) |
| 62 | { |
| 63 | tick_funcs[i](); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | current_tick++; |
| 68 | |
| 69 | /* reset Timer 0 IRQ & ref flags */ |
| 70 | TIREQ |= TI0 | TF0; |
| 71 | } |
| 72 | |
| 73 | if (TC32IRQ & (1<<3)) /* end of TC32 prescale */ |
| 74 | { |
| 75 | /* dispatch timer */ |
| 76 | } |
Rob Purchase | 47ea030 | 2008-01-14 22:04:48 +0000 | [diff] [blame] | 77 | } |