• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Hunan OpenValley Digital Industry Development Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __OSAL_CONFIG_H__
17 #define __OSAL_CONFIG_H__
18 
19 #include "sdkconfig.h"
20 
21 /* enable use of optimized task selection by the scheduler */
22 #ifdef CONFIG_FREERTOS_OPTIMIZED_SCHEDULER
23 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
24 #endif
25 
26 /* ESP31 and ESP32 are dualcore processors. */
27 #ifndef CONFIG_FREERTOS_UNICORE
28 #define portNUM_PROCESSORS 2
29 #else
30 #define portNUM_PROCESSORS 1
31 #endif
32 
33 #define XT_USE_THREAD_SAFE_CLIB		0
34 #define configASSERT_2	            0
35 #define portUSING_MPU_WRAPPERS      0
36 #define configUSE_MUTEX             1
37 #undef XT_USE_SWPRI
38 
39 #if CONFIG_FREERTOS_CORETIMER_0
40 #define XT_TIMER_INDEX 0
41 #elif CONFIG_FREERTOS_CORETIMER_1
42 #define XT_TIMER_INDEX 1
43 #endif
44 
45 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS  CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS
46 #define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS 1
47 
48 #ifndef __ASSEMBLER__
49 
50 /**
51  * This function is defined to provide a deprecation warning whenever
52  * XT_CLOCK_FREQ macro is used.
53  * Update the code to use esp_clk_cpu_freq function instead.
54  * @return current CPU clock frequency, in Hz
55  */
56 int xt_clock_freq(void) __attribute__((deprecated));
57 
58 #define XT_CLOCK_FREQ   (xt_clock_freq())
59 
60 #endif // __ASSEMBLER__
61 
62 
63 /* Required for configuration-dependent settings */
64 #include <esp_osal/xtensa_config.h>
65 
66 /* configASSERT behaviour */
67 #ifndef __ASSEMBLER__
68 #include <assert.h>
69 #include "esp_rom_sys.h"
70 #if CONFIG_IDF_TARGET_ESP32
71 #include "esp32/rom/ets_sys.h"  // will be removed in idf v5.0
72 #elif CONFIG_IDF_TARGET_ESP32S2
73 #include "esp32s2/rom/ets_sys.h"
74 #elif CONFIG_IDF_TARGET_ESP32S3
75 #include "esp32s3/rom/ets_sys.h"
76 #elif CONFIG_IDF_TARGET_ESP32C3
77 #include "esp32c3/rom/ets_sys.h"
78 #endif
79 
80 #if defined(CONFIG_FREERTOS_ASSERT_DISABLE)
81 #define configASSERT(a) /* assertions disabled */
82 #elif defined(CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE)
83 #define configASSERT(a) if (unlikely(!(a))) {                               \
84         esp_rom_printf("%s:%d (%s)- assert failed!\n", __FILE__, __LINE__,  \
85                    __FUNCTION__);                                           \
86     }
87 #elif defined(CONFIG_FREERTOS_ASSERT_FAIL_ABORT)
88 #define configASSERT(a) assert(a)
89 #endif
90 
91 #if CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION
92 #define UNTESTED_FUNCTION() { esp_rom_printf("Untested FreeRTOS function %s\r\n", __FUNCTION__); configASSERT(false); } while(0)
93 #else
94 #define UNTESTED_FUNCTION()
95 #endif
96 
97 
98 #endif /* def __ASSEMBLER__ */
99 
100 
101 /*-----------------------------------------------------------
102  * Application specific definitions.
103  *
104  * These definitions should be adjusted for your particular hardware and
105  * application requirements.
106  *
107  * Note that the default heap size is deliberately kept small so that
108  * the build is more likely to succeed for configurations with limited
109  * memory.
110  *
111  * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
112  * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
113  *----------------------------------------------------------*/
114 
115 #define configUSE_PREEMPTION			0
116 #define configUSE_IDLE_HOOK				0
117 #define configUSE_TICK_HOOK				0
118 #define configRECORD_STACK_HIGH_ADDRESS 1
119 #define configTICK_RATE_HZ				( CONFIG_FREERTOS_HZ )
120 
121 /* Default clock rate for simulator */
122 //#define configCPU_CLOCK_HZ				80000000
123 
124 /* This has impact on speed of search for highest priority */
125 #ifdef SMALL_TEST
126 #define configMAX_PRIORITIES			( 7 )
127 #else
128 #define configMAX_PRIORITIES			( 25 )
129 #endif
130 
131 /* Various things that impact minimum stack sizes */
132 
133 /* Higher stack checker modes cause overhead on each function call */
134 #if CONFIG_STACK_CHECK_ALL || CONFIG_STACK_CHECK_STRONG
135 #define configSTACK_OVERHEAD_CHECKER 256
136 #else
137 #define configSTACK_OVERHEAD_CHECKER 0
138 #endif
139 
140 /* with optimizations disabled, scheduler uses additional stack */
141 #if CONFIG_COMPILER_OPTIMIZATION_NONE
142 #define configSTACK_OVERHEAD_OPTIMIZATION 320
143 #else
144 #define configSTACK_OVERHEAD_OPTIMIZATION 0
145 #endif
146 
147 /* apptrace mdule increases minimum stack usage */
148 #if CONFIG_APPTRACE_ENABLE
149 #define configSTACK_OVERHEAD_APPTRACE 1280
150 #else
151 #define configSTACK_OVERHEAD_APPTRACE 0
152 #endif
153 
154 #define configSTACK_OVERHEAD_TOTAL (                                    \
155                                     configSTACK_OVERHEAD_CHECKER +      \
156                                     configSTACK_OVERHEAD_OPTIMIZATION + \
157                                     configSTACK_OVERHEAD_APPTRACE       \
158                                                                         )
159 
160 #define configMINIMAL_STACK_SIZE  (768 + configSTACK_OVERHEAD_TOTAL)
161 
162 #ifndef configIDLE_TASK_STACK_SIZE
163 #define configIDLE_TASK_STACK_SIZE CONFIG_FREERTOS_IDLE_TASK_STACKSIZE
164 #endif
165 
166 /* Stack alignment, architecture specifc. Must be a power of two. */
167 #define configSTACK_ALIGNMENT			16
168 
169 /* The Xtensa port uses a separate interrupt stack. Adjust the stack size
170  * to suit the needs of your specific application.
171  * Size needs to be aligned to the stack increment, since the location of
172  * the stack for the 2nd CPU will be calculated using configISR_STACK_SIZE.
173  */
174 #ifndef configISR_STACK_SIZE
175 #define configISR_STACK_SIZE			((CONFIG_FREERTOS_ISR_STACKSIZE + configSTACK_ALIGNMENT - 1) & (~(configSTACK_ALIGNMENT - 1)))
176 #endif
177 
178 /* Minimal heap size to make sure examples can run on memory limited
179    configs. Adjust this to suit your system. */
180 
181 
182 //We define the heap to span all of the non-statically-allocated shared RAM. ToDo: Make sure there
183 //is some space left for the app and main cpu when running outside of a thread.
184 #define configAPPLICATION_ALLOCATED_HEAP 1
185 #define configTOTAL_HEAP_SIZE			(&_heap_end - &_heap_start)//( ( size_t ) (64 * 1024) )
186 
187 #define configMAX_TASK_NAME_LEN			( CONFIG_FREERTOS_MAX_TASK_NAME_LEN )
188 
189 #ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY
190 #define configUSE_TRACE_FACILITY        0       /* Used by uxTaskGetSystemState(), and other trace facility functions */
191 #endif
192 
193 #ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
194 #define configUSE_STATS_FORMATTING_FUNCTIONS    1   /* Used by vTaskList() */
195 #endif
196 
197 #ifdef CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID
198 #define configTASKLIST_INCLUDE_COREID   1
199 #endif
200 
201 #ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
202 #define configGENERATE_RUN_TIME_STATS   1       /* Used by vTaskGetRunTimeStats() */
203 #endif
204 
205 #define configUSE_TRACE_FACILITY_2      0		/* Provided by Xtensa port patch */
206 #define configBENCHMARK					0		/* Provided by Xtensa port patch */
207 #define configUSE_16_BIT_TICKS			0
208 #define configIDLE_SHOULD_YIELD			0
209 #define configQUEUE_REGISTRY_SIZE		CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE
210 
211 #define configUSE_MUTEXES				1
212 #define configUSE_RECURSIVE_MUTEXES		1
213 #define configUSE_COUNTING_SEMAPHORES	1
214 
215 #if CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE
216 #define configCHECK_FOR_STACK_OVERFLOW	0
217 #elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL
218 #define configCHECK_FOR_STACK_OVERFLOW	1
219 #elif CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY
220 #define configCHECK_FOR_STACK_OVERFLOW	2
221 #endif
222 
223 
224 /* Co-routine definitions. */
225 #define configUSE_CO_ROUTINES 			0
226 #define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
227 
228 /* Set the following definitions to 1 to include the API function, or zero
229    to exclude the API function. */
230 
231 #define INCLUDE_vTaskPrioritySet			0
232 #define INCLUDE_uxTaskPriorityGet			0
233 #define INCLUDE_vTaskDelete					1
234 #define INCLUDE_vTaskCleanUpResources		0
235 #define INCLUDE_vTaskSuspend				0
236 #define INCLUDE_vTaskDelayUntil				0
237 #define INCLUDE_vTaskDelay					1
238 #define INCLUDE_uxTaskGetStackHighWaterMark	0
239 #define INCLUDE_pcTaskGetTaskName			0
240 #define INCLUDE_xTaskGetIdleTaskHandle      0
241 #define INCLUDE_pxTaskGetStackStart			0
242 
243 #define INCLUDE_xSemaphoreGetMutexHolder    0
244 
245 /* The priority at which the tick interrupt runs.  This should probably be
246    kept at 1. */
247 #define configKERNEL_INTERRUPT_PRIORITY		1
248 
249 /* The maximum interrupt priority from which FreeRTOS.org API functions can
250    be called.  Only API functions that end in ...FromISR() can be used within
251    interrupts. */
252 #define configMAX_SYSCALL_INTERRUPT_PRIORITY	XCHAL_EXCM_LEVEL
253 
254 #define configUSE_NEWLIB_REENTRANT		0
255 
256 #define configSUPPORT_DYNAMIC_ALLOCATION    1
257 #define configSUPPORT_STATIC_ALLOCATION     1
258 
259 #ifndef __ASSEMBLER__
260 #if CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP
261 extern void vPortCleanUpTCB ( void *pxTCB );
262 #define portCLEAN_UP_TCB( pxTCB )           vPortCleanUpTCB( pxTCB )
263 #endif
264 #endif
265 
266 /* Test FreeRTOS timers (with timer task) and more. */
267 /* Some files don't compile if this flag is disabled */
268 #define configUSE_TIMERS                    0
269 #define configTIMER_TASK_PRIORITY           CONFIG_FREERTOS_TIMER_TASK_PRIORITY
270 #define configTIMER_QUEUE_LENGTH            CONFIG_FREERTOS_TIMER_QUEUE_LENGTH
271 #define configTIMER_TASK_STACK_DEPTH        CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH
272 
273 #define INCLUDE_xTimerPendFunctionCall      1
274 #define INCLUDE_eTaskGetState               1
275 #define configUSE_QUEUE_SETS                0
276 
277 #define configUSE_TICKLESS_IDLE             0 // CONFIG_FREERTOS_USE_TICKLESS_IDLE
278 #if configUSE_TICKLESS_IDLE
279 #define configEXPECTED_IDLE_TIME_BEFORE_SLEEP   CONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP
280 #endif //configUSE_TICKLESS_IDLE
281 
282 #define configXT_BOARD                      1   /* Board mode */
283 #define configXT_SIMULATOR					0
284 
285 #if CONFIG_ESP_COREDUMP_ENABLE
286 #define configENABLE_TASK_SNAPSHOT          1
287 #endif
288 #ifndef configENABLE_TASK_SNAPSHOT
289 #define configENABLE_TASK_SNAPSHOT          1
290 #endif
291 
292 #if CONFIG_SYSVIEW_ENABLE
293 #ifndef __ASSEMBLER__
294 #include "SEGGER_SYSVIEW_esp_osal.h"
295 #undef INLINE // to avoid redefinition
296 #endif /* def __ASSEMBLER__ */
297 #endif
298 
299 #if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER
300 #define configCHECK_MUTEX_GIVEN_BY_OWNER    1
301 #else
302 #define configCHECK_MUTEX_GIVEN_BY_OWNER    0
303 #endif
304 
305 #endif /* __OSAL_CONFIG_H__ */
306