1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright © 2009 Bertrik Sikken
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 /* S5L8700 driver for the kernel timer
27 Timer B is configured as a 10 kHz timer (assuming PCLK = 48 MHz)
35 call_tick_tasks(); /* Run through the list of tick tasks */
38 void tick_start(unsigned int interval_in_ms
)
40 int cycles
= 10 * interval_in_ms
;
42 /* enable timer clock */
45 /* configure timer for 10 kHz */
46 TBCMD
= (1 << 1); /* TB_CLR */
47 TBPRE
= 300 - 1; /* prescaler for 48 MHz HCLK */
48 TBCON
= (0 << 13) | /* TB_INT1_EN */
49 (1 << 12) | /* TB_INT0_EN */
50 (0 << 11) | /* TB_START */
51 (2 << 8) | /* TB_CS = PCLK / 16 */
52 (0 << 4); /* TB_MODE_SEL = interval mode */
53 TBDATA0
= cycles
; /* set interval period */
54 TBCMD
= (1 << 0); /* TB_EN */
56 /* enable timer interrupt */
57 INTMSK
|= INTMSK_TIMERB
;