Freertos版本10.4
【stm32】【Freertos】config详解(1)-CSDN博客
协程相关定义Co-routine related definitions
都是默认0
#define configUSE_CO_ROUTINES 0
包含协程功能。
#define configMAX_CO_ROUTINE_PRIORITIES 1
大多数实际应用中,1-3 个协程优先级就足够了。
cpp
/******************************************************************************/
/* Co-routine related definitions. ********************************************/
/******************************************************************************/
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES 2
调试辅助Debugging assistance断言
cpp
/******************************************************************************/
/* Debugging assistance. ******************************************************/
/******************************************************************************/
/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
内存保护单元FreeRTOS MPU
Memory Protection Unit***********没有默认值的设置,在后面不使用MPU就不会报错。
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0//默认
允许应用程序定义特权函数,仅用于 FreeRTOS Cortex-M MPU 端口。
#define configTOTAL_MPU_REGIONS 8//默认
目标硬件上实现的 MPU 区域数量
#define configTEX_S_C_B_FLASH 0x07UL//默认
允许应用程序编写者覆盖覆盖 Flash 的 MPU 区域的TEX、可共享(S)、可缓存(C) 和可缓冲(B) 位的默认值。0x07UL(表示 TEX=000, S=1, C=1, B=1)
#define configTEX_S_C_B_SRAM 0x07UL//默认
覆盖 ram
#define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY 1//默认
允许应用程序任务提升权限
#define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 0//默认1
允许非特权任务进入临界区(有效地屏蔽中断)
#define configUSE_MPU_WRAPPERS_V1 0//默认
设置为 0 以使用新的 v2 MPU 包装器
#define configPROTECTED_KERNEL_OBJECT_POOL_SIZE 10
使用 v2 MPU 包装器时,设置内核对象总数。
#define configSYSTEM_CALL_STACK_SIZE 128
使用 v2 MPU 包装器,系统调用栈的大小。
#define configENABLE_ACCESS_CONTROL_LIST 1
使用 v2 MPU 包装器时,启用访问控制列表 (ACL) 功能。
cpp
/******************************************************************************/
/* FreeRTOS MPU specific definitions. *****************************************/
/******************************************************************************/
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
#define configTOTAL_MPU_REGIONS 8
#define configTEX_S_C_B_FLASH 0x07UL
#define configTEX_S_C_B_SRAM 0x07UL
#define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY 1
#define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 0
#define configUSE_MPU_WRAPPERS_V1 0
#define configPROTECTED_KERNEL_OBJECT_POOL_SIZE 10
#define configSYSTEM_CALL_STACK_SIZE 128
#define configENABLE_ACCESS_CONTROL_LIST 0
对称多处理特定配置定义SMP( Symmetric MultiProcessing ) Specific Configuration definitions
// #define configNUMBER_OF_CORES [Num of available cores]******
设置有多少个核心。以下参数在NUMBER_OF_CORES >1设置
#define configRUN_MULTIPLE_PRIORITIES 0
允许优先级不同的任务同时运行。
#define configUSE_CORE_AFFINITY 0
启用核心亲和性功能。
#define configTASK_DEFAULT_CORE_AFFINITY tskNO_AFFINITY//默认
启用了核心亲和性功能的 SMP 时,默认核心亲和性掩码。
#define configUSE_TASK_PREEMPTION_DISABLE 0
可以将单个任务设置为抢占式或协作式模式。
#define configUSE_PASSIVE_IDLE_HOOK 0//默认
允许应用程序编写者使用被动空闲任务钩子来添加后台功能,而无需单独任务的开销。
#define configTIMER_SERVICE_TASK_CORE_AFFINITY tskNO_AFFINITY//默认
允许应用程序编写者设置 RTOS 守护进程/定时器服务任务的核心亲和性。
cpp
/******************************************************************************/
/* SMP( Symmetric MultiProcessing ) Specific Configuration definitions. *******/
/******************************************************************************/
/* Set configNUMBER_OF_CORES to the number of available processor cores.
* Defaults to 1 if left undefined. */
/*
#define configNUMBER_OF_CORES [Num of available cores]
*/
#define configRUN_MULTIPLE_PRIORITIES 0
#define configUSE_CORE_AFFINITY 0
#define configTASK_DEFAULT_CORE_AFFINITY tskNO_AFFINITY
#define configUSE_TASK_PREEMPTION_DISABLE 0
#define configUSE_PASSIVE_IDLE_HOOK 0
#define configTIMER_SERVICE_TASK_CORE_AFFINITY tskNO_AFFINITY
ARMv8-M安全侧端口相关定义ARMv8-M secure side port related definitions
#define secureconfigMAX_SECURE_CONTEXTS 5
可以调用 ARMv8-M 芯片安全侧的任务的最大数量。启用TRUSTZONE才会使用。
#define configKERNEL_PROVIDED_STATIC_MEMORY 0//默认
控制空闲任务和定时器任务内存的分配方式。
-
设置为 1:使用 FreeRTOS 内核提供的静态内存实现
-
设置为 0:应用程序需要自己提供内存管理实现
ARMv8-M 端口特定配置定义ARMv8-M port Specific Configuration definitions
注意这里的FPU和MPU不是只有ARMv8才有。
#define configENABLE_TRUSTZONE 0//默认
ARMv8-M 端口中的 TrustZone 支持。
#define configRUN_FREERTOS_SECURE_ONLY 1//默认
没有TrustZone,自然只在安全侧。
/* 如果应用程序编写者不想使用 TrustZone,但硬件不支持禁用 TrustZone,
* 那么整个应用程序(包括 FreeRTOS 调度器)可以在安全侧运行,而永远不会
* 分支到非安全侧。要做到这一点,除了将 configENABLE_TRUSTZONE 设置为 0 外,
* 还要将 configRUN_FREERTOS_SECURE_ONLY 设置为 1。 */
#define configENABLE_MPU 0//默认
#define configENABLE_FPU 0//默认
内存保护单元 (MPU),启用浮点单元 (FPU)
#define configENABLE_MVE 0//默认
M-Profile 向量扩展 (MVE) 支持,仅适用于 Cortex-M55 和 Cortex-M85 端口。
cpp
/******************************************************************************/
/* ARMv8-M secure side port related definitions. ******************************/
/******************************************************************************/
#define secureconfigMAX_SECURE_CONTEXTS 5//ENABLE_TRUSTZONE
#define configKERNEL_PROVIDED_STATIC_MEMORY 0
/******************************************************************************/
/* ARMv8-M port Specific Configuration definitions. ***************************/
/******************************************************************************/
#define configENABLE_TRUSTZONE 0
#define configRUN_FREERTOS_SECURE_ONLY 1
#if (CPU_TYPE == STM32F4)
#define configENABLE_MPU 0
#define configENABLE_FPU 1
#elif (CPU_TYPE == STM32F1)
#define configENABLE_MPU 0
#define configENABLE_FPU 0
#else
#define configENABLE_MPU 0
#define configENABLE_FPU 0
#endif
#define configENABLE_MVE 0
ARMv7-M 和 ARMv8-M 端口特定配置定义ARMv7-M and ARMv8-M port Specific Configuration definitions
/* 设置 configCHECK_HANDLER_INSTALLATION 为 1,以启用额外的断言来
* 验证应用程序是否正确安装了 FreeRTOS 中断处理程序。
*
* 应用程序可以通过以下方式之一安装 FreeRTOS 中断处理程序:
* 1. 直接路由 - 分别为 SVC 调用和 PendSV 中断安装
* vPortSVCHandler 和 xPortPendSVHandler 函数。
* 2. 间接路由 - 为 SVC 调用和 PendSV 中断安装单独的处理程序,
* 并从这些处理程序将程序控制路由到 vPortSVCHandler 和
* xPortPendSVHandler 函数。使用间接路由的应用程序必须将
* configCHECK_HANDLER_INSTALLATION 设置为 0。
*
* 如果未定义,默认为 1。 */
#define configCHECK_HANDLER_INSTALLATION 1
包含或排除功能的定义Definitions that include or exclude functionality
不讲解*********
/* Set the following configUSE_* constants to 1 to include the named feature in
* the build, or 0 to exclude the named feature from the build. */
#define configUSE_TASK_NOTIFICATIONS 1
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_QUEUE_SETS 0
#define configUSE_APPLICATION_TASK_TAG 0
/* USE_POSIX_ERRNO enables the task global FreeRTOS_errno variable which will
* contain the most recent error for that task. */
#define configUSE_POSIX_ERRNO 0
/* Set the following INCLUDE_* constants to 1 to include the named API function,
* or 0 to exclude the named API function. Most linkers will remove unused
* functions even when the constant is 1. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_eTaskGetState 0
#define INCLUDE_xTimerPendFunctionCall 0
#define INCLUDE_xTaskAbortDelay 0
#define INCLUDE_xTaskGetHandle 0
#define INCLUDE_xTaskResumeFromISR 1
超级重要的中断处理程序名称映射
FreeRTOS 内部的命名:
Cortex-M 处理器有三个核心系统异常,用于操作系统调度:
-
SVC (Supervisor Call) - 系统服务调用
-
PendSV (Pendable Service) - 可挂起的系统服务
-
SysTick - 系统定时器中断
cpp
FreeRTOS 内部的命名:
void vPortSVCHandler(void); // SVC 处理程序
void xPortPendSVHandler(void); // PendSV 处理程序
void xPortSysTickHandler(void); // SysTick 处理程序
ARM CMSIS 标准命名:
void SVC_Handler(void); // CMSIS 标准名称
void PendSV_Handler(void); // CMSIS 标准名称
void SysTick_Handler(void); // CMSIS 标准名称
cpp
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names. */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
结束
cpp
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/******************************************************************************/
/* Hardware description related definitions. **********************************/
/******************************************************************************/
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
#include <stdint.h>
extern uint32_t SystemCoreClock;
#endif
#define configCPU_CLOCK_HZ ( SystemCoreClock )
/* configSYSTICK_CLOCK_HZ is an optional parameter for ARM Cortex-M ports only.
*
* By default ARM Cortex-M ports generate the RTOS tick interrupt from the
* Cortex-M SysTick timer. Most Cortex-M MCUs run the SysTick timer at the same
* frequency as the MCU itself - when that is the case configSYSTICK_CLOCK_HZ is
* not needed and should be left undefined. If the SysTick timer is clocked at a
* different frequency to the MCU core then set configCPU_CLOCK_HZ to the MCU
* clock frequency, as normal, and configSYSTICK_CLOCK_HZ to the SysTick clock
* frequency. Not used if left undefined.
* The default value is undefined (commented out). If you need this value bring
* it back and set it to a suitable value. */
/*
#define configSYSTICK_CLOCK_HZ [Platform specific]
*/
/******************************************************************************/
/* Scheduling behaviour related definitions. **********************************/
/******************************************************************************/
#define configTICK_RATE_HZ ((TickType_t)1000) //1ms
#define configUSE_PREEMPTION 1//pre-emptive co-operative scheduling
#define configUSE_TIME_SLICING 0//Unable time slicing
#if defined(STM32)
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#else
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#endif
#define configUSE_TICKLESS_IDLE 0//无响应滴答空闲
#define configMAX_PRIORITIES 5
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 30 )//120byte
#if !defined(DEBUG)
#define configMAX_TASK_NAME_LEN 5
#else
#define configMAX_TASK_NAME_LEN 10
#endif
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_64_BITS
#define configIDLE_SHOULD_YIELD 1
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1
#define configQUEUE_REGISTRY_SIZE 8
#if !defined(DEBUG)
#define configQUEUE_REGISTRY_SIZE 0
#else
#define configQUEUE_REGISTRY_SIZE 8
#endif
#define configENABLE_BACKWARD_COMPATIBILITY 0
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
#define configUSE_MINI_LIST_ITEM 1
#define configSTACK_DEPTH_TYPE size_t
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
#define configHEAP_CLEAR_MEMORY_ON_FREE 0
#define configSTATS_BUFFER_MAX_LENGTH 0xFFFF
#define configUSE_NEWLIB_REENTRANT 0
/******************************************************************************/
/* Software timer related definitions. ****************************************/
/******************************************************************************/
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES / 2 )//Medium
#define configTIMER_TASK_STACK_DEPTH ( 1024 )//configMINIMAL_STACK_SIZE
#define configTIMER_QUEUE_LENGTH 10
/******************************************************************************/
/* Event Group related definitions. *******************************************/
/******************************************************************************/
#define configUSE_EVENT_GROUPS 1
/******************************************************************************/
/* Stream Buffer related definitions. *****************************************/
/******************************************************************************/
#define configUSE_STREAM_BUFFERS 1
/******************************************************************************/
/* Memory allocation related definitions. *************************************/
/******************************************************************************/
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1
// #define configTOTAL_HEAP_SIZE ( (size_t) ( 4 * 1024 ) )
#define configAPPLICATION_ALLOCATED_HEAP 0
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
#define configENABLE_HEAP_PROTECTOR 0
/******************************************************************************/
/* Interrupt nesting behaviour configuration. *********************************/
/******************************************************************************/
/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
#define configPRIO_BITS 4 /* 15 priority levels */
#endif
/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0xf
/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
/* Interrupt priorities used by the kernel port layer itself. These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* Another name for configMAX_SYSCALL_INTERRUPT_PRIORITY - the name used depends
* on the FreeRTOS port. */
// #define configMAX_API_CALL_INTERRUPT_PRIORITY 0
/******************************************************************************/
/* Hook and callback function related definitions. ****************************/
/******************************************************************************/
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
#define configUSE_SB_COMPLETED_CALLBACK 0
#define configCHECK_FOR_STACK_OVERFLOW 0
/******************************************************************************/
/* Run time and task stats gathering related definitions. *********************/
/******************************************************************************/
#define configGENERATE_RUN_TIME_STATS 0
#if !defined(DEBUG)
#define configUSE_TRACE_FACILITY 0
#else
#define configUSE_TRACE_FACILITY 1
#endif
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/******************************************************************************/
/* Co-routine related definitions. ********************************************/
/******************************************************************************/
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES 2
/******************************************************************************/
/* Debugging assistance. ******************************************************/
/******************************************************************************/
/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}
/******************************************************************************/
/* FreeRTOS MPU specific definitions. *****************************************/
/******************************************************************************/
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
#define configTOTAL_MPU_REGIONS 8
#define configTEX_S_C_B_FLASH 0x07UL
#define configTEX_S_C_B_SRAM 0x07UL
#define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY 1
#define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 0
#define configUSE_MPU_WRAPPERS_V1 0
#define configPROTECTED_KERNEL_OBJECT_POOL_SIZE 10
#define configSYSTEM_CALL_STACK_SIZE 128
#define configENABLE_ACCESS_CONTROL_LIST 0
/******************************************************************************/
/* SMP( Symmetric MultiProcessing ) Specific Configuration definitions. *******/
/******************************************************************************/
/* Set configNUMBER_OF_CORES to the number of available processor cores.
* Defaults to 1 if left undefined. */
/*
#define configNUMBER_OF_CORES [Num of available cores]
*/
#define configRUN_MULTIPLE_PRIORITIES 0
#define configUSE_CORE_AFFINITY 0
#define configTASK_DEFAULT_CORE_AFFINITY tskNO_AFFINITY
#define configUSE_TASK_PREEMPTION_DISABLE 0
#define configUSE_PASSIVE_IDLE_HOOK 0
#define configTIMER_SERVICE_TASK_CORE_AFFINITY tskNO_AFFINITY
/******************************************************************************/
/* ARMv8-M secure side port related definitions. ******************************/
/******************************************************************************/
#define secureconfigMAX_SECURE_CONTEXTS 5//ENABLE_TRUSTZONE
#define configKERNEL_PROVIDED_STATIC_MEMORY 0
/******************************************************************************/
/* ARMv8-M port Specific Configuration definitions. ***************************/
/******************************************************************************/
#define configENABLE_TRUSTZONE 0
#define configRUN_FREERTOS_SECURE_ONLY 1
#if (CPU_TYPE == STM32F4)
#define configENABLE_MPU 0
#define configENABLE_FPU 1
#elif (CPU_TYPE == STM32F1)
#define configENABLE_MPU 0
#define configENABLE_FPU 0
#else
#define configENABLE_MPU 0
#define configENABLE_FPU 0
#endif
#define configENABLE_MVE 0
/******************************************************************************/
/* ARMv7-M and ARMv8-M port Specific Configuration definitions. ***************/
/******************************************************************************/
#define configCHECK_HANDLER_INSTALLATION 1
/******************************************************************************/
/* Definitions that include or exclude functionality. *************************/
/******************************************************************************/
/* Set the following configUSE_* constants to 1 to include the named feature in
* the build, or 0 to exclude the named feature from the build. */
#define configUSE_TASK_NOTIFICATIONS 1
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_QUEUE_SETS 0
#define configUSE_APPLICATION_TASK_TAG 0
/* USE_POSIX_ERRNO enables the task global FreeRTOS_errno variable which will
* contain the most recent error for that task. */
#define configUSE_POSIX_ERRNO 0
/* Set the following INCLUDE_* constants to 1 to include the named API function,
* or 0 to exclude the named API function. Most linkers will remove unused
* functions even when the constant is 1. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTaskGetCurrentTaskHandle 1
#define INCLUDE_uxTaskGetStackHighWaterMark 0
#define INCLUDE_xTaskGetIdleTaskHandle 0
#define INCLUDE_eTaskGetState 0
#define INCLUDE_xTimerPendFunctionCall 0
#define INCLUDE_xTaskAbortDelay 0
#define INCLUDE_xTaskGetHandle 0
#define INCLUDE_xTaskResumeFromISR 1
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names. */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
#endif /* FREERTOS_CONFIG_H */
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H