Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 theseven 1
//
2
//
3
//    Copyright 2010 TheSeven
4
//
5
//
6
//    This file is part of emBIOS.
7
//
8
//    emBIOS is free software: you can redistribute it and/or
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
//
13
//    emBIOS is distributed in the hope that it will be useful,
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
19
//    with emBIOS.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//
22
 
23
 
24
#include "global.h"
25
#include "timer.h"
26
#include "thread.h"
27
#include "s5l8701.h"
28
 
29
 
30
void setup_tick()
31
{
32
    int cycles = SYSTEM_TICK / 100;
33
 
34
    /* configure timer for 10 kHz */
35
    TBCMD = (1 << 1);   /* TB_CLR */
36
    TBPRE = 300 - 1;    /* prescaler */
37
    TBCON = (0 << 13) | /* TB_INT1_EN */
38
            (1 << 12) | /* TB_INT0_EN */
39
            (0 << 11) | /* TB_START */
40
            (2 << 8) |  /* TB_CS = PCLK / 16 */
41
            (0 << 4);   /* TB_MODE_SEL = interval mode */
42
    TBDATA0 = cycles;   /* set interval period */
43
    TBCMD = (1 << 0);   /* TB_EN */
44
}
45
 
46
void INT_TIMERB(void)
47
{
48
    TBCON = TBCON;
49
    scheduler_switch(-1);
50
}