1 /*
2  * FreeRTOS Kernel V10.4.3
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * https://www.FreeRTOS.org
23  * https://github.com/FreeRTOS
24  *
25  */
26 
27 #ifndef INC_FREERTOS_H
28 #define INC_FREERTOS_H
29 
30 /*
31  * Include the generic headers required for the FreeRTOS port being used.
32  */
33 #include <stddef.h>
34 
35 /*
36  * If stdint.h cannot be located then:
37  *   + If using GCC ensure the -nostdint options is *not* being used.
38  *   + Ensure the project's include path includes the directory in which your
39  *     compiler stores stdint.h.
40  *   + Set any compiler options necessary for it to support C99, as technically
41  *     stdint.h is only mandatory with C99 (FreeRTOS does not require C99 in any
42  *     other way).
43  *   + The FreeRTOS download includes a simple stdint.h definition that can be
44  *     used in cases where none is provided by the compiler.  The files only
45  *     contains the typedefs required to build FreeRTOS.  Read the instructions
46  *     in FreeRTOS/source/stdint.readme for more information.
47  */
48 #include <stdint.h>     /* READ COMMENT ABOVE. */
49 
50 /* *INDENT-OFF* */
51 #ifdef __cplusplus
52     extern "C" {
53 #endif
54 /* *INDENT-ON* */
55 
56 /* Application specific configuration options. */
57 #include "FreeRTOSConfig.h"
58 
59 /* Basic FreeRTOS definitions. */
60 #include "projdefs.h"
61 
62 /* Definitions specific to the port being used. */
63 #include "portable.h"
64 
65 /* Must be defaulted before configUSE_NEWLIB_REENTRANT is used below. */
66 #ifndef configUSE_NEWLIB_REENTRANT
67     #define configUSE_NEWLIB_REENTRANT    0
68 #endif
69 
70 /* Required if struct _reent is used. */
71 #if ( configUSE_NEWLIB_REENTRANT == 1 )
72     #include <reent.h>
73 #endif
74 
75 /*
76  * Check all the required application specific macros have been defined.
77  * These macros are application specific and (as downloaded) are defined
78  * within FreeRTOSConfig.h.
79  */
80 
81 #ifndef configMINIMAL_STACK_SIZE
82     #error Missing definition:  configMINIMAL_STACK_SIZE must be defined in FreeRTOSConfig.h.  configMINIMAL_STACK_SIZE defines the size (in words) of the stack allocated to the idle task.  Refer to the demo project provided for your port for a suitable value.
83 #endif
84 
85 #ifndef configMAX_PRIORITIES
86     #error Missing definition:  configMAX_PRIORITIES must be defined in FreeRTOSConfig.h.  See the Configuration section of the FreeRTOS API documentation for details.
87 #endif
88 
89 #if configMAX_PRIORITIES < 1
90     #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.
91 #endif
92 
93 #ifndef configUSE_PREEMPTION
94     #error Missing definition:  configUSE_PREEMPTION must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.
95 #endif
96 
97 #ifndef configUSE_IDLE_HOOK
98     #error Missing definition:  configUSE_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.
99 #endif
100 
101 #ifndef configUSE_TICK_HOOK
102     #error Missing definition:  configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.
103 #endif
104 
105 #ifndef configUSE_16_BIT_TICKS
106     #error Missing definition:  configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.
107 #endif
108 
109 #ifndef configUSE_CO_ROUTINES
110     #define configUSE_CO_ROUTINES    0
111 #endif
112 
113 #ifndef INCLUDE_vTaskPrioritySet
114     #define INCLUDE_vTaskPrioritySet    0
115 #endif
116 
117 #ifndef INCLUDE_uxTaskPriorityGet
118     #define INCLUDE_uxTaskPriorityGet    0
119 #endif
120 
121 #ifndef INCLUDE_vTaskDelete
122     #define INCLUDE_vTaskDelete    0
123 #endif
124 
125 #ifndef INCLUDE_vTaskSuspend
126     #define INCLUDE_vTaskSuspend    0
127 #endif
128 
129 #ifdef INCLUDE_xTaskDelayUntil
130     #ifdef INCLUDE_vTaskDelayUntil
131         /* INCLUDE_vTaskDelayUntil was replaced by INCLUDE_xTaskDelayUntil.  Backward
132          * compatibility is maintained if only one or the other is defined, but
133          * there is a conflict if both are defined. */
134         #error INCLUDE_vTaskDelayUntil and INCLUDE_xTaskDelayUntil are both defined.  INCLUDE_vTaskDelayUntil is no longer required and should be removed
135     #endif
136 #endif
137 
138 #ifndef INCLUDE_xTaskDelayUntil
139     #ifdef INCLUDE_vTaskDelayUntil
140         /* If INCLUDE_vTaskDelayUntil is set but INCLUDE_xTaskDelayUntil is not then
141          * the project's FreeRTOSConfig.h probably pre-dates the introduction of
142          * xTaskDelayUntil and setting INCLUDE_xTaskDelayUntil to whatever
143          * INCLUDE_vTaskDelayUntil is set to will ensure backward compatibility.
144          */
145         #define INCLUDE_xTaskDelayUntil INCLUDE_vTaskDelayUntil
146     #endif
147 #endif
148 
149 #ifndef INCLUDE_xTaskDelayUntil
150     #define INCLUDE_xTaskDelayUntil    0
151 #endif
152 
153 #ifndef INCLUDE_vTaskDelay
154     #define INCLUDE_vTaskDelay    0
155 #endif
156 
157 #ifndef INCLUDE_xTaskGetIdleTaskHandle
158     #define INCLUDE_xTaskGetIdleTaskHandle    0
159 #endif
160 
161 #ifndef INCLUDE_xTaskAbortDelay
162     #define INCLUDE_xTaskAbortDelay    0
163 #endif
164 
165 #ifndef INCLUDE_xQueueGetMutexHolder
166     #define INCLUDE_xQueueGetMutexHolder    0
167 #endif
168 
169 #ifndef INCLUDE_xSemaphoreGetMutexHolder
170     #define INCLUDE_xSemaphoreGetMutexHolder    INCLUDE_xQueueGetMutexHolder
171 #endif
172 
173 #ifndef INCLUDE_xTaskGetHandle
174     #define INCLUDE_xTaskGetHandle    0
175 #endif
176 
177 #ifndef INCLUDE_uxTaskGetStackHighWaterMark
178     #define INCLUDE_uxTaskGetStackHighWaterMark    0
179 #endif
180 
181 #ifndef INCLUDE_uxTaskGetStackHighWaterMark2
182     #define INCLUDE_uxTaskGetStackHighWaterMark2    0
183 #endif
184 
185 #ifndef INCLUDE_eTaskGetState
186     #define INCLUDE_eTaskGetState    0
187 #endif
188 
189 #ifndef INCLUDE_xTaskResumeFromISR
190     #define INCLUDE_xTaskResumeFromISR    1
191 #endif
192 
193 #ifndef INCLUDE_xTimerPendFunctionCall
194     #define INCLUDE_xTimerPendFunctionCall    0
195 #endif
196 
197 #ifndef INCLUDE_xTaskGetSchedulerState
198     #define INCLUDE_xTaskGetSchedulerState    0
199 #endif
200 
201 #ifndef INCLUDE_xTaskGetCurrentTaskHandle
202     #define INCLUDE_xTaskGetCurrentTaskHandle    0
203 #endif
204 
205 #if configUSE_CO_ROUTINES != 0
206     #ifndef configMAX_CO_ROUTINE_PRIORITIES
207         #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1.
208     #endif
209 #endif
210 
211 #ifndef configUSE_DAEMON_TASK_STARTUP_HOOK
212     #define configUSE_DAEMON_TASK_STARTUP_HOOK    0
213 #endif
214 
215 #ifndef configUSE_APPLICATION_TASK_TAG
216     #define configUSE_APPLICATION_TASK_TAG    0
217 #endif
218 
219 #ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
220     #define configNUM_THREAD_LOCAL_STORAGE_POINTERS    0
221 #endif
222 
223 #ifndef configUSE_RECURSIVE_MUTEXES
224     #define configUSE_RECURSIVE_MUTEXES    0
225 #endif
226 
227 #ifndef configUSE_MUTEXES
228     #define configUSE_MUTEXES    0
229 #endif
230 
231 #ifndef configUSE_TIMERS
232     #define configUSE_TIMERS    0
233 #endif
234 
235 #ifndef configUSE_COUNTING_SEMAPHORES
236     #define configUSE_COUNTING_SEMAPHORES    0
237 #endif
238 
239 #ifndef configUSE_ALTERNATIVE_API
240     #define configUSE_ALTERNATIVE_API    0
241 #endif
242 
243 #ifndef portCRITICAL_NESTING_IN_TCB
244     #define portCRITICAL_NESTING_IN_TCB    0
245 #endif
246 
247 #ifndef configMAX_TASK_NAME_LEN
248     #define configMAX_TASK_NAME_LEN    16
249 #endif
250 
251 #ifndef configIDLE_SHOULD_YIELD
252     #define configIDLE_SHOULD_YIELD    1
253 #endif
254 
255 #if configMAX_TASK_NAME_LEN < 1
256     #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h
257 #endif
258 
259 #ifndef configASSERT
260     #define configASSERT( x )
261     #define configASSERT_DEFINED    0
262 #else
263     #define configASSERT_DEFINED    1
264 #endif
265 
266 /* configPRECONDITION should be defined as configASSERT.
267  * The CBMC proofs need a way to track assumptions and assertions.
268  * A configPRECONDITION statement should express an implicit invariant or
269  * assumption made.  A configASSERT statement should express an invariant that must
270  * hold explicit before calling the code. */
271 #ifndef configPRECONDITION
272     #define configPRECONDITION( X )    configASSERT( X )
273     #define configPRECONDITION_DEFINED    0
274 #else
275     #define configPRECONDITION_DEFINED    1
276 #endif
277 
278 #ifndef portMEMORY_BARRIER
279     #define portMEMORY_BARRIER()
280 #endif
281 
282 #ifndef portSOFTWARE_BARRIER
283     #define portSOFTWARE_BARRIER()
284 #endif
285 
286 /* The timers module relies on xTaskGetSchedulerState(). */
287 #if configUSE_TIMERS == 1
288 
289     #ifndef configTIMER_TASK_PRIORITY
290         #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined.
291     #endif /* configTIMER_TASK_PRIORITY */
292 
293     #ifndef configTIMER_QUEUE_LENGTH
294         #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined.
295     #endif /* configTIMER_QUEUE_LENGTH */
296 
297     #ifndef configTIMER_TASK_STACK_DEPTH
298         #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined.
299     #endif /* configTIMER_TASK_STACK_DEPTH */
300 
301 #endif /* configUSE_TIMERS */
302 
303 #ifndef portSET_INTERRUPT_MASK_FROM_ISR
304     #define portSET_INTERRUPT_MASK_FROM_ISR()    0
305 #endif
306 
307 #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR
308     #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue )    ( void ) uxSavedStatusValue
309 #endif
310 
311 #ifndef portCLEAN_UP_TCB
312     #define portCLEAN_UP_TCB( pxTCB )    ( void ) pxTCB
313 #endif
314 
315 #ifndef portPRE_TASK_DELETE_HOOK
316     #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending )
317 #endif
318 
319 #ifndef portSETUP_TCB
320     #define portSETUP_TCB( pxTCB )    ( void ) pxTCB
321 #endif
322 
323 #ifndef configQUEUE_REGISTRY_SIZE
324     #define configQUEUE_REGISTRY_SIZE    0U
325 #endif
326 
327 #if ( configQUEUE_REGISTRY_SIZE < 1 )
328     #define vQueueAddToRegistry( xQueue, pcName )
329     #define vQueueUnregisterQueue( xQueue )
330     #define pcQueueGetName( xQueue )
331 #endif
332 
333 #ifndef portPOINTER_SIZE_TYPE
334     #define portPOINTER_SIZE_TYPE    uint32_t
335 #endif
336 
337 /* Remove any unused trace macros. */
338 #ifndef traceSTART
339 
340 /* Used to perform any necessary initialisation - for example, open a file
341  * into which trace is to be written. */
342     #define traceSTART()
343 #endif
344 
345 #ifndef traceEND
346 
347 /* Use to close a trace, for example close a file into which trace has been
348  * written. */
349     #define traceEND()
350 #endif
351 
352 #ifndef traceTASK_SWITCHED_IN
353 
354 /* Called after a task has been selected to run.  pxCurrentTCB holds a pointer
355  * to the task control block of the selected task. */
356     #define traceTASK_SWITCHED_IN()
357 #endif
358 
359 #ifndef traceINCREASE_TICK_COUNT
360 
361 /* Called before stepping the tick count after waking from tickless idle
362  * sleep. */
363     #define traceINCREASE_TICK_COUNT( x )
364 #endif
365 
366 #ifndef traceLOW_POWER_IDLE_BEGIN
367     /* Called immediately before entering tickless idle. */
368     #define traceLOW_POWER_IDLE_BEGIN()
369 #endif
370 
371 #ifndef traceLOW_POWER_IDLE_END
372     /* Called when returning to the Idle task after a tickless idle. */
373     #define traceLOW_POWER_IDLE_END()
374 #endif
375 
376 #ifndef traceTASK_SWITCHED_OUT
377 
378 /* Called before a task has been selected to run.  pxCurrentTCB holds a pointer
379  * to the task control block of the task being switched out. */
380     #define traceTASK_SWITCHED_OUT()
381 #endif
382 
383 #ifndef traceTASK_PRIORITY_INHERIT
384 
385 /* Called when a task attempts to take a mutex that is already held by a
386  * lower priority task.  pxTCBOfMutexHolder is a pointer to the TCB of the task
387  * that holds the mutex.  uxInheritedPriority is the priority the mutex holder
388  * will inherit (the priority of the task that is attempting to obtain the
389  * muted. */
390     #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority )
391 #endif
392 
393 #ifndef traceTASK_PRIORITY_DISINHERIT
394 
395 /* Called when a task releases a mutex, the holding of which had resulted in
396  * the task inheriting the priority of a higher priority task.
397  * pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the
398  * mutex.  uxOriginalPriority is the task's configured (base) priority. */
399     #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority )
400 #endif
401 
402 #ifndef traceBLOCKING_ON_QUEUE_RECEIVE
403 
404 /* Task is about to block because it cannot read from a
405  * queue/mutex/semaphore.  pxQueue is a pointer to the queue/mutex/semaphore
406  * upon which the read was attempted.  pxCurrentTCB points to the TCB of the
407  * task that attempted the read. */
408     #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )
409 #endif
410 
411 #ifndef traceBLOCKING_ON_QUEUE_PEEK
412 
413 /* Task is about to block because it cannot read from a
414  * queue/mutex/semaphore.  pxQueue is a pointer to the queue/mutex/semaphore
415  * upon which the read was attempted.  pxCurrentTCB points to the TCB of the
416  * task that attempted the read. */
417     #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue )
418 #endif
419 
420 #ifndef traceBLOCKING_ON_QUEUE_SEND
421 
422 /* Task is about to block because it cannot write to a
423  * queue/mutex/semaphore.  pxQueue is a pointer to the queue/mutex/semaphore
424  * upon which the write was attempted.  pxCurrentTCB points to the TCB of the
425  * task that attempted the write. */
426     #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )
427 #endif
428 
429 #ifndef configCHECK_FOR_STACK_OVERFLOW
430     #define configCHECK_FOR_STACK_OVERFLOW    0
431 #endif
432 
433 #ifndef configRECORD_STACK_HIGH_ADDRESS
434     #define configRECORD_STACK_HIGH_ADDRESS    0
435 #endif
436 
437 #ifndef configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H
438     #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H    0
439 #endif
440 
441 /* The following event macros are embedded in the kernel API calls. */
442 
443 #ifndef traceMOVED_TASK_TO_READY_STATE
444     #define traceMOVED_TASK_TO_READY_STATE( pxTCB )
445 #endif
446 
447 #ifndef tracePOST_MOVED_TASK_TO_READY_STATE
448     #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
449 #endif
450 
451 #ifndef traceQUEUE_CREATE
452     #define traceQUEUE_CREATE( pxNewQueue )
453 #endif
454 
455 #ifndef traceQUEUE_CREATE_FAILED
456     #define traceQUEUE_CREATE_FAILED( ucQueueType )
457 #endif
458 
459 #ifndef traceCREATE_MUTEX
460     #define traceCREATE_MUTEX( pxNewQueue )
461 #endif
462 
463 #ifndef traceCREATE_MUTEX_FAILED
464     #define traceCREATE_MUTEX_FAILED()
465 #endif
466 
467 #ifndef traceGIVE_MUTEX_RECURSIVE
468     #define traceGIVE_MUTEX_RECURSIVE( pxMutex )
469 #endif
470 
471 #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED
472     #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex )
473 #endif
474 
475 #ifndef traceTAKE_MUTEX_RECURSIVE
476     #define traceTAKE_MUTEX_RECURSIVE( pxMutex )
477 #endif
478 
479 #ifndef traceTAKE_MUTEX_RECURSIVE_FAILED
480     #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex )
481 #endif
482 
483 #ifndef traceCREATE_COUNTING_SEMAPHORE
484     #define traceCREATE_COUNTING_SEMAPHORE()
485 #endif
486 
487 #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED
488     #define traceCREATE_COUNTING_SEMAPHORE_FAILED()
489 #endif
490 
491 #ifndef traceQUEUE_SET_SEND
492     #define traceQUEUE_SET_SEND    traceQUEUE_SEND
493 #endif
494 
495 #ifdef ESP_PLATFORM
496 #ifndef traceQUEUE_SEMAPHORE_RECEIVE
497     #define traceQUEUE_SEMAPHORE_RECEIVE( pxQueue )
498 #endif
499 #endif // ESP_PLATFORM
500 
501 #ifndef traceQUEUE_SEND
502     #define traceQUEUE_SEND( pxQueue )
503 #endif
504 
505 #ifndef traceQUEUE_SEND_FAILED
506     #define traceQUEUE_SEND_FAILED( pxQueue )
507 #endif
508 
509 #ifndef traceQUEUE_RECEIVE
510     #define traceQUEUE_RECEIVE( pxQueue )
511 #endif
512 
513 #ifndef traceQUEUE_PEEK
514     #define traceQUEUE_PEEK( pxQueue )
515 #endif
516 
517 #ifndef traceQUEUE_PEEK_FAILED
518     #define traceQUEUE_PEEK_FAILED( pxQueue )
519 #endif
520 
521 #ifndef traceQUEUE_PEEK_FROM_ISR
522     #define traceQUEUE_PEEK_FROM_ISR( pxQueue )
523 #endif
524 
525 #ifndef traceQUEUE_RECEIVE_FAILED
526     #define traceQUEUE_RECEIVE_FAILED( pxQueue )
527 #endif
528 
529 #ifndef traceQUEUE_SEND_FROM_ISR
530     #define traceQUEUE_SEND_FROM_ISR( pxQueue )
531 #endif
532 
533 #ifndef traceQUEUE_SEND_FROM_ISR_FAILED
534     #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )
535 #endif
536 
537 #ifndef traceQUEUE_RECEIVE_FROM_ISR
538     #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )
539 #endif
540 
541 #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED
542     #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )
543 #endif
544 
545 #ifndef traceQUEUE_PEEK_FROM_ISR_FAILED
546     #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue )
547 #endif
548 
549 #ifndef traceQUEUE_DELETE
550     #define traceQUEUE_DELETE( pxQueue )
551 #endif
552 
553 #ifdef ESP_PLATFORM
554 #ifndef traceQUEUE_GIVE_FROM_ISR
555     #define traceQUEUE_GIVE_FROM_ISR( pxQueue )
556 #endif
557 
558 #ifndef traceQUEUE_GIVE_FROM_ISR_FAILED
559     #define traceQUEUE_GIVE_FROM_ISR_FAILED( pxQueue )
560 #endif
561 #endif // ESP_PLATFORM
562 
563 #ifndef traceTASK_CREATE
564     #define traceTASK_CREATE( pxNewTCB )
565 #endif
566 
567 #ifndef traceTASK_CREATE_FAILED
568     #define traceTASK_CREATE_FAILED()
569 #endif
570 
571 #ifndef traceTASK_DELETE
572     #define traceTASK_DELETE( pxTaskToDelete )
573 #endif
574 
575 #ifndef traceTASK_DELAY_UNTIL
576     #define traceTASK_DELAY_UNTIL( x )
577 #endif
578 
579 #ifndef traceTASK_DELAY
580     #define traceTASK_DELAY()
581 #endif
582 
583 #ifndef traceTASK_PRIORITY_SET
584     #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority )
585 #endif
586 
587 #ifndef traceTASK_SUSPEND
588     #define traceTASK_SUSPEND( pxTaskToSuspend )
589 #endif
590 
591 #ifndef traceTASK_RESUME
592     #define traceTASK_RESUME( pxTaskToResume )
593 #endif
594 
595 #ifndef traceTASK_RESUME_FROM_ISR
596     #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )
597 #endif
598 
599 #ifndef traceTASK_INCREMENT_TICK
600     #define traceTASK_INCREMENT_TICK( xTickCount )
601 #endif
602 
603 #ifndef traceTIMER_CREATE
604     #define traceTIMER_CREATE( pxNewTimer )
605 #endif
606 
607 #ifndef traceTIMER_CREATE_FAILED
608     #define traceTIMER_CREATE_FAILED()
609 #endif
610 
611 #ifndef traceTIMER_COMMAND_SEND
612     #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn )
613 #endif
614 
615 #ifndef traceTIMER_EXPIRED
616     #define traceTIMER_EXPIRED( pxTimer )
617 #endif
618 
619 #ifndef traceTIMER_COMMAND_RECEIVED
620     #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue )
621 #endif
622 
623 #ifndef traceMALLOC
624     #define traceMALLOC( pvAddress, uiSize )
625 #endif
626 
627 #ifndef traceFREE
628     #define traceFREE( pvAddress, uiSize )
629 #endif
630 
631 #ifndef traceEVENT_GROUP_CREATE
632     #define traceEVENT_GROUP_CREATE( xEventGroup )
633 #endif
634 
635 #ifndef traceEVENT_GROUP_CREATE_FAILED
636     #define traceEVENT_GROUP_CREATE_FAILED()
637 #endif
638 
639 #ifndef traceEVENT_GROUP_SYNC_BLOCK
640     #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor )
641 #endif
642 
643 #ifndef traceEVENT_GROUP_SYNC_END
644     #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred )    ( void ) xTimeoutOccurred
645 #endif
646 
647 #ifndef traceEVENT_GROUP_WAIT_BITS_BLOCK
648     #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor )
649 #endif
650 
651 #ifndef traceEVENT_GROUP_WAIT_BITS_END
652     #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred )    ( void ) xTimeoutOccurred
653 #endif
654 
655 #ifndef traceEVENT_GROUP_CLEAR_BITS
656     #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear )
657 #endif
658 
659 #ifndef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR
660     #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear )
661 #endif
662 
663 #ifndef traceEVENT_GROUP_SET_BITS
664     #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet )
665 #endif
666 
667 #ifndef traceEVENT_GROUP_SET_BITS_FROM_ISR
668     #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet )
669 #endif
670 
671 #ifndef traceEVENT_GROUP_DELETE
672     #define traceEVENT_GROUP_DELETE( xEventGroup )
673 #endif
674 
675 #ifndef tracePEND_FUNC_CALL
676     #define tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, ret )
677 #endif
678 
679 #ifndef tracePEND_FUNC_CALL_FROM_ISR
680     #define tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, ret )
681 #endif
682 
683 #ifndef traceQUEUE_REGISTRY_ADD
684     #define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName )
685 #endif
686 
687 #ifndef traceTASK_NOTIFY_TAKE_BLOCK
688     #define traceTASK_NOTIFY_TAKE_BLOCK( uxIndexToWait )
689 #endif
690 
691 #ifndef traceTASK_NOTIFY_TAKE
692     #define traceTASK_NOTIFY_TAKE( uxIndexToWait )
693 #endif
694 
695 #ifndef traceTASK_NOTIFY_WAIT_BLOCK
696     #define traceTASK_NOTIFY_WAIT_BLOCK( uxIndexToWait )
697 #endif
698 
699 #ifndef traceTASK_NOTIFY_WAIT
700     #define traceTASK_NOTIFY_WAIT( uxIndexToWait )
701 #endif
702 
703 #ifndef traceTASK_NOTIFY
704     #define traceTASK_NOTIFY( uxIndexToNotify )
705 #endif
706 
707 #ifndef traceTASK_NOTIFY_FROM_ISR
708     #define traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify )
709 #endif
710 
711 #ifndef traceTASK_NOTIFY_GIVE_FROM_ISR
712     #define traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify )
713 #endif
714 
715 #ifndef traceSTREAM_BUFFER_CREATE_FAILED
716     #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
717 #endif
718 
719 #ifndef traceSTREAM_BUFFER_CREATE_STATIC_FAILED
720     #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer )
721 #endif
722 
723 #ifndef traceSTREAM_BUFFER_CREATE
724     #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer )
725 #endif
726 
727 #ifndef traceSTREAM_BUFFER_DELETE
728     #define traceSTREAM_BUFFER_DELETE( xStreamBuffer )
729 #endif
730 
731 #ifndef traceSTREAM_BUFFER_RESET
732     #define traceSTREAM_BUFFER_RESET( xStreamBuffer )
733 #endif
734 
735 #ifndef traceBLOCKING_ON_STREAM_BUFFER_SEND
736     #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer )
737 #endif
738 
739 #ifndef traceSTREAM_BUFFER_SEND
740     #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent )
741 #endif
742 
743 #ifndef traceSTREAM_BUFFER_SEND_FAILED
744     #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer )
745 #endif
746 
747 #ifndef traceSTREAM_BUFFER_SEND_FROM_ISR
748     #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent )
749 #endif
750 
751 #ifndef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE
752     #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer )
753 #endif
754 
755 #ifndef traceSTREAM_BUFFER_RECEIVE
756     #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength )
757 #endif
758 
759 #ifndef traceSTREAM_BUFFER_RECEIVE_FAILED
760     #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer )
761 #endif
762 
763 #ifndef traceSTREAM_BUFFER_RECEIVE_FROM_ISR
764     #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength )
765 #endif
766 
767 #ifdef ESP_PLATFORM
768 #ifndef traceISR_EXIT_TO_SCHEDULER
769     #define traceISR_EXIT_TO_SCHEDULER()
770 #endif
771 
772 #ifndef traceISR_EXIT
773     #define traceISR_EXIT()
774 #endif
775 
776 #ifndef traceISR_ENTER
777     #define traceISR_ENTER(_n_)
778 #endif
779 #endif // ESP_PLATFORM
780 
781 #ifndef configGENERATE_RUN_TIME_STATS
782     #define configGENERATE_RUN_TIME_STATS    0
783 #endif
784 
785 #if ( configGENERATE_RUN_TIME_STATS == 1 )
786 
787     #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
788         #error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined.  portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base.
789     #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */
790 
791     #ifndef portGET_RUN_TIME_COUNTER_VALUE
792         #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE
793             #error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined.  See the examples provided and the FreeRTOS web site for more information.
794         #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */
795     #endif /* portGET_RUN_TIME_COUNTER_VALUE */
796 
797 #endif /* configGENERATE_RUN_TIME_STATS */
798 
799 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
800     #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
801 #endif
802 
803 #ifndef configUSE_MALLOC_FAILED_HOOK
804     #define configUSE_MALLOC_FAILED_HOOK    0
805 #endif
806 
807 #ifndef portPRIVILEGE_BIT
808     #define portPRIVILEGE_BIT    ( ( UBaseType_t ) 0x00 )
809 #endif
810 
811 #ifndef portYIELD_WITHIN_API
812     #define portYIELD_WITHIN_API    portYIELD
813 #endif
814 
815 #ifndef portSUPPRESS_TICKS_AND_SLEEP
816     #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime )
817 #endif
818 
819 #ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP
820     #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP    2
821 #endif
822 
823 #if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2
824     #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2
825 #endif
826 
827 #ifndef configUSE_TICKLESS_IDLE
828     #define configUSE_TICKLESS_IDLE    0
829 #endif
830 
831 #ifndef configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING
832     #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x )
833 #endif
834 
835 #ifndef configPRE_SLEEP_PROCESSING
836     #define configPRE_SLEEP_PROCESSING( x )
837 #endif
838 
839 #ifndef configPOST_SLEEP_PROCESSING
840     #define configPOST_SLEEP_PROCESSING( x )
841 #endif
842 
843 #ifndef configUSE_QUEUE_SETS
844     #define configUSE_QUEUE_SETS    0
845 #endif
846 
847 #ifndef portTASK_USES_FLOATING_POINT
848     #define portTASK_USES_FLOATING_POINT()
849 #endif
850 
851 #ifndef portALLOCATE_SECURE_CONTEXT
852     #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize )
853 #endif
854 
855 #ifndef portDONT_DISCARD
856     #define portDONT_DISCARD
857 #endif
858 
859 #ifndef configUSE_TIME_SLICING
860     #define configUSE_TIME_SLICING    1
861 #endif
862 
863 #ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS
864     #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS    0
865 #endif
866 
867 #ifndef configUSE_STATS_FORMATTING_FUNCTIONS
868     #define configUSE_STATS_FORMATTING_FUNCTIONS    0
869 #endif
870 
871 #ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID
872     #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID()
873 #endif
874 
875 #ifndef configUSE_TRACE_FACILITY
876     #define configUSE_TRACE_FACILITY    0
877 #endif
878 
879 #ifndef mtCOVERAGE_TEST_MARKER
880     #define mtCOVERAGE_TEST_MARKER()
881 #endif
882 
883 #ifndef mtCOVERAGE_TEST_DELAY
884     #define mtCOVERAGE_TEST_DELAY()
885 #endif
886 
887 #ifndef portASSERT_IF_IN_ISR
888     #define portASSERT_IF_IN_ISR()
889 #endif
890 
891 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
892     #define configUSE_PORT_OPTIMISED_TASK_SELECTION    0
893 #endif
894 
895 #ifndef configAPPLICATION_ALLOCATED_HEAP
896     #define configAPPLICATION_ALLOCATED_HEAP    0
897 #endif
898 
899 #ifndef configUSE_TASK_NOTIFICATIONS
900     #define configUSE_TASK_NOTIFICATIONS    1
901 #endif
902 
903 #ifndef configTASK_NOTIFICATION_ARRAY_ENTRIES
904     #define configTASK_NOTIFICATION_ARRAY_ENTRIES    1
905 #endif
906 
907 #if configTASK_NOTIFICATION_ARRAY_ENTRIES < 1
908     #error configTASK_NOTIFICATION_ARRAY_ENTRIES must be at least 1
909 #endif
910 
911 #ifndef configUSE_POSIX_ERRNO
912     #define configUSE_POSIX_ERRNO    0
913 #endif
914 
915 #ifndef portTICK_TYPE_IS_ATOMIC
916     #define portTICK_TYPE_IS_ATOMIC    0
917 #endif
918 
919 #ifndef configSUPPORT_STATIC_ALLOCATION
920     /* Defaults to 0 for backward compatibility. */
921     #define configSUPPORT_STATIC_ALLOCATION    0
922 #endif
923 
924 #ifndef configSUPPORT_DYNAMIC_ALLOCATION
925     /* Defaults to 1 for backward compatibility. */
926     #define configSUPPORT_DYNAMIC_ALLOCATION    1
927 #endif
928 
929 #ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP
930     /* Defaults to 0 for backward compatibility. */
931     #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP   0
932 #endif
933 
934 #ifndef configSTACK_DEPTH_TYPE
935 
936 /* Defaults to uint16_t for backward compatibility, but can be overridden
937  * in FreeRTOSConfig.h if uint16_t is too restrictive. */
938     #define configSTACK_DEPTH_TYPE    uint16_t
939 #endif
940 
941 #ifndef configMESSAGE_BUFFER_LENGTH_TYPE
942 
943 /* Defaults to size_t for backward compatibility, but can be overridden
944  * in FreeRTOSConfig.h if lengths will always be less than the number of bytes
945  * in a size_t. */
946     #define configMESSAGE_BUFFER_LENGTH_TYPE    size_t
947 #endif
948 
949 /* Sanity check the configuration. */
950 #if ( configUSE_TICKLESS_IDLE != 0 )
951     #if ( INCLUDE_vTaskSuspend != 1 )
952         #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0
953     #endif /* INCLUDE_vTaskSuspend */
954 #endif /* configUSE_TICKLESS_IDLE */
955 
956 #if ( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) )
957     #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1.
958 #endif
959 
960 #if ( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) )
961     #error configUSE_MUTEXES must be set to 1 to use recursive mutexes
962 #endif
963 
964 #ifndef configINITIAL_TICK_COUNT
965     #define configINITIAL_TICK_COUNT    0
966 #endif
967 
968 #if ( portTICK_TYPE_IS_ATOMIC == 0 )
969 
970 /* Either variables of tick type cannot be read atomically, or
971  * portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when
972  * the tick count is returned to the standard critical section macros. */
973     #define portTICK_TYPE_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux)
974     #define portTICK_TYPE_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux)
975     #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR()         portSET_INTERRUPT_MASK_FROM_ISR()
976     #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x )    portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) )
977 #else
978 
979 /* The tick type can be read atomically, so critical sections used when the
980  * tick count is returned can be defined away. */
981     #define portTICK_TYPE_ENTER_CRITICAL()
982     #define portTICK_TYPE_EXIT_CRITICAL()
983     #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR()         0
984     #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x )    ( void ) x
985 #endif /* if ( portTICK_TYPE_IS_ATOMIC == 0 ) */
986 
987 /* Definitions to allow backward compatibility with FreeRTOS versions prior to
988  * V8 if desired. */
989 #ifndef configENABLE_BACKWARD_COMPATIBILITY
990     #define configENABLE_BACKWARD_COMPATIBILITY    1
991 #endif
992 
993 #ifndef configPRINTF
994 
995 /* configPRINTF() was not defined, so define it away to nothing.  To use
996  * configPRINTF() then define it as follows (where MyPrintFunction() is
997  * provided by the application writer):
998  *
999  * void MyPrintFunction(const char *pcFormat, ... );
1000  #define configPRINTF( X )   MyPrintFunction X
1001  *
1002  * Then call like a standard printf() function, but placing brackets around
1003  * all parameters so they are passed as a single parameter.  For example:
1004  * configPRINTF( ("Value = %d", MyVariable) ); */
1005     #define configPRINTF( X )
1006 #endif
1007 
1008 #ifndef configMAX
1009 
1010 /* The application writer has not provided their own MAX macro, so define
1011  * the following generic implementation. */
1012     #define configMAX( a, b )    ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
1013 #endif
1014 
1015 #ifndef configMIN
1016 
1017 /* The application writer has not provided their own MIN macro, so define
1018  * the following generic implementation. */
1019     #define configMIN( a, b )    ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
1020 #endif
1021 
1022 #if configENABLE_BACKWARD_COMPATIBILITY == 1
1023     #define eTaskStateGet                 eTaskGetState
1024     #define portTickType                  TickType_t
1025     #define xTaskHandle                   TaskHandle_t
1026     #define xQueueHandle                  QueueHandle_t
1027     #define xSemaphoreHandle              SemaphoreHandle_t
1028     #define xQueueSetHandle               QueueSetHandle_t
1029     #define xQueueSetMemberHandle         QueueSetMemberHandle_t
1030     #define xTimeOutType                  TimeOut_t
1031     #define xMemoryRegion                 MemoryRegion_t
1032     #define xTaskParameters               TaskParameters_t
1033     #define xTaskStatusType               TaskStatus_t
1034     #define xTimerHandle                  TimerHandle_t
1035     #define xCoRoutineHandle              CoRoutineHandle_t
1036     #define pdTASK_HOOK_CODE              TaskHookFunction_t
1037     #define portTICK_RATE_MS              portTICK_PERIOD_MS
1038     #define pcTaskGetTaskName             pcTaskGetName
1039     #define pcTimerGetTimerName           pcTimerGetName
1040     #define pcQueueGetQueueName           pcQueueGetName
1041     #define vTaskGetTaskInfo              vTaskGetInfo
1042     #define xTaskGetIdleRunTimeCounter    ulTaskGetIdleRunTimeCounter
1043 
1044 /* Backward compatibility within the scheduler code only - these definitions
1045  * are not really required but are included for completeness. */
1046     #define tmrTIMER_CALLBACK             TimerCallbackFunction_t
1047     #define pdTASK_CODE                   TaskFunction_t
1048     #define xListItem                     ListItem_t
1049     #define xList                         List_t
1050 
1051 /* For libraries that break the list data hiding, and access list structure
1052  * members directly (which is not supposed to be done). */
1053     #define pxContainer                   pvContainer
1054 #endif /* configENABLE_BACKWARD_COMPATIBILITY */
1055 
1056 #ifdef ESP_PLATFORM
1057 #ifndef configESP32_PER_TASK_DATA
1058     #define configESP32_PER_TASK_DATA 1
1059 #endif
1060 #endif // ESP_PLATFORM
1061 
1062 #if ( configUSE_ALTERNATIVE_API != 0 )
1063     #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0
1064 #endif
1065 
1066 /* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even
1067  * if floating point hardware is otherwise supported by the FreeRTOS port in use.
1068  * This constant is not supported by all FreeRTOS ports that include floating
1069  * point support. */
1070 #ifndef configUSE_TASK_FPU_SUPPORT
1071     #define configUSE_TASK_FPU_SUPPORT    1
1072 #endif
1073 
1074 /* Set configENABLE_MPU to 1 to enable MPU support and 0 to disable it. This is
1075  * currently used in ARMv8M ports. */
1076 #ifndef configENABLE_MPU
1077     #define configENABLE_MPU    0
1078 #endif
1079 
1080 /* Set configENABLE_FPU to 1 to enable FPU support and 0 to disable it. This is
1081  * currently used in ARMv8M ports. */
1082 #ifndef configENABLE_FPU
1083     #define configENABLE_FPU    1
1084 #endif
1085 
1086 /* Set configENABLE_TRUSTZONE to 1 enable TrustZone support and 0 to disable it.
1087  * This is currently used in ARMv8M ports. */
1088 #ifndef configENABLE_TRUSTZONE
1089     #define configENABLE_TRUSTZONE    1
1090 #endif
1091 
1092 /* Set configRUN_FREERTOS_SECURE_ONLY to 1 to run the FreeRTOS ARMv8M port on
1093  * the Secure Side only. */
1094 #ifndef configRUN_FREERTOS_SECURE_ONLY
1095     #define configRUN_FREERTOS_SECURE_ONLY    0
1096 #endif
1097 
1098 /* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using
1099  * dynamically allocated RAM, in which case when any task is deleted it is known
1100  * that both the task's stack and TCB need to be freed.  Sometimes the
1101  * FreeRTOSConfig.h settings only allow a task to be created using statically
1102  * allocated RAM, in which case when any task is deleted it is known that neither
1103  * the task's stack or TCB should be freed.  Sometimes the FreeRTOSConfig.h
1104  * settings allow a task to be created using either statically or dynamically
1105  * allocated RAM, in which case a member of the TCB is used to record whether the
1106  * stack and/or TCB were allocated statically or dynamically, so when a task is
1107  * deleted the RAM that was allocated dynamically is freed again and no attempt is
1108  * made to free the RAM that was allocated statically.
1109  * tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is only true if it is possible for a
1110  * task to be created using either statically or dynamically allocated RAM.  Note
1111  * that if portUSING_MPU_WRAPPERS is 1 then a protected task can be created with
1112  * a statically allocated stack and a dynamically allocated TCB.
1113  *
1114  * The following table lists various combinations of portUSING_MPU_WRAPPERS,
1115  * configSUPPORT_DYNAMIC_ALLOCATION and configSUPPORT_STATIC_ALLOCATION and
1116  * when it is possible to have both static and dynamic allocation:
1117  *  +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
1118  * | MPU | Dynamic | Static |     Available Functions     |       Possible Allocations        | Both Dynamic and | Need Free |
1119  * |     |         |        |                             |                                   | Static Possible  |           |
1120  * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
1121  * | 0   | 0       | 1      | xTaskCreateStatic           | TCB - Static, Stack - Static      | No               | No        |
1122  * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1123  * | 0   | 1       | 0      | xTaskCreate                 | TCB - Dynamic, Stack - Dynamic    | No               | Yes       |
1124  * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1125  * | 0   | 1       | 1      | xTaskCreate,                | 1. TCB - Dynamic, Stack - Dynamic | Yes              | Yes       |
1126  * |     |         |        | xTaskCreateStatic           | 2. TCB - Static, Stack - Static   |                  |           |
1127  * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1128  * | 1   | 0       | 1      | xTaskCreateStatic,          | TCB - Static, Stack - Static      | No               | No        |
1129  * |     |         |        | xTaskCreateRestrictedStatic |                                   |                  |           |
1130  * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1131  * | 1   | 1       | 0      | xTaskCreate,                | 1. TCB - Dynamic, Stack - Dynamic | Yes              | Yes       |
1132  * |     |         |        | xTaskCreateRestricted       | 2. TCB - Dynamic, Stack - Static  |                  |           |
1133  * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1134  * | 1   | 1       | 1      | xTaskCreate,                | 1. TCB - Dynamic, Stack - Dynamic | Yes              | Yes       |
1135  * |     |         |        | xTaskCreateStatic,          | 2. TCB - Dynamic, Stack - Static  |                  |           |
1136  * |     |         |        | xTaskCreateRestricted,      | 3. TCB - Static, Stack - Static   |                  |           |
1137  * |     |         |        | xTaskCreateRestrictedStatic |                                   |                  |           |
1138  * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
1139  */
1140 #define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE                                                                                     \
1141     ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \
1142       ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) )
1143 
1144 /*
1145  * In line with software engineering best practice, FreeRTOS implements a strict
1146  * data hiding policy, so the real structures used by FreeRTOS to maintain the
1147  * state of tasks, queues, semaphores, etc. are not accessible to the application
1148  * code.  However, if the application writer wants to statically allocate such
1149  * an object then the size of the object needs to be known.  Dummy structures
1150  * that are guaranteed to have the same size and alignment requirements of the
1151  * real objects are used for this purpose.  The dummy list and list item
1152  * structures below are used for inclusion in such a dummy structure.
1153  */
1154 struct xSTATIC_LIST_ITEM
1155 {
1156     #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1157         TickType_t xDummy1;
1158     #endif
1159     TickType_t xDummy2;
1160     void * pvDummy3[ 4 ];
1161     #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1162         TickType_t xDummy4;
1163     #endif
1164 };
1165 typedef struct xSTATIC_LIST_ITEM StaticListItem_t;
1166 
1167 /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
1168 struct xSTATIC_MINI_LIST_ITEM
1169 {
1170     #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1171         TickType_t xDummy1;
1172     #endif
1173     TickType_t xDummy2;
1174     void * pvDummy3[ 2 ];
1175 };
1176 typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t;
1177 
1178 /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
1179 typedef struct xSTATIC_LIST
1180 {
1181     #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1182         TickType_t xDummy1;
1183     #endif
1184     UBaseType_t uxDummy2;
1185     void * pvDummy3;
1186     StaticMiniListItem_t xDummy4;
1187     #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1188         TickType_t xDummy5;
1189     #endif
1190 } StaticList_t;
1191 
1192 /*
1193  * In line with software engineering best practice, especially when supplying a
1194  * library that is likely to change in future versions, FreeRTOS implements a
1195  * strict data hiding policy.  This means the Task structure used internally by
1196  * FreeRTOS is not accessible to application code.  However, if the application
1197  * writer wants to statically allocate the memory required to create a task then
1198  * the size of the task object needs to be known.  The StaticTask_t structure
1199  * below is provided for this purpose.  Its sizes and alignment requirements are
1200  * guaranteed to match those of the genuine structure, no matter which
1201  * architecture is being used, and no matter how the values in FreeRTOSConfig.h
1202  * are set.  Its contents are somewhat obfuscated in the hope users will
1203  * recognise that it would be unwise to make direct use of the structure members.
1204  */
1205 typedef struct xSTATIC_TCB
1206 {
1207     void * pxDummy1;
1208     #if ( portUSING_MPU_WRAPPERS == 1 )
1209         xMPU_SETTINGS xDummy2;
1210     #endif
1211     StaticListItem_t xDummy3[ 2 ];
1212     UBaseType_t uxDummy5;
1213     void * pxDummy6;
1214     uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ];
1215     BaseType_t xDummyCore;
1216     #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
1217         void * pxDummy8;
1218     #endif
1219     #if ( portCRITICAL_NESTING_IN_TCB == 1 )
1220         UBaseType_t uxDummy9;
1221     #endif
1222     #if ( configUSE_TRACE_FACILITY == 1 )
1223         UBaseType_t uxDummy10[ 2 ];
1224     #endif
1225     #if ( configUSE_MUTEXES == 1 )
1226         UBaseType_t uxDummy12[ 2 ];
1227     #endif
1228     #if ( configUSE_APPLICATION_TASK_TAG == 1 )
1229         void * pxDummy14;
1230     #endif
1231     #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
1232         void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
1233     #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS )
1234         void            *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
1235     #endif
1236     #endif
1237     #if ( configGENERATE_RUN_TIME_STATS == 1 )
1238         uint32_t ulDummy16;
1239     #endif
1240     #if ( configUSE_NEWLIB_REENTRANT == 1 )
1241         struct  _reent xDummy17;
1242     #endif
1243     #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1244         uint32_t ulDummy18[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
1245         uint8_t ucDummy19[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
1246     #endif
1247     #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 )
1248         uint8_t uxDummy20;
1249     #endif
1250 
1251     #if ( INCLUDE_xTaskAbortDelay == 1 )
1252         uint8_t ucDummy21;
1253     #endif
1254     #if ( configUSE_POSIX_ERRNO == 1 )
1255         int iDummy22;
1256     #endif
1257 } StaticTask_t;
1258 
1259 /*
1260  * In line with software engineering best practice, especially when supplying a
1261  * library that is likely to change in future versions, FreeRTOS implements a
1262  * strict data hiding policy.  This means the Queue structure used internally by
1263  * FreeRTOS is not accessible to application code.  However, if the application
1264  * writer wants to statically allocate the memory required to create a queue
1265  * then the size of the queue object needs to be known.  The StaticQueue_t
1266  * structure below is provided for this purpose.  Its sizes and alignment
1267  * requirements are guaranteed to match those of the genuine structure, no
1268  * matter which architecture is being used, and no matter how the values in
1269  * FreeRTOSConfig.h are set.  Its contents are somewhat obfuscated in the hope
1270  * users will recognise that it would be unwise to make direct use of the
1271  * structure members.
1272  */
1273 typedef struct xSTATIC_QUEUE
1274 {
1275     void * pvDummy1[ 3 ];
1276 
1277     union
1278     {
1279         void * pvDummy2;
1280         UBaseType_t uxDummy2;
1281     } u;
1282 
1283     StaticList_t xDummy3[ 2 ];
1284     UBaseType_t uxDummy4[ 3 ];
1285     uint8_t ucDummy5[ 2 ];
1286 
1287     #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
1288         uint8_t ucDummy6;
1289     #endif
1290 
1291     #if ( configUSE_QUEUE_SETS == 1 )
1292         void * pvDummy7;
1293     #endif
1294 
1295     #if ( configUSE_TRACE_FACILITY == 1 )
1296         UBaseType_t uxDummy8;
1297         uint8_t ucDummy9;
1298     #endif
1299     portMUX_TYPE xDummy10;
1300 } StaticQueue_t;
1301 typedef StaticQueue_t StaticSemaphore_t;
1302 
1303 /*
1304  * In line with software engineering best practice, especially when supplying a
1305  * library that is likely to change in future versions, FreeRTOS implements a
1306  * strict data hiding policy.  This means the event group structure used
1307  * internally by FreeRTOS is not accessible to application code.  However, if
1308  * the application writer wants to statically allocate the memory required to
1309  * create an event group then the size of the event group object needs to be
1310  * know.  The StaticEventGroup_t structure below is provided for this purpose.
1311  * Its sizes and alignment requirements are guaranteed to match those of the
1312  * genuine structure, no matter which architecture is being used, and no matter
1313  * how the values in FreeRTOSConfig.h are set.  Its contents are somewhat
1314  * obfuscated in the hope users will recognise that it would be unwise to make
1315  * direct use of the structure members.
1316  */
1317 typedef struct xSTATIC_EVENT_GROUP
1318 {
1319     TickType_t xDummy1;
1320     StaticList_t xDummy2;
1321 
1322     #if ( configUSE_TRACE_FACILITY == 1 )
1323         UBaseType_t uxDummy3;
1324     #endif
1325 
1326     #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
1327         uint8_t ucDummy4;
1328     #endif
1329     portMUX_TYPE xDummy5;
1330 } StaticEventGroup_t;
1331 
1332 /*
1333  * In line with software engineering best practice, especially when supplying a
1334  * library that is likely to change in future versions, FreeRTOS implements a
1335  * strict data hiding policy.  This means the software timer structure used
1336  * internally by FreeRTOS is not accessible to application code.  However, if
1337  * the application writer wants to statically allocate the memory required to
1338  * create a software timer then the size of the queue object needs to be known.
1339  * The StaticTimer_t structure below is provided for this purpose.  Its sizes
1340  * and alignment requirements are guaranteed to match those of the genuine
1341  * structure, no matter which architecture is being used, and no matter how the
1342  * values in FreeRTOSConfig.h are set.  Its contents are somewhat obfuscated in
1343  * the hope users will recognise that it would be unwise to make direct use of
1344  * the structure members.
1345  */
1346 typedef struct xSTATIC_TIMER
1347 {
1348     void * pvDummy1;
1349     StaticListItem_t xDummy2;
1350     TickType_t xDummy3;
1351     void * pvDummy5;
1352     TaskFunction_t pvDummy6;
1353     #if ( configUSE_TRACE_FACILITY == 1 )
1354         UBaseType_t uxDummy7;
1355     #endif
1356     uint8_t ucDummy8;
1357 } StaticTimer_t;
1358 
1359 /*
1360  * In line with software engineering best practice, especially when supplying a
1361  * library that is likely to change in future versions, FreeRTOS implements a
1362  * strict data hiding policy.  This means the stream buffer structure used
1363  * internally by FreeRTOS is not accessible to application code.  However, if
1364  * the application writer wants to statically allocate the memory required to
1365  * create a stream buffer then the size of the stream buffer object needs to be
1366  * known.  The StaticStreamBuffer_t structure below is provided for this
1367  * purpose.  Its size and alignment requirements are guaranteed to match those
1368  * of the genuine structure, no matter which architecture is being used, and
1369  * no matter how the values in FreeRTOSConfig.h are set.  Its contents are
1370  * somewhat obfuscated in the hope users will recognise that it would be unwise
1371  * to make direct use of the structure members.
1372  */
1373 typedef struct xSTATIC_STREAM_BUFFER
1374 {
1375     size_t uxDummy1[ 4 ];
1376     void * pvDummy2[ 3 ];
1377     uint8_t ucDummy3;
1378     #if ( configUSE_TRACE_FACILITY == 1 )
1379         UBaseType_t uxDummy4;
1380     #endif
1381     portMUX_TYPE xDummy5;
1382 } StaticStreamBuffer_t;
1383 
1384 /* Message buffers are built on stream buffers. */
1385 typedef StaticStreamBuffer_t StaticMessageBuffer_t;
1386 
1387 /* *INDENT-OFF* */
1388 #ifdef __cplusplus
1389     }
1390 #endif
1391 /* *INDENT-ON* */
1392 
1393 #endif /* INC_FREERTOS_H */
1394