Просмотр исходного кода

将FreeRTOSConfig.h的配置项迁到FreeRTOS.h

Meco Man 2 лет назад
Родитель
Сommit
a26410e740

+ 99 - 80
FreeRTOS/include/freertos/FreeRTOS.h

@@ -59,7 +59,9 @@
 #include <rthw.h>
 
 /* Application specific configuration options. */
-#include "FreeRTOSConfig.h"
+#ifdef PKG_FREERTOS_USING_CONFIG_H
+    #include <FreeRTOSConfig.h>
+#endif
 
 /* Basic FreeRTOS definitions. */
 #include "projdefs.h"
@@ -77,27 +79,62 @@
     #include <reent.h>
 #endif
 
-/*
- * Check all the required application specific macros have been defined.
- * These macros are application specific and (as downloaded) are defined
- * within FreeRTOSConfig.h.
- */
+/* RT-Thread inherent definations */
+#define configUSE_PREEMPTION                    1
+#define configUSE_TIME_SLICING                  1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
+#define configUSE_16_BIT_TICKS                  0
 
+#define configTICK_RATE_HZ                      RT_TICK_PER_SECOND
+#define configMAX_PRIORITIES                    RT_THREAD_PRIORITY_MAX
+#define configMAX_TASK_NAME_LEN                 RT_NAME_MAX
+#define configASSERT( x )                       RT_ASSERT( x )
+#define configASSERT_DEFINED                    1
 #ifndef configMINIMAL_STACK_SIZE
-    #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.
+    #define configMINIMAL_STACK_SIZE            128
 #endif
 
-#ifndef configMAX_PRIORITIES
-    #error Missing definition:  configMAX_PRIORITIES must be defined in FreeRTOSConfig.h.  See the Configuration section of the FreeRTOS API documentation for details.
+#if defined(PKG_FREERTOS_USING_MEMMANG_HEAP1) ||
+    defined(PKG_FREERTOS_USING_MEMMANG_HEAP2) ||
+    defined(PKG_FREERTOS_USING_MEMMANG_HEAP4)
+    #ifndef configTOTAL_HEAP_SIZE
+        #define configTOTAL_HEAP_SIZE               10240
+    #endif
+    #ifndef configAPPLICATION_ALLOCATED_HEAP
+        #define configAPPLICATION_ALLOCATED_HEAP    0
+    #endif
 #endif
 
-#if configMAX_PRIORITIES < 1
-    #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.
+#if defined(PKG_FREERTOS_USING_MEMMANG_HEAP4) ||
+    defined(PKG_FREERTOS_USING_MEMMANG_HEAP5)
+    #ifndef configUSE_FREERTOS_PROVIDED_HEAP
+        #define configUSE_FREERTOS_PROVIDED_HEAP    1
+    #endif
 #endif
 
-#ifndef configUSE_PREEMPTION
-    #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.
-#endif
+/* Hook functions are not supported by RT-Thread */
+#define configUSE_IDLE_HOOK                     0
+#define configUSE_TICK_HOOK                     0
+#define configCHECK_FOR_STACK_OVERFLOW          0
+#define configUSE_MALLOC_FAILED_HOOK            0
+#define configUSE_DAEMON_TASK_STARTUP_HOOK      0
+
+/* The following features are not supported by RT-Thread */
+#define INCLUDE_xTimerPendFunctionCall          0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
+#define configUSE_CO_ROUTINES                   0
+#define configQUEUE_REGISTRY_SIZE               0
+#define configUSE_QUEUE_SETS                    0
+#define configUSE_TICKLESS_IDLE                 0
+#define configGENERATE_RUN_TIME_STATS           0
+#define configUSE_TRACE_FACILITY                0
+#define configUSE_STATS_FORMATTING_FUNCTIONS    0
+
+/*
+ * Check all the required application specific macros have been defined.
+ * These macros are application specific and (as downloaded) are defined
+ * within FreeRTOSConfig.h.
+ */
 
 #ifndef configUSE_IDLE_HOOK
     #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 @@
     #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.
 #endif
 
-#ifndef configUSE_16_BIT_TICKS
-    #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.
-#endif
-
 #ifndef configUSE_CO_ROUTINES
     #define configUSE_CO_ROUTINES    0
 #endif
 
 #ifndef INCLUDE_vTaskPrioritySet
-    #define INCLUDE_vTaskPrioritySet    0
+    #define INCLUDE_vTaskPrioritySet    1
 #endif
 
 #ifndef INCLUDE_uxTaskPriorityGet
-    #define INCLUDE_uxTaskPriorityGet    0
+    #define INCLUDE_uxTaskPriorityGet    1
 #endif
 
 #ifndef INCLUDE_vTaskDelete
-    #define INCLUDE_vTaskDelete    0
+    #define INCLUDE_vTaskDelete    1
 #endif
 
 #ifndef INCLUDE_vTaskSuspend
-    #define INCLUDE_vTaskSuspend    0
+    #define INCLUDE_vTaskSuspend    1
 #endif
 
 #ifdef INCLUDE_xTaskDelayUntil
@@ -154,23 +187,23 @@
 #endif
 
 #ifndef INCLUDE_xTaskDelayUntil
-    #define INCLUDE_xTaskDelayUntil    0
+    #define INCLUDE_xTaskDelayUntil    1
 #endif
 
 #ifndef INCLUDE_vTaskDelay
-    #define INCLUDE_vTaskDelay    0
+    #define INCLUDE_vTaskDelay    1
 #endif
 
 #ifndef INCLUDE_xTaskGetIdleTaskHandle
-    #define INCLUDE_xTaskGetIdleTaskHandle    0
+    #define INCLUDE_xTaskGetIdleTaskHandle    1
 #endif
 
 #ifndef INCLUDE_xTaskAbortDelay
-    #define INCLUDE_xTaskAbortDelay    0
+    #define INCLUDE_xTaskAbortDelay    1
 #endif
 
 #ifndef INCLUDE_xQueueGetMutexHolder
-    #define INCLUDE_xQueueGetMutexHolder    0
+    #define INCLUDE_xQueueGetMutexHolder    1
 #endif
 
 #ifndef INCLUDE_xSemaphoreGetMutexHolder
@@ -178,19 +211,19 @@
 #endif
 
 #ifndef INCLUDE_xTaskGetHandle
-    #define INCLUDE_xTaskGetHandle    0
+    #define INCLUDE_xTaskGetHandle    1
 #endif
 
 #ifndef INCLUDE_uxTaskGetStackHighWaterMark
-    #define INCLUDE_uxTaskGetStackHighWaterMark    0
+    #define INCLUDE_uxTaskGetStackHighWaterMark    1
 #endif
 
 #ifndef INCLUDE_uxTaskGetStackHighWaterMark2
-    #define INCLUDE_uxTaskGetStackHighWaterMark2    0
+    #define INCLUDE_uxTaskGetStackHighWaterMark2    1
 #endif
 
 #ifndef INCLUDE_eTaskGetState
-    #define INCLUDE_eTaskGetState    0
+    #define INCLUDE_eTaskGetState    1
 #endif
 
 #ifndef INCLUDE_xTaskResumeFromISR
@@ -202,11 +235,11 @@
 #endif
 
 #ifndef INCLUDE_xTaskGetSchedulerState
-    #define INCLUDE_xTaskGetSchedulerState    0
+    #define INCLUDE_xTaskGetSchedulerState    1
 #endif
 
 #ifndef INCLUDE_xTaskGetCurrentTaskHandle
-    #define INCLUDE_xTaskGetCurrentTaskHandle    0
+    #define INCLUDE_xTaskGetCurrentTaskHandle    1
 #endif
 
 #if configUSE_CO_ROUTINES != 0
@@ -220,7 +253,7 @@
 #endif
 
 #ifndef configUSE_APPLICATION_TASK_TAG
-    #define configUSE_APPLICATION_TASK_TAG    0
+    #define configUSE_APPLICATION_TASK_TAG    1
 #endif
 
 #ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS
@@ -228,19 +261,35 @@
 #endif
 
 #ifndef configUSE_RECURSIVE_MUTEXES
-    #define configUSE_RECURSIVE_MUTEXES    0
+    #ifdef RT_USING_MUTEX
+        #define configUSE_RECURSIVE_MUTEXES    1
+    #else
+        #define configUSE_RECURSIVE_MUTEXES    0
+    #endif
 #endif
 
 #ifndef configUSE_MUTEXES
-    #define configUSE_MUTEXES    0
+    #ifdef RT_USING_MUTEX
+        #define configUSE_MUTEXES    1
+    #else
+        #define configUSE_MUTEXES    0
+    #endif
 #endif
 
 #ifndef configUSE_TIMERS
-    #define configUSE_TIMERS    0
+    #ifdef RT_USING_TIMER_SOFT
+        #define configUSE_TIMERS    1
+    #else
+        #define configUSE_TIMERS    0
+    #endif
 #endif
 
 #ifndef configUSE_COUNTING_SEMAPHORES
-    #define configUSE_COUNTING_SEMAPHORES    0
+    #ifdef RT_USING_SEMAPHORE
+        #define configUSE_COUNTING_SEMAPHORES    1
+    #else
+        #define configUSE_COUNTING_SEMAPHORES    0
+    #endif
 #endif
 
 #ifndef configUSE_ALTERNATIVE_API
@@ -251,25 +300,10 @@
     #define portCRITICAL_NESTING_IN_TCB    0
 #endif
 
-#ifndef configMAX_TASK_NAME_LEN
-    #define configMAX_TASK_NAME_LEN    16
-#endif
-
 #ifndef configIDLE_SHOULD_YIELD
     #define configIDLE_SHOULD_YIELD    1
 #endif
 
-#if configMAX_TASK_NAME_LEN < 1
-    #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h
-#endif
-
-#ifndef configASSERT
-    #define configASSERT( x )
-    #define configASSERT_DEFINED    0
-#else
-    #define configASSERT_DEFINED    1
-#endif
-
 /* configPRECONDITION should be defined as configASSERT.
  * The CBMC proofs need a way to track assumptions and assertions.
  * A configPRECONDITION statement should express an implicit invariant or
@@ -292,19 +326,9 @@
 
 /* The timers module relies on xTaskGetSchedulerState(). */
 #if configUSE_TIMERS == 1
-
-    #ifndef configTIMER_TASK_PRIORITY
-        #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined.
-    #endif /* configTIMER_TASK_PRIORITY */
-
-    #ifndef configTIMER_QUEUE_LENGTH
-        #error If configUSE_TIMERS is set to 1 then configTIMER_QUEUE_LENGTH must also be defined.
-    #endif /* configTIMER_QUEUE_LENGTH */
-
-    #ifndef configTIMER_TASK_STACK_DEPTH
-        #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_STACK_DEPTH must also be defined.
-    #endif /* configTIMER_TASK_STACK_DEPTH */
-
+    #define configTIMER_TASK_PRIORITY           (RT_THREAD_PRIORITY_MAX - 1 - RT_TIMER_THREAD_PRIO)
+    #define configTIMER_QUEUE_LENGTH            0 /* RT-Thread does not use a timer queue. This option is not used. */
+    #define configTIMER_TASK_STACK_DEPTH        RT_TIMER_THREAD_STACK_SIZE
 #endif /* configUSE_TIMERS */
 
 #ifndef portSET_INTERRUPT_MASK_FROM_ISR
@@ -847,10 +871,6 @@
     #define portDONT_DISCARD
 #endif
 
-#ifndef configUSE_TIME_SLICING
-    #define configUSE_TIME_SLICING    1
-#endif
-
 #ifndef configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS
     #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS    0
 #endif
@@ -879,20 +899,16 @@
     #define portASSERT_IF_IN_ISR()
 #endif
 
-#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
-    #define configUSE_PORT_OPTIMISED_TASK_SELECTION    0
-#endif
-
 #ifndef configAPPLICATION_ALLOCATED_HEAP
     #define configAPPLICATION_ALLOCATED_HEAP    0
 #endif
 
 #ifndef configUSE_TASK_NOTIFICATIONS
-    #define configUSE_TASK_NOTIFICATIONS    1
+    #define configUSE_TASK_NOTIFICATIONS        1
 #endif
 
 #ifndef configTASK_NOTIFICATION_ARRAY_ENTRIES
-    #define configTASK_NOTIFICATION_ARRAY_ENTRIES    1
+    #define configTASK_NOTIFICATION_ARRAY_ENTRIES    3
 #endif
 
 #if configTASK_NOTIFICATION_ARRAY_ENTRIES < 1
@@ -908,13 +924,16 @@
 #endif
 
 #ifndef configSUPPORT_STATIC_ALLOCATION
-    /* Defaults to 0 for backward compatibility. */
-    #define configSUPPORT_STATIC_ALLOCATION    0
+    #define configSUPPORT_STATIC_ALLOCATION    1
 #endif
 
+//TODO: using rt-thread rt_malloc/rt_free by default
 #ifndef configSUPPORT_DYNAMIC_ALLOCATION
-    /* Defaults to 1 for backward compatibility. */
-    #define configSUPPORT_DYNAMIC_ALLOCATION    1
+    #ifdef RT_USING_HEAP
+        #define configSUPPORT_DYNAMIC_ALLOCATION    1
+    #else
+        #define configSUPPORT_DYNAMIC_ALLOCATION    0
+    #endif
 #endif
 
 #ifndef configSTACK_DEPTH_TYPE

+ 2 - 2
FreeRTOS/include/freertos/portable.h

@@ -120,8 +120,8 @@ size_t xPortGetMinimumEverFreeHeapSize( void );
  * non-FreeRTOS-specific code, and behave the same as
  * pvPortMalloc()/vPortFree().
  */
-#define pvPortMalloc malloc
-#define vPortFree free
+#define pvPortMalloc rt_malloc
+#define vPortFree rt_free
 #define xPortGetFreeHeapSize esp_get_free_heap_size
 #define xPortGetMinimumEverFreeHeapSize esp_get_minimum_free_heap_size
 

+ 0 - 2
FreeRTOS/include/freertos/projdefs.h

@@ -42,11 +42,9 @@ typedef void (* TaskFunction_t)( void * );
     #define pdMS_TO_TICKS( xTimeInMs )    ( ( TickType_t ) rt_tick_from_millisecond( (rt_int32_t) xTimeInMs ) )
 #endif
 
-#ifdef ESP_PLATFORM
 #ifndef pdTICKS_TO_MS
     #define pdTICKS_TO_MS( xTicks )   ( ( uint32_t ) ( xTicks ) * 1000 / configTICK_RATE_HZ )
 #endif
-#endif // ESP_PLATFORM
 
 #define pdFALSE                                  ( ( BaseType_t ) 0 )
 #define pdTRUE                                   ( ( BaseType_t ) 1 )

+ 0 - 123
FreeRTOS/portable/rt-thread/FreeRTOSConfig.h

@@ -1,123 +0,0 @@
-/*
- * FreeRTOS Kernel V10.4.6
- * Copyright (C) 2021 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * https://www.FreeRTOS.org
- * https://github.com/FreeRTOS
- *
- */
-
-#ifndef FREERTOS_CONFIG_H
-#define FREERTOS_CONFIG_H
-
-#ifdef PKG_FREERTOS_USING_PRELOAD_CONFIG
-#include <FreeRTOSPreloadConfig.h>
-#endif
-
-/* The following options are read-only */
-#define configUSE_PREEMPTION                    1
-#define configUSE_TIME_SLICING                  1
-#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
-#define configUSE_16_BIT_TICKS                  0
-#define configUSE_FREERTOS_PROVIDED_HEAP        1
-
-/* The following read-only options are controlled by rtconfig.h. */
-#define configTICK_RATE_HZ                      RT_TICK_PER_SECOND
-#define configMAX_PRIORITIES                    RT_THREAD_PRIORITY_MAX
-#define configMAX_TASK_NAME_LEN                 RT_NAME_MAX
-
-#ifdef RT_USING_TIMER_SOFT
-    #define configUSE_TIMERS                    1
-    #define configTIMER_TASK_PRIORITY           (RT_THREAD_PRIORITY_MAX - 1 - RT_TIMER_THREAD_PRIO)
-    /* RT-Thread does not use a timer queue. This option is not used. */
-    #define configTIMER_QUEUE_LENGTH            0
-    #define configTIMER_TASK_STACK_DEPTH        RT_TIMER_THREAD_STACK_SIZE
-#endif
-
-/* These options can be modified to selectively disable recursive mutex */
-/* Take effect only if RT_USING_MUTEX is defined */
-#ifdef RT_USING_MUTEX
-    #define configUSE_RECURSIVE_MUTEXES         1
-    #define configUSE_MUTEXES                   1
-#endif
-
-/* These options can be modified to selectively disable counting semaphore */
-/* Take effect only if RT_USING_SEMAPHORE is defined */
-#ifdef RT_USING_SEMAPHORE
-    #define configUSE_COUNTING_SEMAPHORES       1
-#endif
-
-/* Memory allocation related definitions. */
-#define configSUPPORT_STATIC_ALLOCATION         1
-#ifdef RT_USING_HEAP
-    #define configSUPPORT_DYNAMIC_ALLOCATION    1
-    #define configTOTAL_HEAP_SIZE               10240
-    #define configAPPLICATION_ALLOCATED_HEAP    0
-#endif
-
-/* Hook functions are not supported. */
-#define configUSE_IDLE_HOOK                     0
-#define configUSE_TICK_HOOK                     0
-#define configCHECK_FOR_STACK_OVERFLOW          0
-#define configUSE_MALLOC_FAILED_HOOK            0
-#define configUSE_DAEMON_TASK_STARTUP_HOOK      0
-
-/* The following features are not supported. */
-#define INCLUDE_xTimerPendFunctionCall          0
-#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
-#define configUSE_CO_ROUTINES                   0
-#define configQUEUE_REGISTRY_SIZE               0
-#define configUSE_QUEUE_SETS                    0
-#define configUSE_NEWLIB_REENTRANT              0
-#define configUSE_TICKLESS_IDLE                 0
-#define configQUEUE_REGISTRY_SIZE               0
-#define configGENERATE_RUN_TIME_STATS           0
-#define configUSE_TRACE_FACILITY                0
-#define configUSE_STATS_FORMATTING_FUNCTIONS    0
-
-/* Can be modified */
-#define configMINIMAL_STACK_SIZE                128
-
-/* Optional functions */
-#define INCLUDE_vTaskPrioritySet                1
-#define INCLUDE_uxTaskPriorityGet               1
-#define INCLUDE_vTaskDelete                     1
-#define INCLUDE_vTaskSuspend                    1
-#define INCLUDE_xTaskDelayUntil                 1
-#define INCLUDE_vTaskDelay                      1
-#define INCLUDE_xTaskGetIdleTaskHandle          1
-#define INCLUDE_xTaskAbortDelay                 1
-#define INCLUDE_xSemaphoreGetMutexHolder        1
-#define INCLUDE_xTaskGetHandle                  1
-#define INCLUDE_uxTaskGetStackHighWaterMark     1
-#define INCLUDE_uxTaskGetStackHighWaterMark2    1
-#define INCLUDE_eTaskGetState                   1
-#define INCLUDE_xTaskResumeFromISR              1
-#define INCLUDE_xTaskGetSchedulerState          1
-#define INCLUDE_xTaskGetCurrentTaskHandle       1
-#define configUSE_APPLICATION_TASK_TAG          1
-#define configUSE_TASK_NOTIFICATIONS            1
-#define configTASK_NOTIFICATION_ARRAY_ENTRIES   3
-
-/* Other definitions can go here, e.g. configAssert*/
-
-#endif /* FREERTOS_CONFIG_H */