1 /*
2     FreeRTOS V10 - Copyright (C) 2021 Real Time Engineers Ltd.
3     All rights reserved
4 
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6 
7     This file is part of the FreeRTOS distribution.
8 
9     FreeRTOS is free software; you can redistribute it and/or modify it under
10     the terms of the GNU General Public License (version 2) as published by the
11     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
12 
13 	***************************************************************************
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<
16     >>!   obliged to provide the source code for proprietary components     !<<
17     >>!   outside of the FreeRTOS kernel.                                   !<<
18 	***************************************************************************
19 
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following
23     link: http://www.freertos.org/a00114.html
24 
25     ***************************************************************************
26      *                                                                       *
27      *    FreeRTOS provides completely free yet professionally developed,    *
28      *    robust, strictly quality controlled, supported, and cross          *
29      *    platform software that is more than just the market leader, it     *
30      *    is the industry's de facto standard.                               *
31      *                                                                       *
32      *    Help yourself get started quickly while simultaneously helping     *
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *
34      *    tutorial book, reference manual, or both:                          *
35      *    http://www.FreeRTOS.org/Documentation                              *
36      *                                                                       *
37     ***************************************************************************
38 
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading
40 	the FAQ page "My application does not run, what could be wrong?".  Have you
41 	defined configASSERT()?
42 
43 	http://www.FreeRTOS.org/support - In return for receiving this top quality
44 	embedded software for free we request you assist our global community by
45 	participating in the support forum.
46 
47 	http://www.FreeRTOS.org/training - Investing in training allows your team to
48 	be as productive as possible as early as possible.  Now you can receive
49 	FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50 	Ltd, and the world's leading authority on the world's leading RTOS.
51 
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.
55 
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
58 
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
61     licenses offer ticketed support, indemnification and commercial middleware.
62 
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64     engineered and independently SIL3 certified version for use in safety and
65     mission critical applications that require provable dependability.
66 
67     1 tab == 4 spaces!
68 */
69 
70 #ifndef FREERTOS_CONFIG_H
71 #define FREERTOS_CONFIG_H
72 
73 #include "sdkconfig.h"
74 
75 /* for likely and unlikely */
76 #include "esp_compiler.h"
77 
78 // The arch-specific FreeRTOSConfig_arch.h in port/<arch>/include.
79 #include "freertos/FreeRTOSConfig_arch.h"
80 
81 #if !(defined(FREERTOS_CONFIG_XTENSA_H) \
82         || defined(FREERTOS_CONFIG_RISCV_H) \
83         || defined(FREERTOS_CONFIG_LINUX_H))
84 #error "Needs architecture-speific FreeRTOSConfig.h!"
85 #endif
86 
87 #ifndef CONFIG_FREERTOS_UNICORE
88 #define portNUM_PROCESSORS                              2
89 #else
90 #define portNUM_PROCESSORS                              1
91 #endif
92 
93 #define portUSING_MPU_WRAPPERS                          0
94 #define configUSE_MUTEX                                 1
95 
96 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS
97 #define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS     1
98 
99 /* configASSERT behaviour */
100 #ifndef __ASSEMBLER__
101 #include <assert.h>
102 
103 // If CONFIG_FREERTOS_ASSERT_DISABLE is set then configASSERT is defined empty later in FreeRTOS.h and the macro
104 // configASSERT_DEFINED remains unset (meaning some warnings are avoided)
105 
106 #if defined(CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE)
107 #define configASSERT(a) if (unlikely(!(a))) {                               \
108         esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__,  \
109                    __FUNCTION__);                                           \
110     }
111 #elif defined(CONFIG_FREERTOS_ASSERT_FAIL_ABORT)
112 #define configASSERT(a) assert(a)
113 #endif
114 
115 #if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
116 #define UNTESTED_FUNCTION() { esp_rom_printf("Untested FreeRTOS function %s\r\n", __FUNCTION__); configASSERT(false); } while(0)
117 #else
118 #define UNTESTED_FUNCTION()
119 #endif
120 
121 #endif /* def __ASSEMBLER__ */
122 
123 /*-----------------------------------------------------------
124  * Application specific definitions.
125  *
126  * These definitions should be adjusted for your particular hardware and
127  * application requirements.
128  *
129  * Note that the default heap size is deliberately kept small so that
130  * the build is more likely to succeed for configurations with limited
131  * memory.
132  *
133  * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
134  * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
135  *----------------------------------------------------------*/
136 
137 #define configUSE_PREEMPTION                            1
138 #define configUSE_IDLE_HOOK                             1
139 #define configUSE_TICK_HOOK                             1
140 #define configRECORD_STACK_HIGH_ADDRESS                 1
141 #define configTICK_RATE_HZ                              ( CONFIG_FREERTOS_HZ )
142 
143 /* This has impact on speed of search for highest priority */
144 #define configMAX_PRIORITIES                            ( 25 )
145 
146 /* Various things that impact minimum stack sizes */
147 
148 /* Higher stack checker modes cause overhead on each function call */
149 #if CONFIG_STACK_CHECK_ALL || CONFIG_STACK_CHECK_STRONG
150 #define configSTACK_OVERHEAD_CHECKER                    256
151 #else
152 #define configSTACK_OVERHEAD_CHECKER                    0
153 #endif
154 
155 /* with optimizations disabled, scheduler uses additional stack */
156 #if CONFIG_COMPILER_OPTIMIZATION_NONE
157 #define configSTACK_OVERHEAD_OPTIMIZATION               320
158 #else
159 #define configSTACK_OVERHEAD_OPTIMIZATION               0
160 #endif
161 
162 /* apptrace mdule increases minimum stack usage */
163 #if CONFIG_APPTRACE_ENABLE
164 #define configSTACK_OVERHEAD_APPTRACE                   1280
165 #else
166 #define configSTACK_OVERHEAD_APPTRACE                   0
167 #endif
168 
169 /* Stack watchpoint decreases minimum usable stack size by up to 60 bytes.
170    See FreeRTOS FREERTOS_WATCHPOINT_END_OF_STACK option in Kconfig. */
171 #if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
172 #define configSTACK_OVERHEAD_WATCHPOINT                   60
173 #else
174 #define configSTACK_OVERHEAD_WATCHPOINT                   0
175 #endif
176 
177 #define configSTACK_OVERHEAD_TOTAL (                                    \
178                                     configSTACK_OVERHEAD_CHECKER +      \
179                                     configSTACK_OVERHEAD_OPTIMIZATION + \
180                                     configSTACK_OVERHEAD_APPTRACE +     \
181                                     configSTACK_OVERHEAD_WATCHPOINT     \
182                                                                         )
183 
184 #define configMINIMAL_STACK_SIZE                        (768 + configSTACK_OVERHEAD_TOTAL)
185 
186 #ifndef configIDLE_TASK_STACK_SIZE
187 #define configIDLE_TASK_STACK_SIZE CONFIG_FREERTOS_IDLE_TASK_STACKSIZE
188 #endif
189 
190 /* Minimal heap size to make sure examples can run on memory limited
191    configs. Adjust this to suit your system. */
192 
193 
194 //We define the heap to span all of the non-statically-allocated shared RAM. ToDo: Make sure there
195 //is some space left for the app and main cpu when running outside of a thread.
196 #define configAPPLICATION_ALLOCATED_HEAP                1
197 #define configTOTAL_HEAP_SIZE                           (&_heap_end - &_heap_start)//( ( size_t ) (64 * 1024) )
198 
199 #define configMAX_TASK_NAME_LEN                         ( CONFIG_FREERTOS_MAX_TASK_NAME_LEN )
200 
201 #ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY
202 #define configUSE_TRACE_FACILITY                        1       /* Used by uxTaskGetSystemState(), and other trace facility functions */
203 #endif
204 
205 #ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
206 #define configUSE_STATS_FORMATTING_FUNCTIONS            1   /* Used by vTaskList() */
207 #endif
208 
209 #ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
210 #define configTASKLIST_INCLUDE_COREID                   1
211 #endif
212 
213 #ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
214 #define configGENERATE_RUN_TIME_STATS                   1       /* Used by vTaskGetRunTimeStats() */
215 #endif
216 
217 #define configBENCHMARK                                 0
218 #define configUSE_16_BIT_TICKS                          0
219 #define configIDLE_SHOULD_YIELD                         0
220 #define configQUEUE_REGISTRY_SIZE                       CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE
221 
222 #define configUSE_MUTEXES                               1
223 #define configUSE_RECURSIVE_MUTEXES                     1
224 #define configUSE_COUNTING_SEMAPHORES                   1
225 
226 #if CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE
227 #define configCHECK_FOR_STACK_OVERFLOW                  0
228 #elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL
229 #define configCHECK_FOR_STACK_OVERFLOW                  1
230 #elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY
231 #define configCHECK_FOR_STACK_OVERFLOW                  2
232 #endif
233 
234 
235 /* Co-routine definitions. */
236 #define configUSE_CO_ROUTINES                           0
237 #define configMAX_CO_ROUTINE_PRIORITIES                 ( 2 )
238 
239 /* Set the following definitions to 1 to include the API function, or zero
240    to exclude the API function. */
241 
242 #define INCLUDE_vTaskPrioritySet                        1
243 #define INCLUDE_uxTaskPriorityGet                       1
244 #define INCLUDE_vTaskDelete                             1
245 #define INCLUDE_vTaskCleanUpResources                   0
246 #define INCLUDE_vTaskSuspend                            1
247 #define INCLUDE_vTaskDelayUntil                         1
248 #define INCLUDE_vTaskDelay                              1
249 #define INCLUDE_uxTaskGetStackHighWaterMark             1
250 #define INCLUDE_pcTaskGetTaskName                       1
251 #define INCLUDE_xTaskGetIdleTaskHandle                  1
252 #define INCLUDE_pxTaskGetStackStart                     1
253 #define INCLUDE_eTaskGetState                           1
254 #define INCLUDE_xTaskAbortDelay                         1
255 #define INCLUDE_xTaskGetHandle                          1
256 #define INCLUDE_xSemaphoreGetMutexHolder                1
257 #define INCLUDE_xTimerPendFunctionCall                  1
258 #define INCLUDE_xTimerGetTimerDaemonTaskHandle          0   //Currently there is no need for this API
259 
260 /* The priority at which the tick interrupt runs.  This should probably be
261    kept at 1. */
262 #define configKERNEL_INTERRUPT_PRIORITY                 1
263 
264 #if !CONFIG_IDF_TARGET_LINUX
265 #define configUSE_NEWLIB_REENTRANT                      1
266 #endif
267 
268 #define configSUPPORT_DYNAMIC_ALLOCATION                1
269 #define configSUPPORT_STATIC_ALLOCATION                 1
270 
271 #ifndef __ASSEMBLER__
272 #if CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP
273 extern void vPortCleanUpTCB ( void *pxTCB );
274 #define portCLEAN_UP_TCB( pxTCB )           vPortCleanUpTCB( pxTCB )
275 #endif
276 #endif
277 
278 /* Test FreeRTOS timers (with timer task) and more. */
279 /* Some files don't compile if this flag is disabled */
280 #define configUSE_TIMERS                                1
281 #define configTIMER_TASK_PRIORITY                       CONFIG_FREERTOS_TIMER_TASK_PRIORITY
282 #define configTIMER_QUEUE_LENGTH                        CONFIG_FREERTOS_TIMER_QUEUE_LENGTH
283 #define configTIMER_TASK_STACK_DEPTH                    CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH
284 
285 #define configUSE_QUEUE_SETS                            1
286 
287 #define configUSE_TICKLESS_IDLE                         CONFIG_FREERTOS_USE_TICKLESS_IDLE
288 #if configUSE_TICKLESS_IDLE
289 #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP           CONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP
290 #endif //configUSE_TICKLESS_IDLE
291 
292 
293 #if CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT
294 #define configENABLE_TASK_SNAPSHOT                      1
295 #endif
296 #ifndef configENABLE_TASK_SNAPSHOT
297 #define configENABLE_TASK_SNAPSHOT                      0
298 #endif
299 
300 #if CONFIG_SYSVIEW_ENABLE
301 #ifndef __ASSEMBLER__
302 #include "SEGGER_SYSVIEW_FreeRTOS.h"
303 #undef INLINE // to avoid redefinition
304 #endif /* def __ASSEMBLER__ */
305 #endif
306 
307 #if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER
308 #define configCHECK_MUTEX_GIVEN_BY_OWNER                1
309 #else
310 #define configCHECK_MUTEX_GIVEN_BY_OWNER                0
311 #endif
312 
313 
314 #define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H       1
315 
316 #define configTASK_NOTIFICATION_ARRAY_ENTRIES           1
317 
318 // backward compatibility for 4.4
319 #define xTaskRemoveFromUnorderedEventList vTaskRemoveFromUnorderedEventList
320 
321 #define configNUM_CORES                                 portNUM_PROCESSORS
322 
323 #endif /* FREERTOS_CONFIG_H */
324