Skip to content

Commit a26410e

Browse files
committed
将FreeRTOSConfig.h的配置项迁到FreeRTOS.h
1 parent a2743ed commit a26410e

File tree

4 files changed

+101
-207
lines changed

4 files changed

+101
-207
lines changed

FreeRTOS/include/freertos/FreeRTOS.h

Lines changed: 99 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@
5959
#include <rthw.h>
6060

6161
/* Application specific configuration options. */
62-
#include "FreeRTOSConfig.h"
62+
#ifdef PKG_FREERTOS_USING_CONFIG_H
63+
#include <FreeRTOSConfig.h>
64+
#endif
6365

6466
/* Basic FreeRTOS definitions. */
6567
#include "projdefs.h"
@@ -77,27 +79,62 @@
7779
#include <reent.h>
7880
#endif
7981

80-
/*
81-
* Check all the required application specific macros have been defined.
82-
* These macros are application specific and (as downloaded) are defined
83-
* within FreeRTOSConfig.h.
84-
*/
82+
/* RT-Thread inherent definations */
83+
#define configUSE_PREEMPTION 1
84+
#define configUSE_TIME_SLICING 1
85+
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
86+
#define configUSE_16_BIT_TICKS 0
8587

88+
#define configTICK_RATE_HZ RT_TICK_PER_SECOND
89+
#define configMAX_PRIORITIES RT_THREAD_PRIORITY_MAX
90+
#define configMAX_TASK_NAME_LEN RT_NAME_MAX
91+
#define configASSERT( x ) RT_ASSERT( x )
92+
#define configASSERT_DEFINED 1
8693
#ifndef configMINIMAL_STACK_SIZE
87-
#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.
94+
#define configMINIMAL_STACK_SIZE 128
8895
#endif
8996

90-
#ifndef configMAX_PRIORITIES
91-
#error Missing definition: configMAX_PRIORITIES must be defined in FreeRTOSConfig.h. See the Configuration section of the FreeRTOS API documentation for details.
97+
#if defined(PKG_FREERTOS_USING_MEMMANG_HEAP1) ||
98+
defined(PKG_FREERTOS_USING_MEMMANG_HEAP2) ||
99+
defined(PKG_FREERTOS_USING_MEMMANG_HEAP4)
100+
#ifndef configTOTAL_HEAP_SIZE
101+
#define configTOTAL_HEAP_SIZE 10240
102+
#endif
103+
#ifndef configAPPLICATION_ALLOCATED_HEAP
104+
#define configAPPLICATION_ALLOCATED_HEAP 0
105+
#endif
92106
#endif
93107

94-
#if configMAX_PRIORITIES < 1
95-
#error configMAX_PRIORITIES must be defined to be greater than or equal to 1.
108+
#if defined(PKG_FREERTOS_USING_MEMMANG_HEAP4) ||
109+
defined(PKG_FREERTOS_USING_MEMMANG_HEAP5)
110+
#ifndef configUSE_FREERTOS_PROVIDED_HEAP
111+
#define configUSE_FREERTOS_PROVIDED_HEAP 1
112+
#endif
96113
#endif
97114

98-
#ifndef configUSE_PREEMPTION
99-
#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.
100-
#endif
115+
/* Hook functions are not supported by RT-Thread */
116+
#define configUSE_IDLE_HOOK 0
117+
#define configUSE_TICK_HOOK 0
118+
#define configCHECK_FOR_STACK_OVERFLOW 0
119+
#define configUSE_MALLOC_FAILED_HOOK 0
120+
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
121+
122+
/* The following features are not supported by RT-Thread */
123+
#define INCLUDE_xTimerPendFunctionCall 0
124+
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
125+
#define configUSE_CO_ROUTINES 0
126+
#define configQUEUE_REGISTRY_SIZE 0
127+
#define configUSE_QUEUE_SETS 0
128+
#define configUSE_TICKLESS_IDLE 0
129+
#define configGENERATE_RUN_TIME_STATS 0
130+
#define configUSE_TRACE_FACILITY 0
131+
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
132+
133+
/*
134+
* Check all the required application specific macros have been defined.
135+
* These macros are application specific and (as downloaded) are defined
136+
* within FreeRTOSConfig.h.
137+
*/
101138

102139
#ifndef configUSE_IDLE_HOOK
103140
#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.
@@ -107,28 +144,24 @@
107144
#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.
108145
#endif
109146

110-
#ifndef configUSE_16_BIT_TICKS
111-
#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.
112-
#endif
113-
114147
#ifndef configUSE_CO_ROUTINES
115148
#define configUSE_CO_ROUTINES 0
116149
#endif
117150

118151
#ifndef INCLUDE_vTaskPrioritySet
119-
#define INCLUDE_vTaskPrioritySet 0
152+
#define INCLUDE_vTaskPrioritySet 1
120153
#endif
121154

122155
#ifndef INCLUDE_uxTaskPriorityGet
123-
#define INCLUDE_uxTaskPriorityGet 0
156+
#define INCLUDE_uxTaskPriorityGet 1
124157
#endif
125158

126159
#ifndef INCLUDE_vTaskDelete
127-
#define INCLUDE_vTaskDelete 0
160+
#define INCLUDE_vTaskDelete 1
128161
#endif
129162

130163
#ifndef INCLUDE_vTaskSuspend
131-
#define INCLUDE_vTaskSuspend 0
164+
#define INCLUDE_vTaskSuspend 1
132165
#endif
133166

134167
#ifdef INCLUDE_xTaskDelayUntil
@@ -154,43 +187,43 @@
154187
#endif
155188

156189
#ifndef INCLUDE_xTaskDelayUntil
157-
#define INCLUDE_xTaskDelayUntil 0
190+
#define INCLUDE_xTaskDelayUntil 1
158191
#endif
159192

160193
#ifndef INCLUDE_vTaskDelay
161-
#define INCLUDE_vTaskDelay 0
194+
#define INCLUDE_vTaskDelay 1
162195
#endif
163196

164197
#ifndef INCLUDE_xTaskGetIdleTaskHandle
165-
#define INCLUDE_xTaskGetIdleTaskHandle 0
198+
#define INCLUDE_xTaskGetIdleTaskHandle 1
166199
#endif
167200

168201
#ifndef INCLUDE_xTaskAbortDelay
169-
#define INCLUDE_xTaskAbortDelay 0
202+
#define INCLUDE_xTaskAbortDelay 1
170203
#endif
171204

172205
#ifndef INCLUDE_xQueueGetMutexHolder
173-
#define INCLUDE_xQueueGetMutexHolder 0
206+
#define INCLUDE_xQueueGetMutexHolder 1
174207
#endif
175208

176209
#ifndef INCLUDE_xSemaphoreGetMutexHolder
177210
#define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder
178211
#endif
179212

180213
#ifndef INCLUDE_xTaskGetHandle
181-
#define INCLUDE_xTaskGetHandle 0
214+
#define INCLUDE_xTaskGetHandle 1
182215
#endif
183216

184217
#ifndef INCLUDE_uxTaskGetStackHighWaterMark
185-
#define INCLUDE_uxTaskGetStackHighWaterMark 0
218+
#define INCLUDE_uxTaskGetStackHighWaterMark 1
186219
#endif
187220

188221
#ifndef INCLUDE_uxTaskGetStackHighWaterMark2
189-
#define INCLUDE_uxTaskGetStackHighWaterMark2 0
222+
#define INCLUDE_uxTaskGetStackHighWaterMark2 1
190223
#endif
191224

192225
#ifndef INCLUDE_eTaskGetState
193-
#define INCLUDE_eTaskGetState 0
226+
#define INCLUDE_eTaskGetState 1
194227
#endif
195228

196229
#ifndef INCLUDE_xTaskResumeFromISR
@@ -202,11 +235,11 @@
202235
#endif
203236

204237
#ifndef INCLUDE_xTaskGetSchedulerState
205-
#define INCLUDE_xTaskGetSchedulerState 0
238+
#define INCLUDE_xTaskGetSchedulerState 1
206239
#endif
207240

208241
#ifndef INCLUDE_xTaskGetCurrentTaskHandle
209-
#define INCLUDE_xTaskGetCurrentTaskHandle 0
242+
#define INCLUDE_xTaskGetCurrentTaskHandle 1
210243
#endif
211244

212245
#if configUSE_CO_ROUTINES != 0
@@ -220,27 +253,43 @@
220253
#endif
221254

222255
#ifndef configUSE_APPLICATION_TASK_TAG
223-
#define configUSE_APPLICATION_TASK_TAG 0
256+
#define configUSE_APPLICATION_TASK_TAG 1
224257
#endif
225258

226259
#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
227260
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
228261
#endif
229262

230263
#ifndef configUSE_RECURSIVE_MUTEXES
231-
#define configUSE_RECURSIVE_MUTEXES 0
264+
#ifdef RT_USING_MUTEX
265+
#define configUSE_RECURSIVE_MUTEXES 1
266+
#else
267+
#define configUSE_RECURSIVE_MUTEXES 0
268+
#endif
232269
#endif
233270

234271
#ifndef configUSE_MUTEXES
235-
#define configUSE_MUTEXES 0
272+
#ifdef RT_USING_MUTEX
273+
#define configUSE_MUTEXES 1
274+
#else
275+
#define configUSE_MUTEXES 0
276+
#endif
236277
#endif
237278

238279
#ifndef configUSE_TIMERS
239-
#define configUSE_TIMERS 0
280+
#ifdef RT_USING_TIMER_SOFT
281+
#define configUSE_TIMERS 1
282+
#else
283+
#define configUSE_TIMERS 0
284+
#endif
240285
#endif
241286

242287
#ifndef configUSE_COUNTING_SEMAPHORES
243-
#define configUSE_COUNTING_SEMAPHORES 0
288+
#ifdef RT_USING_SEMAPHORE
289+
#define configUSE_COUNTING_SEMAPHORES 1
290+
#else
291+
#define configUSE_COUNTING_SEMAPHORES 0
292+
#endif
244293
#endif
245294

246295
#ifndef configUSE_ALTERNATIVE_API
@@ -251,25 +300,10 @@
251300
#define portCRITICAL_NESTING_IN_TCB 0
252301
#endif
253302

254-
#ifndef configMAX_TASK_NAME_LEN
255-
#define configMAX_TASK_NAME_LEN 16
256-
#endif
257-
258303
#ifndef configIDLE_SHOULD_YIELD
259304
#define configIDLE_SHOULD_YIELD 1
260305
#endif
261306

262-
#if configMAX_TASK_NAME_LEN < 1
263-
#error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h
264-
#endif
265-
266-
#ifndef configASSERT
267-
#define configASSERT( x )
268-
#define configASSERT_DEFINED 0
269-
#else
270-
#define configASSERT_DEFINED 1
271-
#endif
272-
273307
/* configPRECONDITION should be defined as configASSERT.
274308
* The CBMC proofs need a way to track assumptions and assertions.
275309
* A configPRECONDITION statement should express an implicit invariant or
@@ -292,19 +326,9 @@
292326

293327
/* The timers module relies on xTaskGetSchedulerState(). */
294328
#if configUSE_TIMERS == 1
295-
296-
#ifndef configTIMER_TASK_PRIORITY
297-
#error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined.
298-
#endif /* configTIMER_TASK_PRIORITY */
299-
300-
#ifndef configTIMER_QUEUE_LENGTH
301-
#error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined.
302-
#endif /* configTIMER_QUEUE_LENGTH */
303-
304-
#ifndef configTIMER_TASK_STACK_DEPTH
305-
#error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined.
306-
#endif /* configTIMER_TASK_STACK_DEPTH */
307-
329+
#define configTIMER_TASK_PRIORITY (RT_THREAD_PRIORITY_MAX - 1 - RT_TIMER_THREAD_PRIO)
330+
#define configTIMER_QUEUE_LENGTH 0 /* RT-Thread does not use a timer queue. This option is not used. */
331+
#define configTIMER_TASK_STACK_DEPTH RT_TIMER_THREAD_STACK_SIZE
308332
#endif /* configUSE_TIMERS */
309333

310334
#ifndef portSET_INTERRUPT_MASK_FROM_ISR
@@ -847,10 +871,6 @@
847871
#define portDONT_DISCARD
848872
#endif
849873

850-
#ifndef configUSE_TIME_SLICING
851-
#define configUSE_TIME_SLICING 1
852-
#endif
853-
854874
#ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS
855875
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
856876
#endif
@@ -879,20 +899,16 @@
879899
#define portASSERT_IF_IN_ISR()
880900
#endif
881901

882-
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
883-
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
884-
#endif
885-
886902
#ifndef configAPPLICATION_ALLOCATED_HEAP
887903
#define configAPPLICATION_ALLOCATED_HEAP 0
888904
#endif
889905

890906
#ifndef configUSE_TASK_NOTIFICATIONS
891-
#define configUSE_TASK_NOTIFICATIONS 1
907+
#define configUSE_TASK_NOTIFICATIONS 1
892908
#endif
893909

894910
#ifndef configTASK_NOTIFICATION_ARRAY_ENTRIES
895-
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1
911+
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3
896912
#endif
897913

898914
#if configTASK_NOTIFICATION_ARRAY_ENTRIES < 1
@@ -908,13 +924,16 @@
908924
#endif
909925

910926
#ifndef configSUPPORT_STATIC_ALLOCATION
911-
/* Defaults to 0 for backward compatibility. */
912-
#define configSUPPORT_STATIC_ALLOCATION 0
927+
#define configSUPPORT_STATIC_ALLOCATION 1
913928
#endif
914929

930+
//TODO: using rt-thread rt_malloc/rt_free by default
915931
#ifndef configSUPPORT_DYNAMIC_ALLOCATION
916-
/* Defaults to 1 for backward compatibility. */
917-
#define configSUPPORT_DYNAMIC_ALLOCATION 1
932+
#ifdef RT_USING_HEAP
933+
#define configSUPPORT_DYNAMIC_ALLOCATION 1
934+
#else
935+
#define configSUPPORT_DYNAMIC_ALLOCATION 0
936+
#endif
918937
#endif
919938

920939
#ifndef configSTACK_DEPTH_TYPE

FreeRTOS/include/freertos/portable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ size_t xPortGetMinimumEverFreeHeapSize( void );
120120
* non-FreeRTOS-specific code, and behave the same as
121121
* pvPortMalloc()/vPortFree().
122122
*/
123-
#define pvPortMalloc malloc
124-
#define vPortFree free
123+
#define pvPortMalloc rt_malloc
124+
#define vPortFree rt_free
125125
#define xPortGetFreeHeapSize esp_get_free_heap_size
126126
#define xPortGetMinimumEverFreeHeapSize esp_get_minimum_free_heap_size
127127

FreeRTOS/include/freertos/projdefs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ typedef void (* TaskFunction_t)( void * );
4242
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) rt_tick_from_millisecond( (rt_int32_t) xTimeInMs ) )
4343
#endif
4444

45-
#ifdef ESP_PLATFORM
4645
#ifndef pdTICKS_TO_MS
4746
#define pdTICKS_TO_MS( xTicks ) ( ( uint32_t ) ( xTicks ) * 1000 / configTICK_RATE_HZ )
4847
#endif
49-
#endif // ESP_PLATFORM
5048

5149
#define pdFALSE ( ( BaseType_t ) 0 )
5250
#define pdTRUE ( ( BaseType_t ) 1 )

0 commit comments

Comments
 (0)