Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
85 theseven 1
//
2
//
3
//    Copyright 2010 TheSeven
4
//
5
//
427 farthen 6
//    This file is part of emCORE.
85 theseven 7
//
427 farthen 8
//    emCORE is free software: you can redistribute it and/or
85 theseven 9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
427 farthen 13
//    emCORE is distributed in the hope that it will be useful,
85 theseven 14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
427 farthen 19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
85 theseven 20
//
21
//
22
 
23
 
24
#include "global.h"
25
#include "timer.h"
26
#include "thread.h"
27
#include "s5l8720.h"
28
 
29
 
30
void setup_tick()
31
{
32
    int cycles = SYSTEM_TICK / 100;
33
 
34
    TACMD = (1 << 1);   /* TA_CLR */
35
    TBCMD = (1 << 1);   /* TB_CLR */
36
    TCCMD = (1 << 1);   /* TC_CLR */
37
    TDCMD = (1 << 1);   /* TD_CLR */
38
    TFCMD = (1 << 1);   /* TF_CLR */
39
    TGCMD = (1 << 1);   /* TG_CLR */
40
    THCMD = (1 << 1);   /* TH_CLR */
41
 
42
    /* configure timer for 10 kHz */
43
    TBPRE = 208 - 1;    /* prescaler */
44
    TBCON = (0 << 13) | /* TB_INT1_EN */
45
            (1 << 12) | /* TB_INT0_EN */
46
            (0 << 11) | /* TB_START */
47
            (3 << 8) |  /* TB_CS = PCLK / 64 */
48
            (0 << 4);   /* TB_MODE_SEL = interval mode */
49
    TBDATA0 = cycles;   /* set interval period */
50
    TBCMD = (1 << 0);   /* TB_EN */
51
}
52
 
53
void INT_TIMERB(void)
54
{
55
    TBCON = TBCON;
56
    scheduler_switch(-1);
57
}