FreeRTOS_Config.h


  1 #include "something.h"
  2 
  3 #define configUSE_PREEMPTION                    1 /* 1:抢占式  0:协程式 */
  4 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 /* 要执行下一个任务的方法,一般设置为1 效率高 */
  5 #define configUSE_TICKLESS_IDLE                 0 /* 是否使用低功耗 1:使用低功耗,0:不使用低功耗,一般为0 */
  6 #define configCPU_CLOCK_HZ                      60000000 /* 系统时钟频率 */
  7 #define configSYSTICK_CLOCK_HZ                  1000000  /* 一般不设置 */
  8 #define configTICK_RATE_HZ                      250 /* RTOS用来计时的时间基准,时间片的长短 */
  9 #define configMAX_PRIORITIES                    5   /* 优先级的数量,一般设置成7 */
 10 #define configMINIMAL_STACK_SIZE                128 /* 空闲任务堆栈大小 */
 11 #define configMAX_TASK_NAME_LEN                 16  /* 创建任务时候,允许的任务名称最长长度,按照字节计算 */
 12 #define configUSE_16_BIT_TICKS                  0   /* 用来记录tick中断的次数,一般设置为0 (阻塞延时的最大时间会更长)*/
 13 #define configIDLE_SHOULD_YIELD                 1   /* 最低优先级任务的工作模式,设置为1 则在其他任务和最低优先级任务优先级相同时,进行时间切片 */
 14 #define configUSE_TASK_NOTIFICATIONS            1   /* 任务通知功能,设置为1,有任务通知功能,每个任务多消耗8字节RAM */
 15 #define configTASK_NOTIFICATION_ARRAY_ENTRIES   3   /* 任务通知组 V10.4.0 之前任务只有一个通知值,为了向前兼容,一般设置为1 */
 16 #define configUSE_MUTEXES                       0   /* 互斥锁功能 设置为1启动,0忽略 */
 17 #define configUSE_RECURSIVE_MUTEXES             0   /* 递归互斥锁功能设置为1启动,0忽略 */
 18 #define configUSE_COUNTING_SEMAPHORES           0   /* 计数信号量功能,设置为1使能 0不使能 */
 19 #define configUSE_ALTERNATIVE_API               0   /* Deprecated! */ /* 和队列相关 */
 20 #define configQUEUE_REGISTRY_SIZE               10  /* 队列注册相关,以便在GUI中文本与队列相关连 */
 21 #define configUSE_QUEUE_SETS                    0   /* 设置为1表示包含队列集功能(在多个队列和信号量上阻塞或等待的能力) */
 22 
 23 #define configUSE_TIME_SLICING                  0  
 24 /* 默认情况下(如果configUSE_TIME_SLICING没有定义,
 25 或者configUSE_TIME_SLICING定义为1),
 26 FreeRTOS使用优先级的抢占式调度和时间切片。
 27 这意味着RTOS调度器将始终运行处于就绪状态的最高优先级的任务,
 28 并在每个RTOS tick中断时在同等优先级的任务之间进行切换。
 29 如果configUSE_TIME_SLICING设置为0,
 30 那么RTOS调度器仍然会运行处于Ready状态的最高优先级的任务,
 31 但是不会仅仅因为tick中断发生而在同等优先级的任务之间进行切换。*/
 32 
 33 #define configUSE_NEWLIB_REENTRANT              0  /* 不用管,按照默认值 */
 34 #define configENABLE_BACKWARD_COMPATIBILITY     0  /* 新旧版本更新使用,按照默认值自己不用修改 */
 35 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5  /* 设置每个任务的线程本地存储阵列中的索引数量。*/
 36 #define configSTACK_DEPTH_TYPE                  uint16_t /* 对战相关参数,不用修改 */
 37 #define configMESSAGE_BUFFER_LENGTH_TYPE        size_t
 38 
 39 /* Memory allocation related definitions. */
 40 #define configSUPPORT_STATIC_ALLOCATION             1  /*是否使用静态任务,1使用 如果使用静态任务,应用程序着需要实现两个函数 */
 41 void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer,
 42                                     StackType_t **ppxIdleTaskStackBuffer,
 43                                     uint32_t *pulIdleTaskStackSize )
 44 {
 45 /* If the buffers to be provided to the Idle task are declared inside this
 46 function then they must be declared static - otherwise they will be allocated on
 47 the stack and so not exists after this function exits. */
 48 static StaticTask_t xIdleTaskTCB;
 49 static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
 50 
 51     /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
 52     state will be stored. */
 53     *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
 54 
 55     /* Pass out the array that will be used as the Idle task's stack. */
 56     *ppxIdleTaskStackBuffer = uxIdleTaskStack;
 57 
 58     /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
 59     Note that, as the array is necessarily of type StackType_t,
 60     configMINIMAL_STACK_SIZE is specified in words, not bytes. */
 61     *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
 62 }
 63 void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer,
 64                                      StackType_t **ppxTimerTaskStackBuffer,
 65                                      uint32_t *pulTimerTaskStackSize )
 66 {
 67 /* If the buffers to be provided to the Timer task are declared inside this
 68 function then they must be declared static - otherwise they will be allocated on
 69 the stack and so not exists after this function exits. */
 70 static StaticTask_t xTimerTaskTCB;
 71 static StackType_t  uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
 72 
 73     /* Pass out a pointer to the StaticTask_t structure in which the Timer
 74     task's state will be stored. */
 75     *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
 76 
 77     /* Pass out the array that will be used as the Timer task's stack. */
 78     *ppxTimerTaskStackBuffer = uxTimerTaskStack;
 79 
 80     /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
 81     Note that, as the array is necessarily of type StackType_t,
 82     configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
 83     *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
 84 }
 85 
 86 #define configSUPPORT_DYNAMIC_ALLOCATION            1      /* 1使用动态任务 */
 87 #define configTOTAL_HEAP_SIZE                       10240  /* RTOS中堆的总量,就是任务分配的RAM 总和 */
 88 #define configAPPLICATION_ALLOCATED_HEAP            1      /* 1设置应用者可以自行定义堆得位置 一般设置为1 */
 89 #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP   1      /* 默认为0 不修改 */
 90 
 91 /* Hook function related definitions. */
 92 #define configUSE_IDLE_HOOK                     0          /* 是否是能空闲任务钩子函数 一般设置为0 不使能 */
 93 #define configUSE_TICK_HOOK                     0 
 94 #define configCHECK_FOR_STACK_OVERFLOW          0          /* 是否使能堆栈溢出检测 上*/
 95 #define configUSE_MALLOC_FAILED_HOOK            0          /* 内存分配失败时候是否调用钩子函数 1调用,必须定义一个钩子函数 */
 96 /*
 97 void vApplicationMallocFailedHook( void );
 98 */
 99 
100 
101 #define configUSE_DAEMON_TASK_STARTUP_HOOK      0 /* 基本不用不用设置 */
102 
103 /* Run time and task stats gathering related definitions. */
104 #define configGENERATE_RUN_TIME_STATS           0 /* 运行实际统计 */
105 #define configUSE_TRACE_FACILITY                0 /* 如果您希望包含额外的结构成员和函数以帮助执行可视化和跟踪,则设置为1 */
106 #define configUSE_STATS_FORMATTING_FUNCTIONS    0 
107 /*
108 将configUSE_TRACE_FACILITY和configUSE_STATS_FORMATTING_FUNCTIONS设置为1,
109 以便在构建中包含vTaskList()和vTaskGetRunTimeStats()函数。
110 */
111 
112 /* Co-routine related definitions. */
113 #define configUSE_CO_ROUTINES                   0 /* 是否使用协程功能 */
114 #define configMAX_CO_ROUTINE_PRIORITIES         1 /* 协程可用的优先级数量 */
115 
116 /* Software timer related definitions. */
117 #define configUSE_TIMERS                        1  /* 是否使用软件计时器功能 一般设置为1需要 */
118 #define configTIMER_TASK_PRIORITY               3  /* 定时器的优先级 */
119 #define configTIMER_QUEUE_LENGTH                10 /* 设置软件定时器命令队列的长度 */
120 #define configTIMER_TASK_STACK_DEPTH            configMINIMAL_STACK_SIZE
121 
122 /* Interrupt nesting behaviour configuration. */
123 #define configKERNEL_INTERRUPT_PRIORITY         [dependent of processor]
124 #define configMAX_SYSCALL_INTERRUPT_PRIORITY    [dependent on processor and application]
125 #define configMAX_API_CALL_INTERRUPT_PRIORITY   [dependent on processor and application]
126 
127 /* Define to trap errors during development. */
128 #define configASSERT( ( x ) ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )
129 
130 /* FreeRTOS MPU specific definitions. */
131 #define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
132 #define configTOTAL_MPU_REGIONS                                8 /* Default value. */
133 #define configTEX_S_C_B_FLASH                                  0x07UL /* Default value. */
134 #define configTEX_S_C_B_SRAM                                   0x07UL /* Default value. */
135 #define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY            1
136 
137 /* ARMv8-M secure side port related definitions. */
138 #define secureconfigMAX_SECURE_CONTEXTS         5
139 
140 /* Optional functions - most linkers will remove unused functions anyway. */
141 #define INCLUDE_vTaskPrioritySet                1
142 #define INCLUDE_uxTaskPriorityGet               1
143 #define INCLUDE_vTaskDelete                     1
144 #define INCLUDE_vTaskSuspend                    1
145 #define INCLUDE_xResumeFromISR                  1
146 #define INCLUDE_vTaskDelayUntil                 1
147 #define INCLUDE_vTaskDelay                      1
148 #define INCLUDE_xTaskGetSchedulerState          1
149 #define INCLUDE_xTaskGetCurrentTaskHandle       1
150 #define INCLUDE_uxTaskGetStackHighWaterMark     0
151 #define INCLUDE_xTaskGetIdleTaskHandle          0
152 #define INCLUDE_eTaskGetState                   0
153 #define INCLUDE_xEventGroupSetBitFromISR        1
154 #define INCLUDE_xTimerPendFunctionCall          0
155 #define INCLUDE_xTaskAbortDelay                 0
156 #define INCLUDE_xTaskGetHandle                  0
157 #define INCLUDE_xTaskResumeFromISR              1
158 
159 /* A header file that defines trace macro can be included here. */
160 
161 #endif /* FREERTOS_CONFIG_H */