]> rtime.felk.cvut.cz Git - arc.git/blob - arch/arm/arm_cm3/kernel/Frt.c
6a65c4352e7c6d3234df8b60cc071798a7afae90
[arc.git] / arch / arm / arm_cm3 / kernel / Frt.c
1 /* -------------------------------- Arctic Core ------------------------------
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com
3  *
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
5  *
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>.
9  *
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
13  * for more details.
14  * -------------------------------- Arctic Core ------------------------------*/
15
16
17
18
19
20
21
22
23 /*\r
24  * timer.c\r
25  *\r
26  *  Created on: 2009-jan-17\r
27  *      Author: mahi\r
28  */\r
29 \r
30 #include "Os.h"\r
31 #include "sys.h"\r
32 #include "pcb.h"\r
33 #include "internal.h"\r
34 #include "stm32f10x.h"\r
35 #include "core_cm3.h"\r
36 \r
37 /**\r
38  * Init of free running timer.\r
39  */\r
40 void Frt_Init( void ) {\r
41         TaskType tid;\r
42         tid = Os_CreateIsr(OsTick,6/*prio*/,"OsTick");\r
43         IntCtrl_AttachIsr2(tid,NULL,7);\r
44 }\r
45 \r
46 /**\r
47  *
48  * @param period_ticks How long the period in timer ticks should be. The timer\r
49  *                     on PowerPC often driver by the CPU clock or some platform clock.\r
50  *
51  */\r
52
53 void Frt_Start(uint32_t period_ticks) {
54
55         SysTick_Config(period_ticks);
56
57 #if 0
58         // SysTick interrupt each 250ms with counter clock equal to 9MHz
59         if (SysTick_Config((SystemFrequency / 8) / 4)) {
60                 // Capture error
61                 while (1)
62                         ;
63         }
64
65         // Select HCLK/8 as SysTick clock source
66         SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
67 #endif
68
69 }\r
70 \r
71 /**\r
72  * @return
73  */\r
74 \r
75 uint32_t Frt_GetTimeElapsed( void )\r
76 {\r
77         return (SysTick->VAL);\r
78 }\r