1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\r
6 * This source code is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the GNU General Public License version 2 as published by the
\r
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
\r
10 * This program is distributed in the hope that it will be useful, but
\r
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
\r
14 * -------------------------------- Arctic Core ------------------------------*/
\r
17 #include "internal.h"
\r
18 #include "stm32f10x.h"
\r
19 #include "core_cm3.h"
\r
25 * Init of free running timer.
\r
27 void Os_SysTickInit( void ) {
\r
29 tid = Os_Arc_CreateIsr(OsTick,6/*prio*/,"OsTick");
\r
30 Irq_AttachIsr2(tid,NULL, SysTick_IRQn);
\r
34 * Start the Sys Tick timer
\r
36 * @param period_ticks How long the period in timer ticks should be.
\r
40 void Os_SysTickStart(uint32_t period_ticks) {
\r
42 /* Cortex-M3 have a 24-bit system timer that counts down
\r
43 * from the reload value to zero.
\r
46 SysTick_Config(period_ticks);
\r
48 /* Set SysTick Priority to 3 */
\r
49 NVIC_SetPriority(SysTick_IRQn, 0x0C);
\r
52 // SysTick interrupt each 250ms with counter clock equal to 9MHz
\r
53 if (SysTick_Config((SystemFrequency / 8) / 4)) {
\r
59 // Select HCLK/8 as SysTick clock source
\r
60 SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
\r
69 uint32_t Os_SysTickGetValue( void )
\r
71 return (SysTick->VAL);
\r