| 273 |
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 "s5l8702.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 |
TGCMD = (1 << 1); /* TG_CLR */
|
|
|
39 |
THCMD = (1 << 1); /* TH_CLR */
|
|
|
40 |
|
|
|
41 |
/* configure timer for 10 kHz */
|
| 411 |
theseven |
42 |
TBPRE = 337 - 1; /* prescaler */
|
| 273 |
theseven |
43 |
TBCON = (0 << 13) | /* TB_INT1_EN */
|
|
|
44 |
(1 << 12) | /* TB_INT0_EN */
|
|
|
45 |
(0 << 11) | /* TB_START */
|
|
|
46 |
(3 << 8) | /* TB_CS = PCLK / 64 */
|
|
|
47 |
(0 << 4); /* TB_MODE_SEL = interval mode */
|
|
|
48 |
TBDATA0 = cycles; /* set interval period */
|
|
|
49 |
TBCMD = (1 << 0); /* TB_EN */
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
void INT_TIMERB(void)
|
|
|
53 |
{
|
|
|
54 |
TBCON = TBCON;
|
|
|
55 |
scheduler_switch(-1);
|
|
|
56 |
}
|