|
1 | 1 | /* -------------------------------------------------------------------------- |
2 | | - * Copyright (c) 2013-2019 Arm Limited. All rights reserved. |
| 2 | + * Copyright (c) 2013-2020 Arm Limited. All rights reserved. |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: Apache-2.0 |
5 | 5 | * |
|
28 | 28 |
|
29 | 29 | #include "FreeRTOS.h" // ARM.FreeRTOS::RTOS:Core |
30 | 30 |
|
| 31 | +#if defined(_RTE_) |
31 | 32 | #include "RTE_Components.h" // Component selection |
32 | 33 | #include CMSIS_device_header |
33 | 34 |
|
34 | 35 | /* Configuration and component setup check */ |
35 | 36 | #if defined(RTE_Compiler_EventRecorder) |
36 | | - #define USE_TRACE_EVENT_RECORDER |
| 37 | + #if !defined(EVR_FREERTOS_DISABLE) |
| 38 | + #define USE_TRACE_EVENT_RECORDER |
| 39 | + /* |
| 40 | + FreeRTOS provides functions and hooks to support execution tracing. This |
| 41 | + functionality is only enabled if configUSE_TRACE_FACILITY == 1. |
| 42 | + Set #define configUSE_TRACE_FACILITY 1 in FreeRTOSConfig.h to enable trace events. |
| 43 | + */ |
| 44 | + #if (configUSE_TRACE_FACILITY == 0) |
| 45 | + #error "Definition configUSE_TRACE_FACILITY must equal 1 to enable FreeRTOS trace events." |
| 46 | + #endif |
| 47 | + #endif |
37 | 48 | #endif |
38 | 49 |
|
39 | 50 | #if defined(RTE_RTOS_FreeRTOS_HEAP_1) |
|
43 | 54 | #if defined(RTE_RTOS_FreeRTOS_HEAP_5) |
44 | 55 | #define USE_FreeRTOS_HEAP_5 |
45 | 56 | #endif |
| 57 | +#endif /* _RTE_ */ |
46 | 58 |
|
47 | | -/* Check FreeRTOSConfig.h include definitions. |
48 | | - Note: CMSIS-RTOS API requires functions included by using following definitions. |
49 | | - In case if certain API function is not used compiler will optimize it away. |
| 59 | +/* |
| 60 | + CMSIS-RTOS2 FreeRTOS image size optimization definitions. |
| 61 | +
|
| 62 | + Note: Definitions configUSE_OS2 can be used to optimize FreeRTOS image size when |
| 63 | + certain functionality is not required when using CMSIS-RTOS2 API. |
| 64 | + In general optimization decisions are left to the tool chain but in cases |
| 65 | + when coding style prevents it to optimize the code following optional |
| 66 | + definitions can be used. |
| 67 | +*/ |
| 68 | + |
| 69 | +/* |
| 70 | + Option to exclude CMSIS-RTOS2 functions osThreadSuspend and osThreadResume from |
| 71 | + the application image. |
| 72 | +*/ |
| 73 | +#ifndef configUSE_OS2_THREAD_SUSPEND_RESUME |
| 74 | +#define configUSE_OS2_THREAD_SUSPEND_RESUME 1 |
| 75 | +#endif |
| 76 | + |
| 77 | +/* |
| 78 | + Option to exclude CMSIS-RTOS2 function osThreadEnumerate from the application image. |
| 79 | +*/ |
| 80 | +#ifndef configUSE_OS2_THREAD_ENUMERATE |
| 81 | +#define configUSE_OS2_THREAD_ENUMERATE 1 |
| 82 | +#endif |
| 83 | + |
| 84 | +/* |
| 85 | + Option to disable CMSIS-RTOS2 function osEventFlagsSet and osEventFlagsClear |
| 86 | + operation from ISR. |
| 87 | +*/ |
| 88 | +#ifndef configUSE_OS2_EVENTFLAGS_FROM_ISR |
| 89 | +#define configUSE_OS2_EVENTFLAGS_FROM_ISR 1 |
| 90 | +#endif |
| 91 | + |
| 92 | +/* |
| 93 | + Option to exclude CMSIS-RTOS2 Thread Flags API functions from the application image. |
| 94 | +*/ |
| 95 | +#ifndef configUSE_OS2_THREAD_FLAGS |
| 96 | +#define configUSE_OS2_THREAD_FLAGS configUSE_TASK_NOTIFICATIONS |
| 97 | +#endif |
| 98 | + |
| 99 | +/* |
| 100 | + Option to exclude CMSIS-RTOS2 Timer API functions from the application image. |
| 101 | +*/ |
| 102 | +#ifndef configUSE_OS2_TIMER |
| 103 | +#define configUSE_OS2_TIMER configUSE_TIMERS |
| 104 | +#endif |
| 105 | + |
| 106 | +/* |
| 107 | + Option to exclude CMSIS-RTOS2 Mutex API functions from the application image. |
| 108 | +*/ |
| 109 | +#ifndef configUSE_OS2_MUTEX |
| 110 | +#define configUSE_OS2_MUTEX configUSE_MUTEXES |
| 111 | +#endif |
| 112 | + |
| 113 | + |
| 114 | +/* |
| 115 | + CMSIS-RTOS2 FreeRTOS configuration check (FreeRTOSConfig.h). |
| 116 | +
|
| 117 | + Note: CMSIS-RTOS API requires functions included by using following definitions. |
| 118 | + In case if certain API function is not used compiler will optimize it away. |
50 | 119 | */ |
51 | 120 | #if (INCLUDE_xSemaphoreGetMutexHolder == 0) |
52 | | - #error "Definition INCLUDE_xSemaphoreGetMutexHolder must be non-zero to implement Mutex Management API." |
| 121 | + /* |
| 122 | + CMSIS-RTOS2 function osMutexGetOwner uses FreeRTOS function xSemaphoreGetMutexHolder. In case if |
| 123 | + osMutexGetOwner is not used in the application image, compiler will optimize it away. |
| 124 | + Set #define INCLUDE_xSemaphoreGetMutexHolder 1 to fix this error. |
| 125 | + */ |
| 126 | + #error "Definition INCLUDE_xSemaphoreGetMutexHolder must equal 1 to implement Mutex Management API." |
53 | 127 | #endif |
54 | 128 | #if (INCLUDE_vTaskDelay == 0) |
55 | | - #error "Definition INCLUDE_vTaskDelay must be non-zero to implement Generic Wait Functions API." |
| 129 | + /* |
| 130 | + CMSIS-RTOS2 function osDelay uses FreeRTOS function vTaskDelay. In case if |
| 131 | + osDelay is not used in the application image, compiler will optimize it away. |
| 132 | + Set #define INCLUDE_vTaskDelay 1 to fix this error. |
| 133 | + */ |
| 134 | + #error "Definition INCLUDE_vTaskDelay must equal 1 to implement Generic Wait Functions API." |
56 | 135 | #endif |
57 | 136 | #if (INCLUDE_vTaskDelayUntil == 0) |
58 | | - #error "Definition INCLUDE_vTaskDelayUntil must be non-zero to implement Generic Wait Functions API." |
| 137 | + /* |
| 138 | + CMSIS-RTOS2 function osDelayUntil uses FreeRTOS function vTaskDelayUntil. In case if |
| 139 | + osDelayUntil is not used in the application image, compiler will optimize it away. |
| 140 | + Set #define INCLUDE_vTaskDelayUntil 1 to fix this error. |
| 141 | + */ |
| 142 | + #error "Definition INCLUDE_vTaskDelayUntil must equal 1 to implement Generic Wait Functions API." |
59 | 143 | #endif |
60 | 144 | #if (INCLUDE_vTaskDelete == 0) |
61 | | - #error "Definition INCLUDE_vTaskDelete must be non-zero to implement Thread Management API." |
| 145 | + /* |
| 146 | + CMSIS-RTOS2 function osThreadTerminate and osThreadExit uses FreeRTOS function |
| 147 | + vTaskDelete. In case if they are not used in the application image, compiler |
| 148 | + will optimize them away. |
| 149 | + Set #define INCLUDE_vTaskDelete 1 to fix this error. |
| 150 | + */ |
| 151 | + #error "Definition INCLUDE_vTaskDelete must equal 1 to implement Thread Management API." |
62 | 152 | #endif |
63 | 153 | #if (INCLUDE_xTaskGetCurrentTaskHandle == 0) |
64 | | - #error "Definition INCLUDE_xTaskGetCurrentTaskHandle must be non-zero to implement Thread Management API." |
| 154 | + /* |
| 155 | + CMSIS-RTOS2 API uses FreeRTOS function xTaskGetCurrentTaskHandle to implement |
| 156 | + functions osThreadGetId, osThreadFlagsClear and osThreadFlagsGet. In case if these |
| 157 | + functions are not used in the application image, compiler will optimize them away. |
| 158 | + Set #define INCLUDE_xTaskGetCurrentTaskHandle 1 to fix this error. |
| 159 | + */ |
| 160 | + #error "Definition INCLUDE_xTaskGetCurrentTaskHandle must equal 1 to implement Thread Management API." |
65 | 161 | #endif |
66 | 162 | #if (INCLUDE_xTaskGetSchedulerState == 0) |
67 | | - #error "Definition INCLUDE_xTaskGetSchedulerState must be non-zero to implement Kernel Information and Control API." |
| 163 | + /* |
| 164 | + CMSIS-RTOS2 API uses FreeRTOS function xTaskGetSchedulerState to implement Kernel |
| 165 | + tick handling and therefore it is vital that xTaskGetSchedulerState is included into |
| 166 | + the application image. |
| 167 | + Set #define INCLUDE_xTaskGetSchedulerState 1 to fix this error. |
| 168 | + */ |
| 169 | + #error "Definition INCLUDE_xTaskGetSchedulerState must equal 1 to implement Kernel Information and Control API." |
68 | 170 | #endif |
69 | 171 | #if (INCLUDE_uxTaskGetStackHighWaterMark == 0) |
70 | | - #error "Definition INCLUDE_uxTaskGetStackHighWaterMark must be non-zero to implement Thread Management API." |
| 172 | + /* |
| 173 | + CMSIS-RTOS2 function osThreadGetStackSpace uses FreeRTOS function uxTaskGetStackHighWaterMark. |
| 174 | + In case if osThreadGetStackSpace is not used in the application image, compiler will |
| 175 | + optimize it away. |
| 176 | + Set #define INCLUDE_uxTaskGetStackHighWaterMark 1 to fix this error. |
| 177 | + */ |
| 178 | + #error "Definition INCLUDE_uxTaskGetStackHighWaterMark must equal 1 to implement Thread Management API." |
71 | 179 | #endif |
72 | 180 | #if (INCLUDE_uxTaskPriorityGet == 0) |
73 | | - #error "Definition INCLUDE_uxTaskPriorityGet must be non-zero to implement Thread Management API." |
| 181 | + /* |
| 182 | + CMSIS-RTOS2 function osThreadGetPriority uses FreeRTOS function uxTaskPriorityGet. In case if |
| 183 | + osThreadGetPriority is not used in the application image, compiler will optimize it away. |
| 184 | + Set #define INCLUDE_uxTaskPriorityGet 1 to fix this error. |
| 185 | + */ |
| 186 | + #error "Definition INCLUDE_uxTaskPriorityGet must equal 1 to implement Thread Management API." |
74 | 187 | #endif |
75 | 188 | #if (INCLUDE_vTaskPrioritySet == 0) |
76 | | - #error "Definition INCLUDE_vTaskPrioritySet must be non-zero to implement Thread Management API." |
| 189 | + /* |
| 190 | + CMSIS-RTOS2 function osThreadSetPriority uses FreeRTOS function vTaskPrioritySet. In case if |
| 191 | + osThreadSetPriority is not used in the application image, compiler will optimize it away. |
| 192 | + Set #define INCLUDE_vTaskPrioritySet 1 to fix this error. |
| 193 | + */ |
| 194 | + #error "Definition INCLUDE_vTaskPrioritySet must equal 1 to implement Thread Management API." |
77 | 195 | #endif |
78 | 196 | #if (INCLUDE_eTaskGetState == 0) |
79 | | - #error "Definition INCLUDE_eTaskGetState must be non-zero to implement Thread Management API." |
| 197 | + /* |
| 198 | + CMSIS-RTOS2 API uses FreeRTOS function vTaskDelayUntil to implement functions osThreadGetState |
| 199 | + and osThreadTerminate. In case if these functions are not used in the application image, |
| 200 | + compiler will optimize them away. |
| 201 | + Set #define INCLUDE_eTaskGetState 1 to fix this error. |
| 202 | + */ |
| 203 | + #error "Definition INCLUDE_eTaskGetState must equal 1 to implement Thread Management API." |
80 | 204 | #endif |
81 | 205 | #if (INCLUDE_vTaskSuspend == 0) |
82 | | - #error "Definition INCLUDE_vTaskSuspend must be non-zero to implement Kernel Information and Control API." |
| 206 | + /* |
| 207 | + CMSIS-RTOS2 API uses FreeRTOS functions vTaskSuspend and vTaskResume to implement |
| 208 | + functions osThreadSuspend and osThreadResume. In case if these functions are not |
| 209 | + used in the application image, compiler will optimize them away. |
| 210 | + Set #define INCLUDE_vTaskSuspend 1 to fix this error. |
| 211 | +
|
| 212 | + Alternatively, if the application does not use osThreadSuspend and |
| 213 | + osThreadResume they can be excluded from the image code by setting: |
| 214 | + #define configUSE_OS2_THREAD_SUSPEND_RESUME 0 (in FreeRTOSConfig.h) |
| 215 | + */ |
| 216 | + #if (configUSE_OS2_THREAD_SUSPEND_RESUME == 1) |
| 217 | + #error "Definition INCLUDE_vTaskSuspend must equal 1 to implement Kernel Information and Control API." |
| 218 | + #endif |
83 | 219 | #endif |
84 | 220 | #if (INCLUDE_xTimerPendFunctionCall == 0) |
85 | | - #error "Definition INCLUDE_xTimerPendFunctionCall must be non-zero to implement Event Flags API." |
| 221 | + /* |
| 222 | + CMSIS-RTOS2 function osEventFlagsSet and osEventFlagsClear, when called from |
| 223 | + the ISR, call FreeRTOS functions xEventGroupSetBitsFromISR and |
| 224 | + xEventGroupClearBitsFromISR which are only enabled if timers are operational and |
| 225 | + xTimerPendFunctionCall in enabled. |
| 226 | + Set #define INCLUDE_xTimerPendFunctionCall 1 and #define configUSE_TIMERS 1 |
| 227 | + to fix this error. |
| 228 | +
|
| 229 | + Alternatively, if the application does not use osEventFlagsSet and osEventFlagsClear |
| 230 | + from the ISR their operation from ISR can be restricted by setting: |
| 231 | + #define configUSE_OS2_EVENTFLAGS_FROM_ISR 0 (in FreeRTOSConfig.h) |
| 232 | + */ |
| 233 | + #if (configUSE_OS2_EVENTFLAGS_FROM_ISR == 1) |
| 234 | + #error "Definition INCLUDE_xTimerPendFunctionCall must equal 1 to implement Event Flags API." |
| 235 | + #endif |
| 236 | +#endif |
| 237 | + |
| 238 | +#if (configUSE_TIMERS == 0) |
| 239 | + /* |
| 240 | + CMSIS-RTOS2 Timer Management API functions use FreeRTOS timer functions to implement |
| 241 | + timer management. In case if these functions are not used in the application image, |
| 242 | + compiler will optimize them away. |
| 243 | + Set #define configUSE_TIMERS 1 to fix this error. |
| 244 | +
|
| 245 | + Alternatively, if the application does not use timer functions they can be |
| 246 | + excluded from the image code by setting: |
| 247 | + #define configUSE_OS2_TIMER 0 (in FreeRTOSConfig.h) |
| 248 | + */ |
| 249 | + #if (configUSE_OS2_TIMER == 1) |
| 250 | + #error "Definition configUSE_TIMERS must equal 1 to implement Timer Management API." |
| 251 | + #endif |
| 252 | +#endif |
| 253 | + |
| 254 | +#if (configUSE_MUTEXES == 0) |
| 255 | + /* |
| 256 | + CMSIS-RTOS2 Mutex Management API functions use FreeRTOS mutex functions to implement |
| 257 | + mutex management. In case if these functions are not used in the application image, |
| 258 | + compiler will optimize them away. |
| 259 | + Set #define configUSE_MUTEXES 1 to fix this error. |
| 260 | +
|
| 261 | + Alternatively, if the application does not use mutex functions they can be |
| 262 | + excluded from the image code by setting: |
| 263 | + #define configUSE_OS2_MUTEX 0 (in FreeRTOSConfig.h) |
| 264 | + */ |
| 265 | + #if (configUSE_OS2_MUTEX == 1) |
| 266 | + #error "Definition configUSE_MUTEXES must equal 1 to implement Mutex Management API." |
| 267 | + #endif |
| 268 | +#endif |
| 269 | + |
| 270 | +#if (configUSE_COUNTING_SEMAPHORES == 0) |
| 271 | + /* |
| 272 | + CMSIS-RTOS2 Memory Pool functions use FreeRTOS function xSemaphoreCreateCounting |
| 273 | + to implement memory pools. In case if these functions are not used in the application image, |
| 274 | + compiler will optimize them away. |
| 275 | + Set #define configUSE_COUNTING_SEMAPHORES 1 to fix this error. |
| 276 | + */ |
| 277 | + #error "Definition configUSE_COUNTING_SEMAPHORES must equal 1 to implement Memory Pool API." |
| 278 | +#endif |
| 279 | +#if (configUSE_TASK_NOTIFICATIONS == 0) |
| 280 | + /* |
| 281 | + CMSIS-RTOS2 Thread Flags API functions use FreeRTOS Task Notification functions to implement |
| 282 | + thread flag management. In case if these functions are not used in the application image, |
| 283 | + compiler will optimize them away. |
| 284 | + Set #define configUSE_TASK_NOTIFICATIONS 1 to fix this error. |
| 285 | +
|
| 286 | + Alternatively, if the application does not use thread flags functions they can be |
| 287 | + excluded from the image code by setting: |
| 288 | + #define configUSE_OS2_THREAD_FLAGS 0 (in FreeRTOSConfig.h) |
| 289 | + */ |
| 290 | + #if (configUSE_OS2_THREAD_FLAGS == 1) |
| 291 | + #error "Definition configUSE_TASK_NOTIFICATIONS must equal 1 to implement Thread Flags API." |
| 292 | + #endif |
| 293 | +#endif |
| 294 | + |
| 295 | +#if (configUSE_TRACE_FACILITY == 0) |
| 296 | + /* |
| 297 | + CMSIS-RTOS2 function osThreadEnumerate requires FreeRTOS function uxTaskGetSystemState |
| 298 | + which is only enabled if configUSE_TRACE_FACILITY == 1. |
| 299 | + Set #define configUSE_TRACE_FACILITY 1 to fix this error. |
| 300 | +
|
| 301 | + Alternatively, if the application does not use osThreadEnumerate it can be |
| 302 | + excluded from the image code by setting: |
| 303 | + #define configUSE_OS2_THREAD_ENUMERATE 0 (in FreeRTOSConfig.h) |
| 304 | + */ |
| 305 | + #if (configUSE_OS2_THREAD_ENUMERATE == 1) |
| 306 | + #error "Definition configUSE_TRACE_FACILITY must equal 1 to implement osThreadEnumerate." |
| 307 | + #endif |
| 308 | +#endif |
| 309 | + |
| 310 | +#if (configUSE_16_BIT_TICKS == 1) |
| 311 | + /* |
| 312 | + CMSIS-RTOS2 wrapper for FreeRTOS relies on 32-bit tick timer which is also optimal on |
| 313 | + a 32-bit CPU architectures. |
| 314 | + Set #define configUSE_16_BIT_TICKS 0 to fix this error. |
| 315 | + */ |
| 316 | + #error "Definition configUSE_16_BIT_TICKS must be zero to implement CMSIS-RTOS2 API." |
| 317 | +#endif |
| 318 | + |
| 319 | +#if (configMAX_PRIORITIES != 56) |
| 320 | + /* |
| 321 | + CMSIS-RTOS2 defines 56 different priorities (see osPriority_t) and portable CMSIS-RTOS2 |
| 322 | + implementation should implement the same number of priorities. |
| 323 | + Set #define configMAX_PRIORITIES 56 to fix this error. |
| 324 | + */ |
| 325 | + #error "Definition configMAX_PRIORITIES must equal 56 to implement Thread Management API." |
| 326 | +#endif |
| 327 | +#if (configUSE_PORT_OPTIMISED_TASK_SELECTION != 0) |
| 328 | + /* |
| 329 | + CMSIS-RTOS2 requires handling of 56 different priorities (see osPriority_t) while FreeRTOS port |
| 330 | + optimised selection for Cortex core only handles 32 different priorities. |
| 331 | + Set #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 to fix this error. |
| 332 | + */ |
| 333 | + #error "Definition configUSE_PORT_OPTIMISED_TASK_SELECTION must be zero to implement Thread Management API." |
86 | 334 | #endif |
87 | 335 |
|
88 | 336 | #endif /* FREERTOS_OS2_H_ */ |
0 commit comments