2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: MIT
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
29 #ifndef INC_FREERTOS_H
30 #define INC_FREERTOS_H
33 * Include the generic headers required for the FreeRTOS port being used.
38 * If stdint.h cannot be located then:
39 * + If using GCC ensure the -nostdint options is *not* being used.
40 * + Ensure the project's include path includes the directory in which your
41 * compiler stores stdint.h.
42 * + Set any compiler options necessary for it to support C99, as technically
43 * stdint.h is only mandatory with C99 (FreeRTOS does not require C99 in any
45 * + The FreeRTOS download includes a simple stdint.h definition that can be
46 * used in cases where none is provided by the compiler. The files only
47 * contains the typedefs required to build FreeRTOS. Read the instructions
48 * in FreeRTOS/source/stdint.readme for more information.
50 #include <stdint.h> /* READ COMMENT ABOVE. */
58 /* Acceptable values for configTICK_TYPE_WIDTH_IN_BITS. */
59 #define TICK_TYPE_WIDTH_16_BITS 0
60 #define TICK_TYPE_WIDTH_32_BITS 1
61 #define TICK_TYPE_WIDTH_64_BITS 2
63 /* Application specific configuration options. */
64 #include "FreeRTOSConfig.h"
66 #if !defined( configUSE_16_BIT_TICKS ) && !defined( configTICK_TYPE_WIDTH_IN_BITS )
67 #error Missing definition: One of configUSE_16_BIT_TICKS and configTICK_TYPE_WIDTH_IN_BITS must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details.
70 #if defined( configUSE_16_BIT_TICKS ) && defined( configTICK_TYPE_WIDTH_IN_BITS )
71 #error Only one of configUSE_16_BIT_TICKS and configTICK_TYPE_WIDTH_IN_BITS must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details.
74 /* Define configTICK_TYPE_WIDTH_IN_BITS according to the
75 * value of configUSE_16_BIT_TICKS for backward compatibility. */
76 #ifndef configTICK_TYPE_WIDTH_IN_BITS
77 #if ( configUSE_16_BIT_TICKS == 1 )
78 #define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_16_BITS
80 #define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS
84 /* Set configUSE_MPU_WRAPPERS_V1 to 1 to use MPU wrappers v1. */
85 #ifndef configUSE_MPU_WRAPPERS_V1
86 #define configUSE_MPU_WRAPPERS_V1 0
89 /* Set configENABLE_ACCESS_CONTROL_LIST to 1 to enable access control list support. */
90 #ifndef configENABLE_ACCESS_CONTROL_LIST
91 #define configENABLE_ACCESS_CONTROL_LIST 0
94 /* Set default value of configNUMBER_OF_CORES to 1 to use single core FreeRTOS. */
95 #ifndef configNUMBER_OF_CORES
96 #define configNUMBER_OF_CORES 1
99 /* Basic FreeRTOS definitions. */
100 #include "projdefs.h"
102 /* Definitions specific to the port being used. */
103 #include "portable.h"
105 /* Must be defaulted before configUSE_NEWLIB_REENTRANT is used below. */
106 #ifndef configUSE_NEWLIB_REENTRANT
107 #define configUSE_NEWLIB_REENTRANT 0
110 /* Required if struct _reent is used. */
111 #if ( configUSE_NEWLIB_REENTRANT == 1 )
113 #include "newlib-freertos.h"
115 #endif /* if ( configUSE_NEWLIB_REENTRANT == 1 ) */
117 /* Must be defaulted before configUSE_PICOLIBC_TLS is used below. */
118 #ifndef configUSE_PICOLIBC_TLS
119 #define configUSE_PICOLIBC_TLS 0
122 #if ( configUSE_PICOLIBC_TLS == 1 )
124 #include "picolibc-freertos.h"
126 #endif /* if ( configUSE_PICOLIBC_TLS == 1 ) */
128 #ifndef configUSE_C_RUNTIME_TLS_SUPPORT
129 #define configUSE_C_RUNTIME_TLS_SUPPORT 0
132 #if ( configUSE_C_RUNTIME_TLS_SUPPORT == 1 )
134 #ifndef configTLS_BLOCK_TYPE
135 #error Missing definition: configTLS_BLOCK_TYPE must be defined in FreeRTOSConfig.h when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
138 #ifndef configINIT_TLS_BLOCK
139 #error Missing definition: configINIT_TLS_BLOCK must be defined in FreeRTOSConfig.h when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
142 #ifndef configSET_TLS_BLOCK
143 #error Missing definition: configSET_TLS_BLOCK must be defined in FreeRTOSConfig.h when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
146 #ifndef configDEINIT_TLS_BLOCK
147 #error Missing definition: configDEINIT_TLS_BLOCK must be defined in FreeRTOSConfig.h when configUSE_C_RUNTIME_TLS_SUPPORT is set to 1.
149 #endif /* if ( configUSE_C_RUNTIME_TLS_SUPPORT == 1 ) */
152 * Check all the required application specific macros have been defined.
153 * These macros are application specific and (as downloaded) are defined
154 * within FreeRTOSConfig.h.
157 #ifndef configMINIMAL_STACK_SIZE
158 #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.
161 #ifndef configMAX_PRIORITIES
162 #error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details.
165 #if configMAX_PRIORITIES < 1
166 #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.
169 #ifndef configUSE_PREEMPTION
170 #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.
173 #ifndef configUSE_IDLE_HOOK
174 #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.
177 #if ( configNUMBER_OF_CORES > 1 )
178 #ifndef configUSE_MINIMAL_IDLE_HOOK
179 #error Missing definition: configUSE_MINIMAL_IDLE_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.
183 #ifndef configUSE_TICK_HOOK
184 #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.
187 #if ( ( configTICK_TYPE_WIDTH_IN_BITS != TICK_TYPE_WIDTH_16_BITS ) && \
188 ( configTICK_TYPE_WIDTH_IN_BITS != TICK_TYPE_WIDTH_32_BITS ) && \
189 ( configTICK_TYPE_WIDTH_IN_BITS != TICK_TYPE_WIDTH_64_BITS ) )
190 #error Macro configTICK_TYPE_WIDTH_IN_BITS is defined to incorrect value. See the Configuration section of the FreeRTOS API documentation for details.
193 #ifndef configUSE_CO_ROUTINES
194 #define configUSE_CO_ROUTINES 0
197 #ifndef INCLUDE_vTaskPrioritySet
198 #define INCLUDE_vTaskPrioritySet 0
201 #ifndef INCLUDE_uxTaskPriorityGet
202 #define INCLUDE_uxTaskPriorityGet 0
205 #ifndef INCLUDE_vTaskDelete
206 #define INCLUDE_vTaskDelete 0
209 #ifndef INCLUDE_vTaskSuspend
210 #define INCLUDE_vTaskSuspend 0
213 #ifdef INCLUDE_xTaskDelayUntil
214 #ifdef INCLUDE_vTaskDelayUntil
216 /* INCLUDE_vTaskDelayUntil was replaced by INCLUDE_xTaskDelayUntil. Backward
217 * compatibility is maintained if only one or the other is defined, but
218 * there is a conflict if both are defined. */
219 #error INCLUDE_vTaskDelayUntil and INCLUDE_xTaskDelayUntil are both defined. INCLUDE_vTaskDelayUntil is no longer required and should be removed
223 #ifndef INCLUDE_xTaskDelayUntil
224 #ifdef INCLUDE_vTaskDelayUntil
226 /* If INCLUDE_vTaskDelayUntil is set but INCLUDE_xTaskDelayUntil is not then
227 * the project's FreeRTOSConfig.h probably pre-dates the introduction of
228 * xTaskDelayUntil and setting INCLUDE_xTaskDelayUntil to whatever
229 * INCLUDE_vTaskDelayUntil is set to will ensure backward compatibility.
231 #define INCLUDE_xTaskDelayUntil INCLUDE_vTaskDelayUntil
235 #ifndef INCLUDE_xTaskDelayUntil
236 #define INCLUDE_xTaskDelayUntil 0
239 #ifndef INCLUDE_vTaskDelay
240 #define INCLUDE_vTaskDelay 0
243 #ifndef INCLUDE_xTaskGetIdleTaskHandle
244 #define INCLUDE_xTaskGetIdleTaskHandle 0
247 #ifndef INCLUDE_xTaskAbortDelay
248 #define INCLUDE_xTaskAbortDelay 0
251 #ifndef INCLUDE_xQueueGetMutexHolder
252 #define INCLUDE_xQueueGetMutexHolder 0
255 #ifndef INCLUDE_xSemaphoreGetMutexHolder
256 #define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder
259 #ifndef INCLUDE_xTaskGetHandle
260 #define INCLUDE_xTaskGetHandle 0
263 #ifndef INCLUDE_uxTaskGetStackHighWaterMark
264 #define INCLUDE_uxTaskGetStackHighWaterMark 0
267 #ifndef INCLUDE_uxTaskGetStackHighWaterMark2
268 #define INCLUDE_uxTaskGetStackHighWaterMark2 0
271 #ifndef INCLUDE_eTaskGetState
272 #define INCLUDE_eTaskGetState 0
275 #ifndef INCLUDE_xTaskResumeFromISR
276 #define INCLUDE_xTaskResumeFromISR 1
279 #ifndef INCLUDE_xTimerPendFunctionCall
280 #define INCLUDE_xTimerPendFunctionCall 0
283 #ifndef INCLUDE_xTaskGetSchedulerState
284 #define INCLUDE_xTaskGetSchedulerState 0
287 #ifndef INCLUDE_xTaskGetCurrentTaskHandle
288 #define INCLUDE_xTaskGetCurrentTaskHandle 1
291 #if configUSE_CO_ROUTINES != 0
292 #ifndef configMAX_CO_ROUTINE_PRIORITIES
293 #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1.
297 #ifndef configUSE_DAEMON_TASK_STARTUP_HOOK
298 #define configUSE_DAEMON_TASK_STARTUP_HOOK 0
301 #ifndef configUSE_APPLICATION_TASK_TAG
302 #define configUSE_APPLICATION_TASK_TAG 0
305 #ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
306 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
309 #ifndef configUSE_RECURSIVE_MUTEXES
310 #define configUSE_RECURSIVE_MUTEXES 0
313 #ifndef configUSE_MUTEXES
314 #define configUSE_MUTEXES 0
317 #ifndef configUSE_TIMERS
318 #define configUSE_TIMERS 0
321 #ifndef configUSE_COUNTING_SEMAPHORES
322 #define configUSE_COUNTING_SEMAPHORES 0
325 #ifndef configUSE_TASK_PREEMPTION_DISABLE
326 #define configUSE_TASK_PREEMPTION_DISABLE 0
329 #ifndef configUSE_ALTERNATIVE_API
330 #define configUSE_ALTERNATIVE_API 0
333 #ifndef portCRITICAL_NESTING_IN_TCB
334 #define portCRITICAL_NESTING_IN_TCB 0
337 #ifndef configMAX_TASK_NAME_LEN
338 #define configMAX_TASK_NAME_LEN 16
341 #ifndef configIDLE_SHOULD_YIELD
342 #define configIDLE_SHOULD_YIELD 1
345 #if configMAX_TASK_NAME_LEN < 1
346 #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h
350 #define configASSERT( x )
351 #define configASSERT_DEFINED 0
353 #define configASSERT_DEFINED 1
356 /* configPRECONDITION should be defined as configASSERT.
357 * The CBMC proofs need a way to track assumptions and assertions.
358 * A configPRECONDITION statement should express an implicit invariant or
359 * assumption made. A configASSERT statement should express an invariant that must
360 * hold explicit before calling the code. */
361 #ifndef configPRECONDITION
362 #define configPRECONDITION( X ) configASSERT( X )
363 #define configPRECONDITION_DEFINED 0
365 #define configPRECONDITION_DEFINED 1
368 #ifndef portMEMORY_BARRIER
369 #define portMEMORY_BARRIER()
372 #ifndef portSOFTWARE_BARRIER
373 #define portSOFTWARE_BARRIER()
376 #ifndef configRUN_MULTIPLE_PRIORITIES
377 #define configRUN_MULTIPLE_PRIORITIES 0
380 #ifndef portGET_CORE_ID
382 #if ( configNUMBER_OF_CORES == 1 )
383 #define portGET_CORE_ID() 0
385 #error configNUMBER_OF_CORES is set to more than 1 then portGET_CORE_ID must also be defined.
386 #endif /* configNUMBER_OF_CORES */
388 #endif /* portGET_CORE_ID */
390 #ifndef portYIELD_CORE
392 #if ( configNUMBER_OF_CORES == 1 )
393 #define portYIELD_CORE( x ) portYIELD()
395 #error configNUMBER_OF_CORES is set to more than 1 then portYIELD_CORE must also be defined.
396 #endif /* configNUMBER_OF_CORES */
398 #endif /* portYIELD_CORE */
400 #ifndef portSET_INTERRUPT_MASK
402 #if ( configNUMBER_OF_CORES > 1 )
403 #error portSET_INTERRUPT_MASK is required in SMP
406 #endif /* portSET_INTERRUPT_MASK */
408 #ifndef portCLEAR_INTERRUPT_MASK
410 #if ( configNUMBER_OF_CORES > 1 )
411 #error portCLEAR_INTERRUPT_MASK is required in SMP
414 #endif /* portCLEAR_INTERRUPT_MASK */
416 #ifndef portRELEASE_TASK_LOCK
418 #if ( configNUMBER_OF_CORES == 1 )
419 #define portRELEASE_TASK_LOCK()
421 #error portRELEASE_TASK_LOCK is required in SMP
424 #endif /* portRELEASE_TASK_LOCK */
426 #ifndef portGET_TASK_LOCK
428 #if ( configNUMBER_OF_CORES == 1 )
429 #define portGET_TASK_LOCK()
431 #error portGET_TASK_LOCK is required in SMP
434 #endif /* portGET_TASK_LOCK */
436 #ifndef portRELEASE_ISR_LOCK
438 #if ( configNUMBER_OF_CORES == 1 )
439 #define portRELEASE_ISR_LOCK()
441 #error portRELEASE_ISR_LOCK is required in SMP
444 #endif /* portRELEASE_ISR_LOCK */
446 #ifndef portGET_ISR_LOCK
448 #if ( configNUMBER_OF_CORES == 1 )
449 #define portGET_ISR_LOCK()
451 #error portGET_ISR_LOCK is required in SMP
454 #endif /* portGET_ISR_LOCK */
456 #ifndef portCHECK_IF_IN_ISR
458 #if ( configNUMBER_OF_CORES > 1 )
459 #error portCHECK_IF_IN_ISR is required in SMP
462 #endif /* portCHECK_IF_IN_ISR */
464 #ifndef portENTER_CRITICAL_FROM_ISR
466 #if ( configNUMBER_OF_CORES > 1 )
467 #error portENTER_CRITICAL_FROM_ISR is required in SMP
472 #ifndef portEXIT_CRITICAL_FROM_ISR
474 #if ( configNUMBER_OF_CORES > 1 )
475 #error portEXIT_CRITICAL_FROM_ISR is required in SMP
480 #ifndef configUSE_CORE_AFFINITY
481 #define configUSE_CORE_AFFINITY 0
482 #endif /* configUSE_CORE_AFFINITY */
484 #ifndef configUSE_MINIMAL_IDLE_HOOK
485 #define configUSE_MINIMAL_IDLE_HOOK 0
486 #endif /* configUSE_MINIMAL_IDLE_HOOK */
488 /* The timers module relies on xTaskGetSchedulerState(). */
489 #if configUSE_TIMERS == 1
491 #ifndef configTIMER_TASK_PRIORITY
492 #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined.
493 #endif /* configTIMER_TASK_PRIORITY */
495 #ifndef configTIMER_QUEUE_LENGTH
496 #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined.
497 #endif /* configTIMER_QUEUE_LENGTH */
499 #ifndef configTIMER_TASK_STACK_DEPTH
500 #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined.
501 #endif /* configTIMER_TASK_STACK_DEPTH */
503 #ifndef portTIMER_CALLBACK_ATTRIBUTE
504 #define portTIMER_CALLBACK_ATTRIBUTE
505 #endif /* portTIMER_CALLBACK_ATTRIBUTE */
507 #endif /* configUSE_TIMERS */
509 #ifndef portSET_INTERRUPT_MASK_FROM_ISR
510 #define portSET_INTERRUPT_MASK_FROM_ISR() 0
513 #ifndef portCLEAR_INTERRUPT_MASK_FROM_ISR
514 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) ( void ) ( uxSavedStatusValue )
517 #ifndef portCLEAN_UP_TCB
518 #define portCLEAN_UP_TCB( pxTCB ) ( void ) ( pxTCB )
521 #ifndef portPRE_TASK_DELETE_HOOK
522 #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxYieldPending )
525 #ifndef portSETUP_TCB
526 #define portSETUP_TCB( pxTCB ) ( void ) ( pxTCB )
529 #ifndef configQUEUE_REGISTRY_SIZE
530 #define configQUEUE_REGISTRY_SIZE 0U
533 #if ( configQUEUE_REGISTRY_SIZE < 1 )
534 #define vQueueAddToRegistry( xQueue, pcName )
535 #define vQueueUnregisterQueue( xQueue )
536 #define pcQueueGetName( xQueue )
539 #ifndef configUSE_MINI_LIST_ITEM
540 #define configUSE_MINI_LIST_ITEM 1
543 #ifndef portPOINTER_SIZE_TYPE
544 #define portPOINTER_SIZE_TYPE uint32_t
547 /* Remove any unused trace macros. */
550 /* Used to perform any necessary initialisation - for example, open a file
551 * into which trace is to be written. */
557 /* Use to close a trace, for example close a file into which trace has been
562 #ifndef traceTASK_SWITCHED_IN
564 /* Called after a task has been selected to run. pxCurrentTCB holds a pointer
565 * to the task control block of the selected task. */
566 #define traceTASK_SWITCHED_IN()
569 #ifndef traceINCREASE_TICK_COUNT
571 /* Called before stepping the tick count after waking from tickless idle
573 #define traceINCREASE_TICK_COUNT( x )
576 #ifndef traceLOW_POWER_IDLE_BEGIN
577 /* Called immediately before entering tickless idle. */
578 #define traceLOW_POWER_IDLE_BEGIN()
581 #ifndef traceLOW_POWER_IDLE_END
582 /* Called when returning to the Idle task after a tickless idle. */
583 #define traceLOW_POWER_IDLE_END()
586 #ifndef traceTASK_SWITCHED_OUT
588 /* Called before a task has been selected to run. pxCurrentTCB holds a pointer
589 * to the task control block of the task being switched out. */
590 #define traceTASK_SWITCHED_OUT()
593 #ifndef traceTASK_PRIORITY_INHERIT
595 /* Called when a task attempts to take a mutex that is already held by a
596 * lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task
597 * that holds the mutex. uxInheritedPriority is the priority the mutex holder
598 * will inherit (the priority of the task that is attempting to obtain the
600 #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority )
603 #ifndef traceTASK_PRIORITY_DISINHERIT
605 /* Called when a task releases a mutex, the holding of which had resulted in
606 * the task inheriting the priority of a higher priority task.
607 * pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the
608 * mutex. uxOriginalPriority is the task's configured (base) priority. */
609 #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority )
612 #ifndef traceBLOCKING_ON_QUEUE_RECEIVE
614 /* Task is about to block because it cannot read from a
615 * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
616 * upon which the read was attempted. pxCurrentTCB points to the TCB of the
617 * task that attempted the read. */
618 #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )
621 #ifndef traceBLOCKING_ON_QUEUE_PEEK
623 /* Task is about to block because it cannot read from a
624 * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
625 * upon which the read was attempted. pxCurrentTCB points to the TCB of the
626 * task that attempted the read. */
627 #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue )
630 #ifndef traceBLOCKING_ON_QUEUE_SEND
632 /* Task is about to block because it cannot write to a
633 * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
634 * upon which the write was attempted. pxCurrentTCB points to the TCB of the
635 * task that attempted the write. */
636 #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )
639 #ifndef configCHECK_FOR_STACK_OVERFLOW
640 #define configCHECK_FOR_STACK_OVERFLOW 0
643 #ifndef configRECORD_STACK_HIGH_ADDRESS
644 #define configRECORD_STACK_HIGH_ADDRESS 0
647 #ifndef configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H
648 #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 0
651 /* The following event macros are embedded in the kernel API calls. */
653 #ifndef traceMOVED_TASK_TO_READY_STATE
654 #define traceMOVED_TASK_TO_READY_STATE( pxTCB )
657 #ifndef tracePOST_MOVED_TASK_TO_READY_STATE
658 #define tracePOST_MOVED_TASK_TO_READY_STATE( pxTCB )
661 #ifndef traceMOVED_TASK_TO_DELAYED_LIST
662 #define traceMOVED_TASK_TO_DELAYED_LIST()
665 #ifndef traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST
666 #define traceMOVED_TASK_TO_OVERFLOW_DELAYED_LIST()
669 #ifndef traceQUEUE_CREATE
670 #define traceQUEUE_CREATE( pxNewQueue )
673 #ifndef traceQUEUE_CREATE_FAILED
674 #define traceQUEUE_CREATE_FAILED( ucQueueType )
677 #ifndef traceCREATE_MUTEX
678 #define traceCREATE_MUTEX( pxNewQueue )
681 #ifndef traceCREATE_MUTEX_FAILED
682 #define traceCREATE_MUTEX_FAILED()
685 #ifndef traceGIVE_MUTEX_RECURSIVE
686 #define traceGIVE_MUTEX_RECURSIVE( pxMutex )
689 #ifndef traceGIVE_MUTEX_RECURSIVE_FAILED
690 #define traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex )
693 #ifndef traceTAKE_MUTEX_RECURSIVE
694 #define traceTAKE_MUTEX_RECURSIVE( pxMutex )
697 #ifndef traceTAKE_MUTEX_RECURSIVE_FAILED
698 #define traceTAKE_MUTEX_RECURSIVE_FAILED( pxMutex )
701 #ifndef traceCREATE_COUNTING_SEMAPHORE
702 #define traceCREATE_COUNTING_SEMAPHORE()
705 #ifndef traceCREATE_COUNTING_SEMAPHORE_FAILED
706 #define traceCREATE_COUNTING_SEMAPHORE_FAILED()
709 #ifndef traceQUEUE_SET_SEND
710 #define traceQUEUE_SET_SEND traceQUEUE_SEND
713 #ifndef traceQUEUE_SEND
714 #define traceQUEUE_SEND( pxQueue )
717 #ifndef traceQUEUE_SEND_FAILED
718 #define traceQUEUE_SEND_FAILED( pxQueue )
721 #ifndef traceQUEUE_RECEIVE
722 #define traceQUEUE_RECEIVE( pxQueue )
725 #ifndef traceQUEUE_PEEK
726 #define traceQUEUE_PEEK( pxQueue )
729 #ifndef traceQUEUE_PEEK_FAILED
730 #define traceQUEUE_PEEK_FAILED( pxQueue )
733 #ifndef traceQUEUE_PEEK_FROM_ISR
734 #define traceQUEUE_PEEK_FROM_ISR( pxQueue )
737 #ifndef traceQUEUE_RECEIVE_FAILED
738 #define traceQUEUE_RECEIVE_FAILED( pxQueue )
741 #ifndef traceQUEUE_SEND_FROM_ISR
742 #define traceQUEUE_SEND_FROM_ISR( pxQueue )
745 #ifndef traceQUEUE_SEND_FROM_ISR_FAILED
746 #define traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue )
749 #ifndef traceQUEUE_RECEIVE_FROM_ISR
750 #define traceQUEUE_RECEIVE_FROM_ISR( pxQueue )
753 #ifndef traceQUEUE_RECEIVE_FROM_ISR_FAILED
754 #define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )
757 #ifndef traceQUEUE_PEEK_FROM_ISR_FAILED
758 #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue )
761 #ifndef traceQUEUE_DELETE
762 #define traceQUEUE_DELETE( pxQueue )
765 #ifndef traceTASK_CREATE
766 #define traceTASK_CREATE( pxNewTCB )
769 #ifndef traceTASK_CREATE_FAILED
770 #define traceTASK_CREATE_FAILED()
773 #ifndef traceTASK_DELETE
774 #define traceTASK_DELETE( pxTaskToDelete )
777 #ifndef traceTASK_DELAY_UNTIL
778 #define traceTASK_DELAY_UNTIL( x )
781 #ifndef traceTASK_DELAY
782 #define traceTASK_DELAY()
785 #ifndef traceTASK_PRIORITY_SET
786 #define traceTASK_PRIORITY_SET( pxTask, uxNewPriority )
789 #ifndef traceTASK_SUSPEND
790 #define traceTASK_SUSPEND( pxTaskToSuspend )
793 #ifndef traceTASK_RESUME
794 #define traceTASK_RESUME( pxTaskToResume )
797 #ifndef traceTASK_RESUME_FROM_ISR
798 #define traceTASK_RESUME_FROM_ISR( pxTaskToResume )
801 #ifndef traceTASK_INCREMENT_TICK
802 #define traceTASK_INCREMENT_TICK( xTickCount )
805 #ifndef traceTIMER_CREATE
806 #define traceTIMER_CREATE( pxNewTimer )
809 #ifndef traceTIMER_CREATE_FAILED
810 #define traceTIMER_CREATE_FAILED()
813 #ifndef traceTIMER_COMMAND_SEND
814 #define traceTIMER_COMMAND_SEND( xTimer, xMessageID, xMessageValueValue, xReturn )
817 #ifndef traceTIMER_EXPIRED
818 #define traceTIMER_EXPIRED( pxTimer )
821 #ifndef traceTIMER_COMMAND_RECEIVED
822 #define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue )
826 #define traceMALLOC( pvAddress, uiSize )
830 #define traceFREE( pvAddress, uiSize )
833 #ifndef traceEVENT_GROUP_CREATE
834 #define traceEVENT_GROUP_CREATE( xEventGroup )
837 #ifndef traceEVENT_GROUP_CREATE_FAILED
838 #define traceEVENT_GROUP_CREATE_FAILED()
841 #ifndef traceEVENT_GROUP_SYNC_BLOCK
842 #define traceEVENT_GROUP_SYNC_BLOCK( xEventGroup, uxBitsToSet, uxBitsToWaitFor )
845 #ifndef traceEVENT_GROUP_SYNC_END
846 #define traceEVENT_GROUP_SYNC_END( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) ( xTimeoutOccurred )
849 #ifndef traceEVENT_GROUP_WAIT_BITS_BLOCK
850 #define traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor )
853 #ifndef traceEVENT_GROUP_WAIT_BITS_END
854 #define traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxBitsToWaitFor, xTimeoutOccurred ) ( void ) ( xTimeoutOccurred )
857 #ifndef traceEVENT_GROUP_CLEAR_BITS
858 #define traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear )
861 #ifndef traceEVENT_GROUP_CLEAR_BITS_FROM_ISR
862 #define traceEVENT_GROUP_CLEAR_BITS_FROM_ISR( xEventGroup, uxBitsToClear )
865 #ifndef traceEVENT_GROUP_SET_BITS
866 #define traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet )
869 #ifndef traceEVENT_GROUP_SET_BITS_FROM_ISR
870 #define traceEVENT_GROUP_SET_BITS_FROM_ISR( xEventGroup, uxBitsToSet )
873 #ifndef traceEVENT_GROUP_DELETE
874 #define traceEVENT_GROUP_DELETE( xEventGroup )
877 #ifndef tracePEND_FUNC_CALL
878 #define tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, ret )
881 #ifndef tracePEND_FUNC_CALL_FROM_ISR
882 #define tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, ret )
885 #ifndef traceQUEUE_REGISTRY_ADD
886 #define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName )
889 #ifndef traceTASK_NOTIFY_TAKE_BLOCK
890 #define traceTASK_NOTIFY_TAKE_BLOCK( uxIndexToWait )
893 #ifndef traceTASK_NOTIFY_TAKE
894 #define traceTASK_NOTIFY_TAKE( uxIndexToWait )
897 #ifndef traceTASK_NOTIFY_WAIT_BLOCK
898 #define traceTASK_NOTIFY_WAIT_BLOCK( uxIndexToWait )
901 #ifndef traceTASK_NOTIFY_WAIT
902 #define traceTASK_NOTIFY_WAIT( uxIndexToWait )
905 #ifndef traceTASK_NOTIFY
906 #define traceTASK_NOTIFY( uxIndexToNotify )
909 #ifndef traceTASK_NOTIFY_FROM_ISR
910 #define traceTASK_NOTIFY_FROM_ISR( uxIndexToNotify )
913 #ifndef traceTASK_NOTIFY_GIVE_FROM_ISR
914 #define traceTASK_NOTIFY_GIVE_FROM_ISR( uxIndexToNotify )
917 #ifndef traceISR_EXIT_TO_SCHEDULER
918 #define traceISR_EXIT_TO_SCHEDULER()
921 #ifndef traceISR_EXIT
922 #define traceISR_EXIT()
925 #ifndef traceISR_ENTER
926 #define traceISR_ENTER()
929 #ifndef traceSTREAM_BUFFER_CREATE_FAILED
930 #define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
933 #ifndef traceSTREAM_BUFFER_CREATE_STATIC_FAILED
934 #define traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer )
937 #ifndef traceSTREAM_BUFFER_CREATE
938 #define traceSTREAM_BUFFER_CREATE( pxStreamBuffer, xIsMessageBuffer )
941 #ifndef traceSTREAM_BUFFER_DELETE
942 #define traceSTREAM_BUFFER_DELETE( xStreamBuffer )
945 #ifndef traceSTREAM_BUFFER_RESET
946 #define traceSTREAM_BUFFER_RESET( xStreamBuffer )
949 #ifndef traceBLOCKING_ON_STREAM_BUFFER_SEND
950 #define traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer )
953 #ifndef traceSTREAM_BUFFER_SEND
954 #define traceSTREAM_BUFFER_SEND( xStreamBuffer, xBytesSent )
957 #ifndef traceSTREAM_BUFFER_SEND_FAILED
958 #define traceSTREAM_BUFFER_SEND_FAILED( xStreamBuffer )
961 #ifndef traceSTREAM_BUFFER_SEND_FROM_ISR
962 #define traceSTREAM_BUFFER_SEND_FROM_ISR( xStreamBuffer, xBytesSent )
965 #ifndef traceBLOCKING_ON_STREAM_BUFFER_RECEIVE
966 #define traceBLOCKING_ON_STREAM_BUFFER_RECEIVE( xStreamBuffer )
969 #ifndef traceSTREAM_BUFFER_RECEIVE
970 #define traceSTREAM_BUFFER_RECEIVE( xStreamBuffer, xReceivedLength )
973 #ifndef traceSTREAM_BUFFER_RECEIVE_FAILED
974 #define traceSTREAM_BUFFER_RECEIVE_FAILED( xStreamBuffer )
977 #ifndef traceSTREAM_BUFFER_RECEIVE_FROM_ISR
978 #define traceSTREAM_BUFFER_RECEIVE_FROM_ISR( xStreamBuffer, xReceivedLength )
981 #ifndef configGENERATE_RUN_TIME_STATS
982 #define configGENERATE_RUN_TIME_STATS 0
985 #if ( configGENERATE_RUN_TIME_STATS == 1 )
987 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
988 #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.
989 #endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */
991 #ifndef portGET_RUN_TIME_COUNTER_VALUE
992 #ifndef portALT_GET_RUN_TIME_COUNTER_VALUE
993 #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.
994 #endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */
995 #endif /* portGET_RUN_TIME_COUNTER_VALUE */
997 #endif /* configGENERATE_RUN_TIME_STATS */
999 #ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
1000 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
1003 #ifndef configUSE_MALLOC_FAILED_HOOK
1004 #define configUSE_MALLOC_FAILED_HOOK 0
1007 #ifndef portPRIVILEGE_BIT
1008 #define portPRIVILEGE_BIT ( ( UBaseType_t ) 0x00 )
1011 #ifndef portYIELD_WITHIN_API
1012 #define portYIELD_WITHIN_API portYIELD
1015 #ifndef portSUPPRESS_TICKS_AND_SLEEP
1016 #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime )
1019 #ifndef configEXPECTED_IDLE_TIME_BEFORE_SLEEP
1020 #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 2
1023 #if configEXPECTED_IDLE_TIME_BEFORE_SLEEP < 2
1024 #error configEXPECTED_IDLE_TIME_BEFORE_SLEEP must not be less than 2
1027 #ifndef configUSE_TICKLESS_IDLE
1028 #define configUSE_TICKLESS_IDLE 0
1031 #ifndef configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING
1032 #define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING( x )
1035 #ifndef configPRE_SLEEP_PROCESSING
1036 #define configPRE_SLEEP_PROCESSING( x )
1039 #ifndef configPOST_SLEEP_PROCESSING
1040 #define configPOST_SLEEP_PROCESSING( x )
1043 #ifndef configUSE_QUEUE_SETS
1044 #define configUSE_QUEUE_SETS 0
1047 #ifndef portTASK_USES_FLOATING_POINT
1048 #define portTASK_USES_FLOATING_POINT()
1051 #ifndef portALLOCATE_SECURE_CONTEXT
1052 #define portALLOCATE_SECURE_CONTEXT( ulSecureStackSize )
1055 #ifndef portDONT_DISCARD
1056 #define portDONT_DISCARD
1059 #ifndef configUSE_TIME_SLICING
1060 #define configUSE_TIME_SLICING 1
1063 #ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS
1064 #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
1067 #ifndef configUSE_STATS_FORMATTING_FUNCTIONS
1068 #define configUSE_STATS_FORMATTING_FUNCTIONS 0
1071 #ifndef portASSERT_IF_INTERRUPT_PRIORITY_INVALID
1072 #define portASSERT_IF_INTERRUPT_PRIORITY_INVALID()
1075 #ifndef configUSE_TRACE_FACILITY
1076 #define configUSE_TRACE_FACILITY 0
1079 #ifndef mtCOVERAGE_TEST_MARKER
1080 #define mtCOVERAGE_TEST_MARKER()
1083 #ifndef mtCOVERAGE_TEST_DELAY
1084 #define mtCOVERAGE_TEST_DELAY()
1087 #ifndef portASSERT_IF_IN_ISR
1088 #define portASSERT_IF_IN_ISR()
1091 #ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
1092 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
1095 #ifndef configAPPLICATION_ALLOCATED_HEAP
1096 #define configAPPLICATION_ALLOCATED_HEAP 0
1099 #ifndef configENABLE_HEAP_PROTECTOR
1100 #define configENABLE_HEAP_PROTECTOR 0
1103 #ifndef configUSE_TASK_NOTIFICATIONS
1104 #define configUSE_TASK_NOTIFICATIONS 1
1107 #ifndef configTASK_NOTIFICATION_ARRAY_ENTRIES
1108 #define configTASK_NOTIFICATION_ARRAY_ENTRIES 1
1111 #if configTASK_NOTIFICATION_ARRAY_ENTRIES < 1
1112 #error configTASK_NOTIFICATION_ARRAY_ENTRIES must be at least 1
1115 #ifndef configUSE_POSIX_ERRNO
1116 #define configUSE_POSIX_ERRNO 0
1119 #ifndef configUSE_SB_COMPLETED_CALLBACK
1121 /* By default per-instance callbacks are not enabled for stream buffer or message buffer. */
1122 #define configUSE_SB_COMPLETED_CALLBACK 0
1125 #ifndef portTICK_TYPE_IS_ATOMIC
1126 #define portTICK_TYPE_IS_ATOMIC 0
1129 #ifndef configSUPPORT_STATIC_ALLOCATION
1130 /* Defaults to 0 for backward compatibility. */
1131 #define configSUPPORT_STATIC_ALLOCATION 0
1134 #ifndef configSUPPORT_DYNAMIC_ALLOCATION
1135 /* Defaults to 1 for backward compatibility. */
1136 #define configSUPPORT_DYNAMIC_ALLOCATION 1
1139 #if ( ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION != 1 ) )
1140 #error configUSE_STATS_FORMATTING_FUNCTIONS cannot be used without dynamic allocation, but configSUPPORT_DYNAMIC_ALLOCATION is not set to 1.
1143 #if ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 )
1144 #if ( ( configUSE_TRACE_FACILITY != 1 ) && ( configGENERATE_RUN_TIME_STATS != 1 ) )
1145 #error configUSE_STATS_FORMATTING_FUNCTIONS is 1 but the functions it enables are not used because neither configUSE_TRACE_FACILITY or configGENERATE_RUN_TIME_STATS are 1. Set configUSE_STATS_FORMATTING_FUNCTIONS to 0 in FreeRTOSConfig.h.
1149 #ifndef configSTACK_DEPTH_TYPE
1151 /* Defaults to uint16_t for backward compatibility, but can be overridden
1152 * in FreeRTOSConfig.h if uint16_t is too restrictive. */
1153 #define configSTACK_DEPTH_TYPE uint16_t
1156 #ifndef configRUN_TIME_COUNTER_TYPE
1158 /* Defaults to uint32_t for backward compatibility, but can be overridden in
1159 * FreeRTOSConfig.h if uint32_t is too restrictive. */
1161 #define configRUN_TIME_COUNTER_TYPE uint32_t
1164 #ifndef configMESSAGE_BUFFER_LENGTH_TYPE
1166 /* Defaults to size_t for backward compatibility, but can be overridden
1167 * in FreeRTOSConfig.h if lengths will always be less than the number of bytes
1169 #define configMESSAGE_BUFFER_LENGTH_TYPE size_t
1172 /* Sanity check the configuration. */
1173 #if ( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) )
1174 #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1.
1177 #if ( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) )
1178 #error configUSE_MUTEXES must be set to 1 to use recursive mutexes
1181 #if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configUSE_TASK_PREEMPTION_DISABLE != 0 ) )
1182 #error configRUN_MULTIPLE_PRIORITIES must be set to 1 to use task preemption disable
1185 #if ( ( configUSE_PREEMPTION == 0 ) && ( configUSE_TASK_PREEMPTION_DISABLE != 0 ) )
1186 #error configUSE_PREEMPTION must be set to 1 to use task preemption disable
1189 #if ( ( configNUMBER_OF_CORES == 1 ) && ( configUSE_TASK_PREEMPTION_DISABLE != 0 ) )
1190 #error configUSE_TASK_PREEMPTION_DISABLE is not supported in single core FreeRTOS
1193 #if ( ( configNUMBER_OF_CORES == 1 ) && ( configUSE_CORE_AFFINITY != 0 ) )
1194 #error configUSE_CORE_AFFINITY is not supported in single core FreeRTOS
1197 #if ( ( configNUMBER_OF_CORES > 1 ) && ( configUSE_PORT_OPTIMISED_TASK_SELECTION != 0 ) )
1198 #error configUSE_PORT_OPTIMISED_TASK_SELECTION is not supported in SMP FreeRTOS
1201 #ifndef configINITIAL_TICK_COUNT
1202 #define configINITIAL_TICK_COUNT 0
1205 #if ( portTICK_TYPE_IS_ATOMIC == 0 )
1207 /* Either variables of tick type cannot be read atomically, or
1208 * portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when
1209 * the tick count is returned to the standard critical section macros. */
1210 #define portTICK_TYPE_ENTER_CRITICAL() portENTER_CRITICAL()
1211 #define portTICK_TYPE_EXIT_CRITICAL() portEXIT_CRITICAL()
1212 #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
1213 #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) )
1216 /* The tick type can be read atomically, so critical sections used when the
1217 * tick count is returned can be defined away. */
1218 #define portTICK_TYPE_ENTER_CRITICAL()
1219 #define portTICK_TYPE_EXIT_CRITICAL()
1220 #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0
1221 #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) ( x )
1222 #endif /* if ( portTICK_TYPE_IS_ATOMIC == 0 ) */
1224 /* Definitions to allow backward compatibility with FreeRTOS versions prior to
1226 #ifndef configENABLE_BACKWARD_COMPATIBILITY
1227 #define configENABLE_BACKWARD_COMPATIBILITY 1
1230 #ifndef configPRINTF
1232 /* configPRINTF() was not defined, so define it away to nothing. To use
1233 * configPRINTF() then define it as follows (where MyPrintFunction() is
1234 * provided by the application writer):
1236 * void MyPrintFunction(const char *pcFormat, ... );
1237 #define configPRINTF( X ) MyPrintFunction X
1239 * Then call like a standard printf() function, but placing brackets around
1240 * all parameters so they are passed as a single parameter. For example:
1241 * configPRINTF( ("Value = %d", MyVariable) ); */
1242 #define configPRINTF( X )
1247 /* The application writer has not provided their own MAX macro, so define
1248 * the following generic implementation. */
1249 #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
1254 /* The application writer has not provided their own MIN macro, so define
1255 * the following generic implementation. */
1256 #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
1259 #if configENABLE_BACKWARD_COMPATIBILITY == 1
1260 #define eTaskStateGet eTaskGetState
1261 #define portTickType TickType_t
1262 #define xTaskHandle TaskHandle_t
1263 #define xQueueHandle QueueHandle_t
1264 #define xSemaphoreHandle SemaphoreHandle_t
1265 #define xQueueSetHandle QueueSetHandle_t
1266 #define xQueueSetMemberHandle QueueSetMemberHandle_t
1267 #define xTimeOutType TimeOut_t
1268 #define xMemoryRegion MemoryRegion_t
1269 #define xTaskParameters TaskParameters_t
1270 #define xTaskStatusType TaskStatus_t
1271 #define xTimerHandle TimerHandle_t
1272 #define xCoRoutineHandle CoRoutineHandle_t
1273 #define pdTASK_HOOK_CODE TaskHookFunction_t
1274 #define portTICK_RATE_MS portTICK_PERIOD_MS
1275 #define pcTaskGetTaskName pcTaskGetName
1276 #define pcTimerGetTimerName pcTimerGetName
1277 #define pcQueueGetQueueName pcQueueGetName
1278 #define vTaskGetTaskInfo vTaskGetInfo
1279 #define xTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
1281 /* Backward compatibility within the scheduler code only - these definitions
1282 * are not really required but are included for completeness. */
1283 #define tmrTIMER_CALLBACK TimerCallbackFunction_t
1284 #define pdTASK_CODE TaskFunction_t
1285 #define xListItem ListItem_t
1286 #define xList List_t
1288 /* For libraries that break the list data hiding, and access list structure
1289 * members directly (which is not supposed to be done). */
1290 #define pxContainer pvContainer
1291 #endif /* configENABLE_BACKWARD_COMPATIBILITY */
1293 #if ( configUSE_ALTERNATIVE_API != 0 )
1294 #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0
1297 /* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even
1298 * if floating point hardware is otherwise supported by the FreeRTOS port in use.
1299 * This constant is not supported by all FreeRTOS ports that include floating
1301 #ifndef configUSE_TASK_FPU_SUPPORT
1302 #define configUSE_TASK_FPU_SUPPORT 1
1305 /* Set configENABLE_MPU to 1 to enable MPU support and 0 to disable it. This is
1306 * currently used in ARMv8M ports. */
1307 #ifndef configENABLE_MPU
1308 #define configENABLE_MPU 0
1311 /* Set configENABLE_FPU to 1 to enable FPU support and 0 to disable it. This is
1312 * currently used in ARMv8M ports. */
1313 #ifndef configENABLE_FPU
1314 #define configENABLE_FPU 1
1317 /* Set configENABLE_MVE to 1 to enable MVE support and 0 to disable it. This is
1318 * currently used in ARMv8M ports. */
1319 #ifndef configENABLE_MVE
1320 #define configENABLE_MVE 0
1323 /* Set configENABLE_TRUSTZONE to 1 enable TrustZone support and 0 to disable it.
1324 * This is currently used in ARMv8M ports. */
1325 #ifndef configENABLE_TRUSTZONE
1326 #define configENABLE_TRUSTZONE 1
1329 /* Set configRUN_FREERTOS_SECURE_ONLY to 1 to run the FreeRTOS ARMv8M port on
1330 * the Secure Side only. */
1331 #ifndef configRUN_FREERTOS_SECURE_ONLY
1332 #define configRUN_FREERTOS_SECURE_ONLY 0
1335 #ifndef configRUN_ADDITIONAL_TESTS
1336 #define configRUN_ADDITIONAL_TESTS 0
1339 /* Sometimes the FreeRTOSConfig.h settings only allow a task to be created using
1340 * dynamically allocated RAM, in which case when any task is deleted it is known
1341 * that both the task's stack and TCB need to be freed. Sometimes the
1342 * FreeRTOSConfig.h settings only allow a task to be created using statically
1343 * allocated RAM, in which case when any task is deleted it is known that neither
1344 * the task's stack or TCB should be freed. Sometimes the FreeRTOSConfig.h
1345 * settings allow a task to be created using either statically or dynamically
1346 * allocated RAM, in which case a member of the TCB is used to record whether the
1347 * stack and/or TCB were allocated statically or dynamically, so when a task is
1348 * deleted the RAM that was allocated dynamically is freed again and no attempt is
1349 * made to free the RAM that was allocated statically.
1350 * tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is only true if it is possible for a
1351 * task to be created using either statically or dynamically allocated RAM. Note
1352 * that if portUSING_MPU_WRAPPERS is 1 then a protected task can be created with
1353 * a statically allocated stack and a dynamically allocated TCB.
1355 * The following table lists various combinations of portUSING_MPU_WRAPPERS,
1356 * configSUPPORT_DYNAMIC_ALLOCATION and configSUPPORT_STATIC_ALLOCATION and
1357 * when it is possible to have both static and dynamic allocation:
1358 * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
1359 * | MPU | Dynamic | Static | Available Functions | Possible Allocations | Both Dynamic and | Need Free |
1360 * | | | | | | Static Possible | |
1361 * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
1362 * | 0 | 0 | 1 | xTaskCreateStatic | TCB - Static, Stack - Static | No | No |
1363 * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1364 * | 0 | 1 | 0 | xTaskCreate | TCB - Dynamic, Stack - Dynamic | No | Yes |
1365 * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1366 * | 0 | 1 | 1 | xTaskCreate, | 1. TCB - Dynamic, Stack - Dynamic | Yes | Yes |
1367 * | | | | xTaskCreateStatic | 2. TCB - Static, Stack - Static | | |
1368 * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1369 * | 1 | 0 | 1 | xTaskCreateStatic, | TCB - Static, Stack - Static | No | No |
1370 * | | | | xTaskCreateRestrictedStatic | | | |
1371 * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1372 * | 1 | 1 | 0 | xTaskCreate, | 1. TCB - Dynamic, Stack - Dynamic | Yes | Yes |
1373 * | | | | xTaskCreateRestricted | 2. TCB - Dynamic, Stack - Static | | |
1374 * +-----|---------|--------|-----------------------------|-----------------------------------|------------------|-----------|
1375 * | 1 | 1 | 1 | xTaskCreate, | 1. TCB - Dynamic, Stack - Dynamic | Yes | Yes |
1376 * | | | | xTaskCreateStatic, | 2. TCB - Dynamic, Stack - Static | | |
1377 * | | | | xTaskCreateRestricted, | 3. TCB - Static, Stack - Static | | |
1378 * | | | | xTaskCreateRestrictedStatic | | | |
1379 * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
1381 #define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE \
1382 ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \
1383 ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) )
1386 * In line with software engineering best practice, FreeRTOS implements a strict
1387 * data hiding policy, so the real structures used by FreeRTOS to maintain the
1388 * state of tasks, queues, semaphores, etc. are not accessible to the application
1389 * code. However, if the application writer wants to statically allocate such
1390 * an object then the size of the object needs to be known. Dummy structures
1391 * that are guaranteed to have the same size and alignment requirements of the
1392 * real objects are used for this purpose. The dummy list and list item
1393 * structures below are used for inclusion in such a dummy structure.
1395 struct xSTATIC_LIST_ITEM
1397 #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1401 void * pvDummy3[ 4 ];
1402 #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1406 typedef struct xSTATIC_LIST_ITEM StaticListItem_t;
1408 #if ( configUSE_MINI_LIST_ITEM == 1 )
1409 /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
1410 struct xSTATIC_MINI_LIST_ITEM
1412 #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1416 void * pvDummy3[ 2 ];
1418 typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t;
1419 #else /* if ( configUSE_MINI_LIST_ITEM == 1 ) */
1420 typedef struct xSTATIC_LIST_ITEM StaticMiniListItem_t;
1421 #endif /* if ( configUSE_MINI_LIST_ITEM == 1 ) */
1423 /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
1424 typedef struct xSTATIC_LIST
1426 #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1429 UBaseType_t uxDummy2;
1431 StaticMiniListItem_t xDummy4;
1432 #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
1438 * In line with software engineering best practice, especially when supplying a
1439 * library that is likely to change in future versions, FreeRTOS implements a
1440 * strict data hiding policy. This means the Task structure used internally by
1441 * FreeRTOS is not accessible to application code. However, if the application
1442 * writer wants to statically allocate the memory required to create a task then
1443 * the size of the task object needs to be known. The StaticTask_t structure
1444 * below is provided for this purpose. Its sizes and alignment requirements are
1445 * guaranteed to match those of the genuine structure, no matter which
1446 * architecture is being used, and no matter how the values in FreeRTOSConfig.h
1447 * are set. Its contents are somewhat obfuscated in the hope users will
1448 * recognise that it would be unwise to make direct use of the structure members.
1450 typedef struct xSTATIC_TCB
1453 #if ( portUSING_MPU_WRAPPERS == 1 )
1454 xMPU_SETTINGS xDummy2;
1456 #if ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 )
1457 UBaseType_t uxDummy26;
1459 StaticListItem_t xDummy3[ 2 ];
1460 UBaseType_t uxDummy5;
1462 #if ( configNUMBER_OF_CORES > 1 )
1463 BaseType_t xDummy23;
1464 UBaseType_t uxDummy24;
1466 uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ];
1467 #if ( configUSE_TASK_PREEMPTION_DISABLE == 1 )
1468 BaseType_t xDummy25;
1470 #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
1473 #if ( portCRITICAL_NESTING_IN_TCB == 1 )
1474 UBaseType_t uxDummy9;
1476 #if ( configUSE_TRACE_FACILITY == 1 )
1477 UBaseType_t uxDummy10[ 2 ];
1479 #if ( configUSE_MUTEXES == 1 )
1480 UBaseType_t uxDummy12[ 2 ];
1482 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
1485 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
1486 void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
1488 #if ( configGENERATE_RUN_TIME_STATS == 1 )
1489 configRUN_TIME_COUNTER_TYPE ulDummy16;
1491 #if ( configUSE_C_RUNTIME_TLS_SUPPORT == 1 )
1492 configTLS_BLOCK_TYPE xDummy17;
1494 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1495 uint32_t ulDummy18[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
1496 uint8_t ucDummy19[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
1498 #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 )
1502 #if ( INCLUDE_xTaskAbortDelay == 1 )
1505 #if ( configUSE_POSIX_ERRNO == 1 )
1511 * In line with software engineering best practice, especially when supplying a
1512 * library that is likely to change in future versions, FreeRTOS implements a
1513 * strict data hiding policy. This means the Queue structure used internally by
1514 * FreeRTOS is not accessible to application code. However, if the application
1515 * writer wants to statically allocate the memory required to create a queue
1516 * then the size of the queue object needs to be known. The StaticQueue_t
1517 * structure below is provided for this purpose. Its sizes and alignment
1518 * requirements are guaranteed to match those of the genuine structure, no
1519 * matter which architecture is being used, and no matter how the values in
1520 * FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in the hope
1521 * users will recognise that it would be unwise to make direct use of the
1522 * structure members.
1524 typedef struct xSTATIC_QUEUE
1526 void * pvDummy1[ 3 ];
1531 UBaseType_t uxDummy2;
1534 StaticList_t xDummy3[ 2 ];
1535 UBaseType_t uxDummy4[ 3 ];
1536 uint8_t ucDummy5[ 2 ];
1538 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
1542 #if ( configUSE_QUEUE_SETS == 1 )
1546 #if ( configUSE_TRACE_FACILITY == 1 )
1547 UBaseType_t uxDummy8;
1551 typedef StaticQueue_t StaticSemaphore_t;
1554 * In line with software engineering best practice, especially when supplying a
1555 * library that is likely to change in future versions, FreeRTOS implements a
1556 * strict data hiding policy. This means the event group structure used
1557 * internally by FreeRTOS is not accessible to application code. However, if
1558 * the application writer wants to statically allocate the memory required to
1559 * create an event group then the size of the event group object needs to be
1560 * know. The StaticEventGroup_t structure below is provided for this purpose.
1561 * Its sizes and alignment requirements are guaranteed to match those of the
1562 * genuine structure, no matter which architecture is being used, and no matter
1563 * how the values in FreeRTOSConfig.h are set. Its contents are somewhat
1564 * obfuscated in the hope users will recognise that it would be unwise to make
1565 * direct use of the structure members.
1567 typedef struct xSTATIC_EVENT_GROUP
1570 StaticList_t xDummy2;
1572 #if ( configUSE_TRACE_FACILITY == 1 )
1573 UBaseType_t uxDummy3;
1576 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
1579 } StaticEventGroup_t;
1582 * In line with software engineering best practice, especially when supplying a
1583 * library that is likely to change in future versions, FreeRTOS implements a
1584 * strict data hiding policy. This means the software timer structure used
1585 * internally by FreeRTOS is not accessible to application code. However, if
1586 * the application writer wants to statically allocate the memory required to
1587 * create a software timer then the size of the queue object needs to be known.
1588 * The StaticTimer_t structure below is provided for this purpose. Its sizes
1589 * and alignment requirements are guaranteed to match those of the genuine
1590 * structure, no matter which architecture is being used, and no matter how the
1591 * values in FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in
1592 * the hope users will recognise that it would be unwise to make direct use of
1593 * the structure members.
1595 typedef struct xSTATIC_TIMER
1598 StaticListItem_t xDummy2;
1601 TaskFunction_t pvDummy6;
1602 #if ( configUSE_TRACE_FACILITY == 1 )
1603 UBaseType_t uxDummy7;
1609 * In line with software engineering best practice, especially when supplying a
1610 * library that is likely to change in future versions, FreeRTOS implements a
1611 * strict data hiding policy. This means the stream buffer structure used
1612 * internally by FreeRTOS is not accessible to application code. However, if
1613 * the application writer wants to statically allocate the memory required to
1614 * create a stream buffer then the size of the stream buffer object needs to be
1615 * known. The StaticStreamBuffer_t structure below is provided for this
1616 * purpose. Its size and alignment requirements are guaranteed to match those
1617 * of the genuine structure, no matter which architecture is being used, and
1618 * no matter how the values in FreeRTOSConfig.h are set. Its contents are
1619 * somewhat obfuscated in the hope users will recognise that it would be unwise
1620 * to make direct use of the structure members.
1622 typedef struct xSTATIC_STREAM_BUFFER
1624 size_t uxDummy1[ 4 ];
1625 void * pvDummy2[ 3 ];
1627 #if ( configUSE_TRACE_FACILITY == 1 )
1628 UBaseType_t uxDummy4;
1630 #if ( configUSE_SB_COMPLETED_CALLBACK == 1 )
1631 void * pvDummy5[ 2 ];
1633 } StaticStreamBuffer_t;
1635 /* Message buffers are built on stream buffers. */
1636 typedef StaticStreamBuffer_t StaticMessageBuffer_t;
1644 #endif /* INC_FREERTOS_H */