1 /* -------------------------------- Arctic Core ------------------------------
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
6 * This source code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by the
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * -------------------------------- Arctic Core ------------------------------*/
22 * Init of free running timer.
\r
24 void Frt_Init( void ) {
\r
26 tid = Os_Arc_CreateIsr(OsTick,6/*prio*/,"OsTick");
\r
27 Irq_AttachIsr2(tid,NULL,7);
\r
33 * @param period_ticks How long the period in timer ticks should be. The timer
\r
34 * on PowerPC often driver by the CPU clock or some platform clock.
\r
37 void Frt_Start(uint32_t period_ticks) {
\r
41 tmp = get_spr(SPR_HID0);
\r
43 set_spr(SPR_HID0, tmp);
\r
45 /* Initialize the Decrementer */
\r
46 set_spr(SPR_DEC, period_ticks);
\r
47 set_spr(SPR_DECAR, period_ticks);
\r
49 /* Set autoreload */
\r
50 tmp = get_spr(SPR_TCR);
\r
52 set_spr(SPR_TCR, tmp);
\r
54 /* Enable notification */
\r
55 tmp = get_spr(SPR_TCR);
\r
57 set_spr(SPR_TCR, tmp );
\r
62 * TODO: This function just subtract the max value?! ok??
\r
68 uint32_t Frt_GetTimeElapsed( void )
\r
70 uint32_t timer = get_spr(SPR_DECAR) - get_spr(SPR_DEC);
\r