FreeRTOSConfig.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef FREERTOS_CONFIG_H
  7. #define FREERTOS_CONFIG_H
  8. #include "sdkconfig.h"
  9. /*
  10. This file get's pulled into assembly sources. Therefore, some includes need to be wrapped in #ifndef __ASSEMBLER__
  11. */
  12. #ifndef __ASSEMBLER__
  13. #include <assert.h> //For configASSERT()
  14. #endif /* def __ASSEMBLER__ */
  15. #ifdef CONFIG_FREERTOS_SMP
  16. // Pull in the SMP configuration
  17. #include "freertos/FreeRTOSConfig_smp.h"
  18. #else // CONFIG_FREERTOS_SMP
  19. // The arch-specific FreeRTOSConfig_arch.h in port/<arch>/include.
  20. #include "freertos/FreeRTOSConfig_arch.h"
  21. #if !(defined(FREERTOS_CONFIG_XTENSA_H) || defined(FREERTOS_CONFIG_RISCV_H) || defined(FREERTOS_CONFIG_LINUX_H))
  22. #error "Needs architecture-speific FreeRTOSConfig.h!"
  23. #endif
  24. /* ----------------------------------------------------- Helpers -------------------------------------------------------
  25. * - Macros that the FreeRTOS configuration macros depend on
  26. * ------------------------------------------------------------------------------------------------------------------ */
  27. /* Higher stack checker modes cause overhead on each function call */
  28. #if CONFIG_STACK_CHECK_ALL || CONFIG_STACK_CHECK_STRONG
  29. #define STACK_OVERHEAD_CHECKER 256
  30. #else
  31. #define STACK_OVERHEAD_CHECKER 0
  32. #endif
  33. /* with optimizations disabled, scheduler uses additional stack */
  34. #if CONFIG_COMPILER_OPTIMIZATION_NONE
  35. #define STACK_OVERHEAD_OPTIMIZATION 320
  36. #else
  37. #define STACK_OVERHEAD_OPTIMIZATION 0
  38. #endif
  39. /* apptrace mdule increases minimum stack usage */
  40. #if CONFIG_APPTRACE_ENABLE
  41. #define STACK_OVERHEAD_APPTRACE 1280
  42. #else
  43. #define STACK_OVERHEAD_APPTRACE 0
  44. #endif
  45. /* Stack watchpoint decreases minimum usable stack size by up to 60 bytes.
  46. See FreeRTOS FREERTOS_WATCHPOINT_END_OF_STACK option in Kconfig. */
  47. #if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
  48. #define STACK_OVERHEAD_WATCHPOINT 60
  49. #else
  50. #define STACK_OVERHEAD_WATCHPOINT 0
  51. #endif
  52. #define configSTACK_OVERHEAD_TOTAL ( \
  53. STACK_OVERHEAD_CHECKER + \
  54. STACK_OVERHEAD_OPTIMIZATION + \
  55. STACK_OVERHEAD_APPTRACE + \
  56. STACK_OVERHEAD_WATCHPOINT)
  57. /* ------------------------------------------------- FreeRTOS Config ---------------------------------------------------
  58. * - All Vanilla FreeRTOS configuration goes into this section
  59. * - Keep this section in-sync with the corresponding version of single-core upstream version of FreeRTOS
  60. * - Don't put any SMP or ESP-IDF exclusive FreeRTOS configurations here. Those go into the next section
  61. * - Not all FreeRTOS configuration are listed. Some configurations have default values set in FreeRTOS.h thus don't
  62. * need to be explicitly defined.
  63. * ------------------------------------------------------------------------------------------------------------------ */
  64. /*-----------------------------------------------------------
  65. * Application specific definitions.
  66. *
  67. * These definitions should be adjusted for your particular hardware and
  68. * application requirements.
  69. *
  70. * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
  71. * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
  72. *
  73. * See http://www.freertos.org/a00110.html
  74. *----------------------------------------------------------*/
  75. // ------------------ Scheduler Related --------------------
  76. // #define configUSE_PREEMPTION 1
  77. // #define configUSE_TICKLESS_IDLE CONFIG_FREERTOS_USE_TICKLESS_IDLE
  78. #if configUSE_TICKLESS_IDLE
  79. #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP CONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP
  80. #endif // configUSE_TICKLESS_IDLE
  81. #define configCPU_CLOCK_HZ (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000)
  82. // #define configTICK_RATE_HZ CONFIG_FREERTOS_HZ
  83. // #define configMAX_PRIORITIES ( 25 ) //This has impact on speed of search for highest priority
  84. // #define configMINIMAL_STACK_SIZE ( 768 + configSTACK_OVERHEAD_TOTAL )
  85. // #define configUSE_TIME_SLICING 1
  86. // #define configUSE_16_BIT_TICKS 0
  87. #define configIDLE_SHOULD_YIELD 0
  88. #define configKERNEL_INTERRUPT_PRIORITY 1 // Todo: This currently isn't used anywhere
  89. // ------------- Synchronization Primitives ----------------
  90. // #define configUSE_MUTEXES 1
  91. // #define configUSE_RECURSIVE_MUTEXES 1
  92. #define configUSE_COUNTING_SEMAPHORES 1
  93. // #define configUSE_QUEUE_SETS 1
  94. // #define configQUEUE_REGISTRY_SIZE CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE
  95. #define configUSE_TASK_NOTIFICATIONS 1
  96. // #define configTASK_NOTIFICATION_ARRAY_ENTRIES 1
  97. // ----------------------- System --------------------------
  98. // #define configMAX_TASK_NAME_LEN CONFIG_FREERTOS_MAX_TASK_NAME_LEN
  99. #define configNUM_THREAD_LOCAL_STORAGE_POINTERS CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS
  100. #ifndef CONFIG_IDF_TARGET_LINUX
  101. #define configSTACK_DEPTH_TYPE uint32_t
  102. #define configUSE_NEWLIB_REENTRANT 1
  103. #endif
  104. #if CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY
  105. #define configENABLE_BACKWARD_COMPATIBILITY 1
  106. #else
  107. #define configENABLE_BACKWARD_COMPATIBILITY 0
  108. #endif
  109. // #define configASSERT(a) assert(a)
  110. #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H 1
  111. // ----------------------- Memory -------------------------
  112. #define configSUPPORT_STATIC_ALLOCATION 1
  113. #define configSUPPORT_DYNAMIC_ALLOCATION 1
  114. // We define the heap to span all of the non-statically-allocated shared RAM. ToDo: Make sure there
  115. // is some space left for the app and main cpu when running outside of a thread.
  116. // #define configTOTAL_HEAP_SIZE (&_heap_end - &_heap_start)//( ( size_t ) (64 * 1024) )
  117. // #define configAPPLICATION_ALLOCATED_HEAP 1
  118. #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
  119. // ------------------------ Hooks --------------------------
  120. // #define configUSE_IDLE_HOOK CONFIG_FREERTOS_USE_IDLE_HOOK
  121. // #define configUSE_TICK_HOOK CONFIG_FREERTOS_USE_TICK_HOOK
  122. #if CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE
  123. #define configCHECK_FOR_STACK_OVERFLOW 0
  124. #elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL
  125. #define configCHECK_FOR_STACK_OVERFLOW 1
  126. #elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY
  127. #define configCHECK_FOR_STACK_OVERFLOW 2
  128. #endif
  129. #define configRECORD_STACK_HIGH_ADDRESS 1
  130. // ------------------- Run-time Stats ----------------------
  131. #ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
  132. #define configGENERATE_RUN_TIME_STATS 1 /* Used by vTaskGetRunTimeStats() */
  133. #endif
  134. #ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY
  135. #define configUSE_TRACE_FACILITY 1 /* Used by uxTaskGetSystemState(), and other trace facility functions */
  136. #endif
  137. #ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
  138. #define configUSE_STATS_FORMATTING_FUNCTIONS 1 /* Used by vTaskList() */
  139. #endif
  140. // -------------------- Co-routines -----------------------
  141. #define configUSE_CO_ROUTINES 0
  142. #define configMAX_CO_ROUTINE_PRIORITIES 2
  143. // ------------------- Software Timer ----------------------
  144. // #define configUSE_TIMERS 1
  145. // #define configTIMER_TASK_PRIORITY CONFIG_FREERTOS_TIMER_TASK_PRIORITY
  146. // #define configTIMER_QUEUE_LENGTH CONFIG_FREERTOS_TIMER_QUEUE_LENGTH
  147. // #define configTIMER_TASK_STACK_DEPTH CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH
  148. // -------------------- API Includes -----------------------
  149. #if CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY
  150. #define configENABLE_BACKWARD_COMPATIBILITY 1
  151. #else
  152. #define configENABLE_BACKWARD_COMPATIBILITY 0
  153. #endif
  154. #define INCLUDE_vTaskPrioritySet 1
  155. #define INCLUDE_uxTaskPriorityGet 1
  156. #define INCLUDE_vTaskDelete 1
  157. #define INCLUDE_vTaskSuspend 1
  158. #define INCLUDE_xTaskDelayUntil 1
  159. #define INCLUDE_vTaskDelay 1
  160. #define INCLUDE_xTaskGetIdleTaskHandle 1
  161. #define INCLUDE_xTaskAbortDelay 1
  162. #define INCLUDE_xSemaphoreGetMutexHolder 1
  163. #define INCLUDE_xTaskGetHandle 1
  164. #define INCLUDE_uxTaskGetStackHighWaterMark 1
  165. #define INCLUDE_uxTaskGetStackHighWaterMark2 1
  166. #define INCLUDE_eTaskGetState 1
  167. #define INCLUDE_xTaskResumeFromISR 1
  168. // #define INCLUDE_xTimerPendFunctionCall 1
  169. #define INCLUDE_xTaskGetSchedulerState 1
  170. #define INCLUDE_xTaskGetCurrentTaskHandle 1
  171. // Unlisted
  172. #define INCLUDE_pxTaskGetStackStart 1
  173. // -------------------- Trace Macros -----------------------
  174. /*
  175. For trace macros.
  176. Note: Include trace macros here and not above as trace macros are dependent on some of the FreeRTOS configs
  177. */
  178. #ifndef __ASSEMBLER__
  179. #if CONFIG_SYSVIEW_ENABLE
  180. #include "SEGGER_SYSVIEW_FreeRTOS.h"
  181. #undef INLINE // to avoid redefinition
  182. #endif // CONFIG_SYSVIEW_ENABLE
  183. #endif /* def __ASSEMBLER__ */
  184. /* ------------------------------------------------ ESP-IDF Additions --------------------------------------------------
  185. * - All FreeRTOS related configurations no part of Vanilla FreeRTOS goes into this section
  186. * - FreeRTOS configurations related to SMP and ESP-IDF additions go into this section
  187. * ------------------------------------------------------------------------------------------------------------------ */
  188. // ------------------------- SMP ---------------------------
  189. #ifndef CONFIG_FREERTOS_UNICORE
  190. #define portNUM_PROCESSORS 2
  191. #else
  192. #define portNUM_PROCESSORS 1
  193. #endif
  194. #define configNUM_CORES portNUM_PROCESSORS
  195. #ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
  196. #define configTASKLIST_INCLUDE_COREID 1
  197. #endif
  198. // ---------------------- Features -------------------------
  199. #define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS 1
  200. #ifndef configIDLE_TASK_STACK_SIZE
  201. #define configIDLE_TASK_STACK_SIZE CONFIG_FREERTOS_IDLE_TASK_STACKSIZE
  202. #endif
  203. #if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER
  204. #define configCHECK_MUTEX_GIVEN_BY_OWNER 1
  205. #else
  206. #define configCHECK_MUTEX_GIVEN_BY_OWNER 0
  207. #endif
  208. #ifndef __ASSEMBLER__
  209. #if CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP
  210. extern void vPortCleanUpTCB(void *pxTCB);
  211. #define portCLEAN_UP_TCB(pxTCB) vPortCleanUpTCB(pxTCB)
  212. #endif
  213. #endif
  214. // -------------------- Compatibility ----------------------
  215. // backward compatibility for 4.4
  216. #define xTaskRemoveFromUnorderedEventList vTaskRemoveFromUnorderedEventList
  217. #endif // CONFIG_FREERTOS_SMP
  218. #endif /* FREERTOS_CONFIG_H */