Skip to content

Commit 69adc49

Browse files
committed
Moved kernel tick timer specifics to FreeRTOS_Tick_Config module
1 parent 8ba180d commit 69adc49

11 files changed

Lines changed: 622 additions & 73 deletions

File tree

ARM.CMSIS-FreeRTOS.pdsc

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<license>License/license.txt</license>
99

1010
<releases>
11-
<release version="9.0.0-RC4">
11+
<release version="9.0.0-RC5">
1212
Added example for Cortex-A9 FVP
1313
</release>
1414
<release version="9.0.0-RC3" date="2017-02-15">
@@ -94,6 +94,21 @@
9494
<require Dcore="Cortex-A9" Dfpu="DP_FPU"/>
9595
</condition>
9696

97+
<condition id="CoreM">
98+
<description>Cortex-M processor based device</description>
99+
<accept condition="CM0"/>
100+
<accept condition="CM3"/>
101+
<accept condition="CM4"/>
102+
<accept condition="CM4_FP"/>
103+
<accept condition="CM7"/>
104+
<accept condition="CM7_FP"/>
105+
</condition>
106+
107+
<condition id="CoreA">
108+
<description>Cortex-A processor based device</description>
109+
<accept condition="CA9_DP"/>
110+
</condition>
111+
97112
<!-- ARMCC compiler -->
98113
<condition id="CM0_ARMCC">
99114
<description>Cortex-M0 or Cortex-M0+ or SC000 processor based device for the ARM Compiler</description>
@@ -309,7 +324,11 @@
309324
#define RTE_RTOS_FreeRTOS_CONFIG_RTOS2 /* RTOS FreeRTOS Config for CMSIS RTOS2 API */
310325
</RTE_Components_h>
311326
<files>
312-
<file category="header" attr="config" name="CMSIS/RTOS2/FreeRTOS/Config/FreeRTOSConfig.h" version="9.0.0"/>
327+
<file category="header" attr="config" name="CMSIS/RTOS2/FreeRTOS/Config/ARMCM/FreeRTOSConfig.h" version="9.0.0" cond="CoreM"/>
328+
<file category="header" attr="config" name="CMSIS/RTOS2/FreeRTOS/Config/ARMCA/FreeRTOSConfig.h" version="9.0.0" cond="CoreA"/>
329+
330+
<file category="header" attr="config" name="CMSIS/RTOS2/FreeRTOS/Config/FreeRTOS_Tick_Config.h" version="9.0.0"/>
331+
<file category="source" attr="config" name="CMSIS/RTOS2/FreeRTOS/Config/FreeRTOS_Tick_Config.c" version="9.0.0"/>
313332
</files>
314333
</component>
315334

@@ -319,7 +338,8 @@
319338
#define RTE_RTOS_FreeRTOS_CONFIG /* RTOS FreeRTOS Config for FreeRTOS API */
320339
</RTE_Components_h>
321340
<files>
322-
<file category="header" attr="config" name="Config/FreeRTOSConfig.h" version="9.0.0"/>
341+
<file category="header" attr="config" name="Config/ARMCM/FreeRTOSConfig.h" version="9.0.0" cond="CoreM"/>
342+
<file category="header" attr="config" name="Config/ARMCA/FreeRTOSConfig.h" version="9.0.0" cond="CoreA"/>
323343
</files>
324344
</component>
325345

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
/*
2+
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
3+
All rights reserved
4+
5+
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6+
7+
This file is part of the FreeRTOS distribution.
8+
9+
FreeRTOS is free software; you can redistribute it and/or modify it under
10+
the terms of the GNU General Public License (version 2) as published by the
11+
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
12+
13+
***************************************************************************
14+
>>! NOTE: The modification to the GPL is included to allow you to !<<
15+
>>! distribute a combined work that includes FreeRTOS without being !<<
16+
>>! obliged to provide the source code for proprietary components !<<
17+
>>! outside of the FreeRTOS kernel. !<<
18+
***************************************************************************
19+
20+
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22+
FOR A PARTICULAR PURPOSE. Full license text is available on the following
23+
link: http://www.freertos.org/a00114.html
24+
25+
***************************************************************************
26+
* *
27+
* FreeRTOS provides completely free yet professionally developed, *
28+
* robust, strictly quality controlled, supported, and cross *
29+
* platform software that is more than just the market leader, it *
30+
* is the industry's de facto standard. *
31+
* *
32+
* Help yourself get started quickly while simultaneously helping *
33+
* to support the FreeRTOS project by purchasing a FreeRTOS *
34+
* tutorial book, reference manual, or both: *
35+
* http://www.FreeRTOS.org/Documentation *
36+
* *
37+
***************************************************************************
38+
39+
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
40+
the FAQ page "My application does not run, what could be wrong?". Have you
41+
defined configASSERT()?
42+
43+
http://www.FreeRTOS.org/support - In return for receiving this top quality
44+
embedded software for free we request you assist our global community by
45+
participating in the support forum.
46+
47+
http://www.FreeRTOS.org/training - Investing in training allows your team to
48+
be as productive as possible as early as possible. Now you can receive
49+
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50+
Ltd, and the world's leading authority on the world's leading RTOS.
51+
52+
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53+
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54+
compatible FAT file system, and our tiny thread aware UDP/IP stack.
55+
56+
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57+
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
58+
59+
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60+
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
61+
licenses offer ticketed support, indemnification and commercial middleware.
62+
63+
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64+
engineered and independently SIL3 certified version for use in safety and
65+
mission critical applications that require provable dependability.
66+
67+
1 tab == 4 spaces!
68+
*/
69+
70+
#ifndef FREERTOS_CONFIG_H
71+
#define FREERTOS_CONFIG_H
72+
73+
/*-----------------------------------------------------------
74+
* Application specific definitions.
75+
*
76+
* These definitions should be adjusted for your particular hardware and
77+
* application requirements.
78+
*
79+
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
80+
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
81+
*
82+
* See http://www.freertos.org/a00110.html.
83+
*----------------------------------------------------------*/
84+
85+
#include <stdint.h>
86+
87+
extern uint32_t SystemCoreClock;
88+
89+
//-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
90+
91+
// <o>Minimal stack size [words] <0-65535>
92+
// <i> Stack for idle task and default task stack in words.
93+
// <i> Default: 128
94+
#define configMINIMAL_STACK_SIZE ((uint16_t)(128))
95+
96+
// <o>Total heap size [bytes] <0-0xFFFFFFFF>
97+
// <i> Heap memory size in bytes.
98+
// <i> Default: 8192
99+
#define configTOTAL_HEAP_SIZE ((size_t)8192)
100+
101+
// <o>Kernel tick frequency [Hz] <0-0xFFFFFFFF>
102+
// <i> Kernel tick rate in Hz.
103+
// <i> Default: 1000
104+
#define configTICK_RATE_HZ ((TickType_t)1000)
105+
106+
// <o>Timer task stack depth [words] <0-65535>
107+
// <i> Stack for timer task in words.
108+
// <i> Default: 80
109+
#define configTIMER_TASK_STACK_DEPTH 80
110+
111+
// <o>Timer task priority <0-56>
112+
// <i> Timer task priority.
113+
// <i> Default: 40 (High)
114+
#define configTIMER_TASK_PRIORITY 40
115+
116+
// <o>Timer queue length <0-1024>
117+
// <i> Timer command queue length.
118+
// <i> Default: 5
119+
#define configTIMER_QUEUE_LENGTH 5
120+
121+
// <q>Use time slicing
122+
// <i> Enable setting to use timeslicing.
123+
// <i> Default: 1
124+
#define configUSE_TIME_SLICING 1
125+
126+
// <q>Idle should yield
127+
// <i> Control Yield behaviour of the idle task.
128+
// <i> Default: 1
129+
#define configIDLE_SHOULD_YIELD 1
130+
131+
// <o>Check for stack overflow
132+
// <0=>Disable <1=>Method one <2=>Method two
133+
// <i> Enable or disable stack overflow checking.
134+
// <i> Callback function vApplicationStackOverflowHook implementation is required when stack checking is enabled.
135+
// <i> Default: 0
136+
#define configCHECK_FOR_STACK_OVERFLOW 2
137+
138+
// <q>Use idle hook
139+
// <i> Enable callback function call on each idle task iteration.
140+
// <i> Callback function vApplicationIdleHook implementation is required when idle hook is enabled.
141+
// <i> Default: 0
142+
#define configUSE_IDLE_HOOK 0
143+
144+
// <q>Use tick hook
145+
// <i> Enable callback function call during each tick interrupt.
146+
// <i> Callback function vApplicationTickHook implementation is required when tick hook is enabled.
147+
// <i> Default: 0
148+
#define configUSE_TICK_HOOK 0
149+
150+
// <q>Use deamon task startup hook
151+
// <i> Enable callback function call when timer service starts.
152+
// <i> Callback function vApplicationDaemonTaskStartupHook implementation is required when deamon task startup hook is enabled.
153+
// <i> Default: 0
154+
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
155+
156+
// <q>Use malloc failed hook
157+
// <i> Enable callback function call when out of dynamic memory.
158+
// <i> Callback function vApplicationMallocFailedHook implementation is required when malloc failed hook is enabled.
159+
// <i> Default: 0
160+
#define configUSE_MALLOC_FAILED_HOOK 0
161+
162+
// <q>Interrupt controller base address
163+
// <i> Must be set to the base address of the ARM Generic Interrupt Controller (GIC).
164+
// <i> Default: 0x2C000000
165+
#define configINTERRUPT_CONTROLLER_BASE_ADDRESS 0x2C000000UL
166+
167+
// <q>Interrupt controller CPU interface offset
168+
// <i> Must be set to the offset from interrupt controller base address at which the CPU interface starts.
169+
// <i> Default: 0x1000
170+
#define configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET 0x00000100UL
171+
172+
// <q>Interrupt controller unique priorities
173+
// <i> The number of unique priorities that can be specified in the ARM Generic Interrupt Controller (GIC).
174+
// <i> Default: 32
175+
#define configUNIQUE_INTERRUPT_PRIORITIES 32
176+
177+
// <q>Maximum API call interrupt priority
178+
// <i> Interrupts assigned a priority at or below this priority can call interrupt safe FreeRTOS API function, and will nest.
179+
// <i> Interrupts assigned a priority above this priority will not be effected by RTOS critical sections, and will nest,
180+
// <i> but cannot call any FreeRTOS API functions.
181+
// <i> Default: 32
182+
#define configMAX_API_CALL_INTERRUPT_PRIORITY 32
183+
184+
//------------- <<< end of configuration section >>> ---------------------------
185+
186+
/* Defines needed by FreeRTOS to implement CMSIS RTOS2 API. Do not change! */
187+
#define configCPU_CLOCK_HZ (SystemCoreClock)
188+
#define configSUPPORT_STATIC_ALLOCATION 1
189+
#define configSUPPORT_DYNAMIC_ALLOCATION 1
190+
#define configUSE_PREEMPTION 1
191+
#define configUSE_TIMERS 1
192+
#define configUSE_MUTEXES 1
193+
#define configUSE_RECURSIVE_MUTEXES 1
194+
#define configUSE_COUNTING_SEMAPHORES 1
195+
#define configUSE_TASK_NOTIFICATIONS 1
196+
#define configUSE_TRACE_FACILITY 1
197+
#define configUSE_16_BIT_TICKS 0
198+
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
199+
#define configMAX_PRIORITIES 56
200+
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 16
201+
#define configKERNEL_INTERRUPT_PRIORITY 255
202+
203+
/* Defines that include FreeRTOS functions which implement CMSIS RTOS2 API. Do not change! */
204+
#define INCLUDE_xEventGroupSetBitsFromISR 1
205+
#define INCLUDE_xSemaphoreGetMutexHolder 1
206+
#define INCLUDE_vTaskDelay 1
207+
#define INCLUDE_vTaskDelayUntil 1
208+
#define INCLUDE_vTaskDelete 1
209+
#define INCLUDE_xTaskGetCurrentTaskHandle 1
210+
#define INCLUDE_xTaskGetSchedulerState 1
211+
#define INCLUDE_uxTaskGetStackHighWaterMark 1
212+
#define INCLUDE_uxTaskPriorityGet 1
213+
#define INCLUDE_vTaskPrioritySet 1
214+
#define INCLUDE_eTaskGetState 1
215+
#define INCLUDE_vTaskSuspend 1
216+
#define INCLUDE_xTimerPendFunctionCall 1
217+
218+
/* Include kernel tick timer definitions */
219+
#include "FreeRTOS_Tick_Config.h"
220+
221+
/* Map the FreeRTOS port timer configuration functions to their implementations */
222+
#define configSETUP_TICK_INTERRUPT() vConfigureTickInterrupt()
223+
#define configCLEAR_TICK_INTERRUPT() vClearTickInterrupt()
224+
225+
#endif /* FREERTOS_CONFIG_H */

CMSIS/RTOS2/FreeRTOS/Config/FreeRTOSConfig.h renamed to CMSIS/RTOS2/FreeRTOS/Config/ARMCM/FreeRTOSConfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ extern uint32_t SystemCoreClock;
197197
#define xPortPendSVHandler PendSV_Handler
198198
#define vPortSVCHandler SVC_Handler
199199

200+
/* Include kernel tick timer definitions */
201+
#include "FreeRTOS_Tick_Config.h"
202+
200203
/* Include debug event definitions */
201204
#include "freertos_evr.h"
202205

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/* --------------------------------------------------------------------------
2+
* Copyright (c) 2013-2017 ARM Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Name: FreeRTOS_Tick_Config.c
19+
* Purpose: FreeRTOS kernel tick timer configuration
20+
*
21+
*---------------------------------------------------------------------------*/
22+
23+
#include <string.h>
24+
25+
#include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core
26+
27+
#if defined (TICK_TIMER_SYSTICK)
28+
/* SysTick handler prototype */
29+
extern void SysTick_Handler (void);
30+
31+
/* FreeRTOS tick timer interrupt handler prototype */
32+
extern void xPortSysTickHandler (void);
33+
34+
/*
35+
SysTick handler implementation that also clears overflow flag.
36+
*/
37+
void SysTick_Handler (void) {
38+
/* Clear overflow flag */
39+
SysTick->CTRL;
40+
41+
/* Call tick handler */
42+
xPortSysTickHandler();
43+
}
44+
#elif defined (TICK_TIMER_PTIM)
45+
/*
46+
Configure Private Timer as FreeRTOS tick timer and install function
47+
FreeRTOS_Tick_Handler as tick timer interrupt handler.
48+
*/
49+
void vConfigureTickInterrupt (void) {
50+
51+
PTIM_SetLoadValue ((SystemCoreClock/configTICK_RATE_HZ) - 1U);
52+
PTIM_SetControl (PTIM_GetControl() | 7U);
53+
54+
/* Next assume Install_Interrupt() installs the function passed as its second
55+
parameter as the handler for the peripheral passed as its first parameter. */
56+
InterruptHandlerRegister (PrivTimer_IRQn, FreeRTOS_Tick_Handler);
57+
58+
/* Determine number of implemented priority bits */
59+
GIC_SetPriority (PrivTimer_IRQn, 0xFFU);
60+
61+
/* Set lowest priority -1 */
62+
GIC_SetPriority (PrivTimer_IRQn, GIC_GetPriority(PrivTimer_IRQn)-1);
63+
64+
/* Enable IRQ */
65+
GIC_EnableIRQ (PrivTimer_IRQn);
66+
}
67+
68+
/*
69+
Clear Private Timer interrupt flag.
70+
*/
71+
void vClearTickInterrupt (void) {
72+
PTIM_ClearEventFlag();
73+
}
74+
#endif

0 commit comments

Comments
 (0)