1 /* --------------------------------------------------------------------------
2 * Copyright (c) 2013-2024 Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
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
10 * www.apache.org/licenses/LICENSE-2.0
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.
18 * --------------------------------------------------------------------------
22 * Project: CMSIS-FreeRTOS
23 * Title: FreeRTOS configuration definitions
25 * --------------------------------------------------------------------------*/
27 #ifndef FREERTOS_CONFIG_H
28 #define FREERTOS_CONFIG_H
30 /*-----------------------------------------------------------
31 * Application specific definitions.
33 * These definitions should be adjusted for your particular hardware and
34 * application requirements.
36 * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
37 * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
39 * See http://www.freertos.org/a00110.html
40 *----------------------------------------------------------*/
42 #if (defined(__ARMCC_VERSION) || defined(__GNUC__) || defined(__ICCARM__))
45 #include "RTE_Components.h"
46 #include CMSIS_device_header
49 //-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
51 // <o>Minimal stack size [words] <0-65535>
52 // <i> Stack for idle task and default task stack in words.
54 #define configMINIMAL_STACK_SIZE ((uint16_t)(128))
56 // <o>Total heap size [bytes] <0-0xFFFFFFFF>
57 // <i> Heap memory size in bytes.
59 #define configTOTAL_HEAP_SIZE ((size_t)8192)
61 // <o>Kernel tick frequency [Hz] <0-0xFFFFFFFF>
62 // <i> Kernel tick rate in Hz.
64 #define configTICK_RATE_HZ ((TickType_t)1000)
66 // <o>Timer task stack depth [words] <0-65535>
67 // <i> Stack for timer task in words.
69 #define configTIMER_TASK_STACK_DEPTH 80
71 // <o>Timer task priority <0-56>
72 // <i> Timer task priority.
73 // <i> Default: 40 (High)
74 #define configTIMER_TASK_PRIORITY 40
76 // <o>Timer queue length <0-1024>
77 // <i> Timer command queue length.
79 #define configTIMER_QUEUE_LENGTH 5
81 // <o>Preemption interrupt priority
82 // <i> Maximum priority of interrupts that are safe to call FreeRTOS API.
84 #define configMAX_SYSCALL_INTERRUPT_PRIORITY 128
86 // <q>Use time slicing
87 // <i> Enable setting to use timeslicing.
89 #define configUSE_TIME_SLICING 1
91 // <q>Use tickless idle
92 // <i> Enable low power tickless mode to stop the periodic tick interrupt during idle periods or
93 // <i> disable it to keep the tick interrupt running at all times.
95 #define configUSE_TICKLESS_IDLE 0
97 // <q>Idle should yield
98 // <i> Control Yield behaviour of the idle task.
100 #define configIDLE_SHOULD_YIELD 1
102 // <o>Check for stack overflow
103 // <0=>Disable <1=>Method one <2=>Method two
104 // <i> Enable or disable stack overflow checking.
105 // <i> Callback function vApplicationStackOverflowHook implementation is required when stack checking is enabled.
107 #define configCHECK_FOR_STACK_OVERFLOW 2
110 // <i> Enable callback function call on each idle task iteration.
111 // <i> Callback function vApplicationIdleHook implementation is required when idle hook is enabled.
113 #define configUSE_IDLE_HOOK 0
116 // <i> Enable callback function call during each tick interrupt.
117 // <i> Callback function vApplicationTickHook implementation is required when tick hook is enabled.
119 #define configUSE_TICK_HOOK 0
121 // <q>Use deamon task startup hook
122 // <i> Enable callback function call when timer service starts.
123 // <i> Callback function vApplicationDaemonTaskStartupHook implementation is required when deamon task startup hook is enabled.
125 #define configUSE_DAEMON_TASK_STARTUP_HOOK 0
127 // <q>Use malloc failed hook
128 // <i> Enable callback function call when out of dynamic memory.
129 // <i> Callback function vApplicationMallocFailedHook implementation is required when malloc failed hook is enabled.
131 #define configUSE_MALLOC_FAILED_HOOK 0
133 // <o>Queue registry size
134 // <i> Define maximum number of queue objects registered for debug purposes.
135 // <i> The queue registry is used by kernel aware debuggers to locate queue and semaphore structures and display associated text names.
137 #define configQUEUE_REGISTRY_SIZE 0
139 // <h>Event Recorder Configuration
140 // <i> Initialize and setup Event Recorder level filtering.
141 // <i> Settings have no effect when Event Recorder is not present.
143 // <q>Initialize Event Recorder
144 // <i> Initialize Event Recorder before FreeRTOS kernel start.
146 #define configEVR_INITIALIZE 1
148 // <e>Setup recording level filter
149 // <i> Enable configuration of FreeRTOS events recording level
151 #define configEVR_SETUP_LEVEL 1
153 // <o>Tasks functions
154 // <i> Define event recording level bitmask for events generated from Tasks functions.
156 // <0x00=>Off <0x01=>Errors <0x03=>Errors + API <0x05=>Errors + Operation <0x07=>Errors + API + Operation <0x0F=>All
157 #define configEVR_LEVEL_TASKS 0x07
159 // <o>Queue functions
160 // <i> Define event recording level bitmask for events generated from Queue functions.
162 // <0x00=>Off <0x01=>Errors <0x03=>Errors + API <0x05=>Errors + Operation <0x07=>Errors + API + Operation <0x0F=>All
163 #define configEVR_LEVEL_QUEUE 0x07
165 // <o>Timer functions
166 // <i> Define event recording level bitmask for events generated from Timer functions.
168 // <0x00=>Off <0x01=>Errors <0x03=>Errors + API <0x05=>Errors + Operation <0x07=>Errors + API + Operation <0x0F=>All
169 #define configEVR_LEVEL_TIMERS 0x07
171 // <o>Event Groups functions
172 // <i> Define event recording level bitmask for events generated from Event Groups functions.
174 // <0x00=>Off <0x01=>Errors <0x03=>Errors + API <0x05=>Errors + Operation <0x07=>Errors + API + Operation <0x0F=>All
175 #define configEVR_LEVEL_EVENTGROUPS 0x07
178 // <i> Define event recording level bitmask for events generated from Heap functions.
180 // <0x00=>Off <0x01=>Errors <0x03=>Errors + API <0x05=>Errors + Operation <0x07=>Errors + API + Operation <0x0F=>All
181 #define configEVR_LEVEL_HEAP 0x07
183 // <o>Stream Buffer functions
184 // <i> Define event recording level bitmask for events generated from Stream Buffer functions.
186 // <0x00=>Off <0x01=>Errors <0x03=>Errors + API <0x05=>Errors + Operation <0x07=>Errors + API + Operation <0x0F=>All
187 #define configEVR_LEVEL_STREAMBUFFER 0x07
191 // <h>Memory Allocation Configuration
192 // <i> Enable and configure memory allocation specific features.
193 // <i> To configure FreeRTOS heap size use configTOTAL_HEAP_SIZE.
195 // <q> Support static memory allocation
196 // <i> Enable or disable static memory allocation.
197 // <i> When enabled RTOS objects can be created using application provided RAM.
199 #define configSUPPORT_STATIC_ALLOCATION 1
201 // <q> Support dynamic memory allocation
202 // <i> Enable or disable dynamic memory allocation.
203 // <i> When enabled RTOS objects can be created using RAM automatically allocated from the FreeRTOS heap.
205 #define configSUPPORT_DYNAMIC_ALLOCATION 1
207 // <q>Use kernel provided static memory
208 // <i> When enabled FreeRTOS kernel provides static memory for Idle and Timer tasks.
209 // <i> Otherwise user shall provide implementation of:
210 // <i> - vApplicationGetIdleTaskMemory and vApplicationGetTimerTaskMemory
211 // <i> - vApplicationGetPassiveIdleTaskMemory (when kernel uses SMP)
213 #define configKERNEL_PROVIDED_STATIC_MEMORY 1
215 // <q>Use application allocated heap
216 // <i> Global heap buffer must be provided externally when using application allocated heap.
217 // <i> The buffer must be declared as: uint8_t ucHeap[ configTOTAL_HEAP_SIZE ].
219 #define configAPPLICATION_ALLOCATED_HEAP 0
221 // <q>Use separate heap for stack allocation
222 // <i> Enable or disable stack allocation for any task from a separate heap.
223 // <i> Thread-safe implementation of pvPortMallocStack and vPortFreeStack is required when using separate heap.
225 #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
227 // <q>Use heap protector
228 // <i> Enable or disable bounds checking and obfuscation to heap block pointers.
229 // <i> This setting only applies to Heap_4 and Heap_5.
231 #define configENABLE_HEAP_PROTECTOR 0
234 // <h>Port Specific Configuration
235 // <i> Enable and configure port specific features.
236 // <i> Check FreeRTOS documentation for definitions that apply for the used port.
238 // <q>Use Floating Point Unit
239 // <i> Using Floating Point Unit (FPU) affects context handling.
240 // <i> Enable FPU when application uses floating point operations.
241 // <i> This setting is only relevant on ARMv8-M ports.
243 #define configENABLE_FPU 0
245 // <q>Use M-Profile Vector Extension
246 // <i> Using M-Profile Vector Extension (MVE) affects context handling.
247 // <i> Enable MVE when application uses signal processing and ML algorithms.
248 // <i> This setting is only relevant on ARMv8-M ports.
250 #define configENABLE_MVE 0
252 // <q>Use Memory Protection Unit
253 // <i> Using Memory Protection Unit (MPU) requires detailed memory map definition.
254 // <i> This setting is only relevant on ARMv8-M MPU enabled ports.
256 #define configENABLE_MPU 0
258 // <q>Use TrustZone Secure Side Only
259 // <i> This settings prevents FreeRTOS contex switch to Non-Secure side.
260 // <i> Enable this setting when FreeRTOS runs on the Secure side only.
261 // <i> This setting is only relevant on ARMv8-M ports.
263 #define configRUN_FREERTOS_SECURE_ONLY 0
265 // <q>Use TrustZone Security Extension
266 // <i> Using TrustZone affects context handling.
267 // <i> Enable TrustZone when FreeRTOS runs on the Non-Secure side and calls functions from the Secure side.
268 // <i> This setting is only relevant on ARMv8-M ports.
270 #define configENABLE_TRUSTZONE 0
272 // <o>Minimal secure stack size [words] <0-65535>
273 // <i> Stack for idle task Secure side context in words.
274 // <i> This setting is only relevant on ARMv8-M ports when TrustZone extension is enabled.
276 #define configMINIMAL_SECURE_STACK_SIZE ((uint32_t)128)
278 // <h>Interrupt Controller Configuration
279 // <i> Configure Arm Generic Interrupt Controller (GIC) interrupt controller specific settings.
280 // <i> Settings related to interrupt controller are relevant only on ARMv7-A ports.
282 // <o>Interrupt controller base address
283 // <i> Must be set to the base address of the interrupt controller peripheral.
284 // <i> Default: 0x2C000000
285 #define configINTERRUPT_CONTROLLER_BASE_ADDRESS 0x2C000000UL
287 // <o>Interrupt controller CPU interface offset
288 // <i> Must be set to the offset from interrupt controller base address at which the CPU interface starts.
289 // <i> Default: 0x1000
290 #define configINTERRUPT_CONTROLLER_CPU_INTERFACE_OFFSET 0x00001000UL
292 // <o>Interrupt controller unique priorities
293 // <i> The number of unique priorities that can be specified in the interrupt controller peripheral.
295 #define configUNIQUE_INTERRUPT_PRIORITIES 32
299 // <h>Symmetric Multiprocessing Configuration
300 // <i> Enable and configure FreeRTOS for Symmetric Multiprocessing (SMP).
302 // <o>Number of processor cores
303 // <i> Sets the number of available processor cores.
305 #define configNUMBER_OF_CORES 1
307 // <q>Use processor core affinity
308 // <i> Enables the control for task to run on specific processor cores.
309 // <i> Task that has no processor affinity set may run on any available core.
311 #define configUSE_CORE_AFFINITY 0
313 // <q>Use passive idle hook
314 // <i> Enable callback function call on each idle task iteration.
315 // <i> Callback function vApplicationPassiveIdleHook implementation is required when idle hook is enabled.
317 #define configUSE_PASSIVE_IDLE_HOOK 0
320 //------------- <<< end of configuration section >>> ---------------------------
322 /* Defines needed by FreeRTOS to implement CMSIS RTOS2 API. Do not change! */
323 #define configCPU_CLOCK_HZ (SystemCoreClock)
324 #define configUSE_PREEMPTION 1
325 #define configUSE_TIMERS 1
326 #define configUSE_MUTEXES 1
327 #define configUSE_RECURSIVE_MUTEXES 1
328 #define configUSE_COUNTING_SEMAPHORES 1
329 #define configUSE_TASK_NOTIFICATIONS 1
330 #define configUSE_TRACE_FACILITY 1
331 #define configUSE_16_BIT_TICKS 0
332 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
333 #define configMAX_PRIORITIES 56
334 #define configKERNEL_INTERRUPT_PRIORITY 255
336 /* Defines that include FreeRTOS functions which implement CMSIS RTOS2 API. Do not change! */
337 #define INCLUDE_xEventGroupSetBitsFromISR 1
338 #define INCLUDE_xSemaphoreGetMutexHolder 1
339 #define INCLUDE_vTaskDelay 1
340 #define INCLUDE_xTaskDelayUntil 1
341 #define INCLUDE_vTaskDelete 1
342 #define INCLUDE_xTaskGetCurrentTaskHandle 1
343 #define INCLUDE_xTaskGetSchedulerState 1
344 #define INCLUDE_uxTaskGetStackHighWaterMark 1
345 #define INCLUDE_uxTaskPriorityGet 1
346 #define INCLUDE_vTaskPrioritySet 1
347 #define INCLUDE_eTaskGetState 1
348 #define INCLUDE_vTaskSuspend 1
349 #define INCLUDE_xTaskAbortDelay 1
350 #define INCLUDE_xTimerPendFunctionCall 1
352 #if (__ARM_ARCH_7A__ == 1U)
353 /* Cortex-A specifics */
356 /* Maximum API call interrupt priority:
357 - Interrupts assigned a priority at or below this priority can call interrupt safe FreeRTOS API function, and will nest.
358 - Interrupts assigned a priority above this priority will not be effected by RTOS critical sections, and will nest,
359 but cannot call any FreeRTOS API functions.
360 - Use configMAX_SYSCALL_INTERRUPT_PRIORITY to set this define as they are essentially the same.
362 #define configMAX_API_CALL_INTERRUPT_PRIORITY configMAX_SYSCALL_INTERRUPT_PRIORITY
364 /* Map the FreeRTOS port timer configuration functions to their implementations */
365 #define configSETUP_TICK_INTERRUPT() \
366 OS_Tick_Setup (configTICK_RATE_HZ, FreeRTOS_Tick_Handler); \
369 #define configCLEAR_TICK_INTERRUPT() \
370 OS_Tick_AcknowledgeIRQ()
372 /* Cortex-M specifics */
373 /* Map the FreeRTOS port interrupt handlers to their CMSIS standard names. */
374 #define xPortPendSVHandler PendSV_Handler
375 #define vPortSVCHandler SVC_Handler
377 /* Ensure Cortex-M port compatibility. */
378 #define SysTick_Handler xPortSysTickHandler
380 #if (defined(__ARMCC_VERSION) || defined(__GNUC__) || defined(__ICCARM__))
381 /* Include debug event definitions */
382 #include "freertos_evr.h"
386 #endif /* FREERTOS_CONFIG_H */