移植 FreeRTOS
2026-07-06
上一节VSCode工程搭建为例,展示添加FreeRTOS操作系统步骤。
下载源码
下载 FreeRTOS 版本V11.3.0 对应
移植
复制源文件
V11版本的目录结构与之前有明显的不同
需要的核心文件全部在在FreeRTOS-Kernel中FreeRTOSv202406.01-LTS->FreeRTOS-LTS->FreeRTOS->FreeRTOS-Kernel
复制该目录到工程目录如下所示:
project# 工程根目录
.vscode# vscode配置目录
…
CMSIS# 架构库目录
…
STM32F10x_StdPeriph_Driver# 标准外设库 目录
…
FreeRTOS-Kernel# FREERTOS 内核目录
…
build# 编译输出目录
…
main.c# LED点亮示例代码
CMakeLists.txt# CMAKE编译配置文件
stlink-dap.cfg# 仿真器配置文件
stm32f1x.cfg# 目标芯片配置文件
STM32F103xx_FLASH.ld# 链接脚本文件
STM32F103xx.svd# 目标芯片寄存器
stm32f10x_conf.h# 标准外设库配置文件
添加代码补全和智能提示
添加FREERTOS相关头文件 该文件修改只影响代码预览和跳转,对工程的编译调试、仿真、无影响。
.vscode/c_cpp_properties.json
"includePath": [
"${workspaceFolder}/CMSIS/CM3/CoreSupport",
"${workspaceFolder}/CMSIS/CM3/DeviceSupport/ST/STM32F10x",
"${workspaceFolder}/STM32F10x_StdPeriph_Driver/inc",
"${workspaceFolder}/FreeRTOS-Kernel",
"${workspaceFolder}/FreeRTOS-Kernel/include",
"${workspaceFolder}/FreeRTOS-Kernel/examples/template_configuration",
"${workspaceFolder}/FreeRTOS-Kernel/portable/GCC/ARM_CM3",
"${workspaceFolder}/"
],添加头文件、源文件路径配置
添加FREERTOS相关的源文件、头文件
CMakeLists.txt
# 添加头文件搜索路径
include_directories(
${PROJECT_SOURCE_DIR}/CMSIS/CM3/CoreSupport
${PROJECT_SOURCE_DIR}/CMSIS/CM3/DeviceSupport/ST/STM32F10x
${PROJECT_SOURCE_DIR}/STM32F10x_StdPeriph_Driver/inc
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/include
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/examples/template_configuration
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/portable/GCC/ARM_CM3
${PROJECT_SOURCE_DIR}/
)
# 添加源文件
file(GLOB CMSIS_LIST
${PROJECT_SOURCE_DIR}/CMSIS/CM3/CoreSupport/core_cm3.c
${PROJECT_SOURCE_DIR}/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/portable/GCC/ARM_CM3/port.c
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/portable/MemMang/heap_4.c
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/croutine.c
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/event_groups.c
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/list.c
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/queue.c
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/stream_buffer.c
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/tasks.c
${PROJECT_SOURCE_DIR}/FreeRTOS-Kernel/timers.c
)FREERTOS配置修改及裁剪
参照以下内容进行修改
FreeRTOS-Kernel/examples/template_configuration/FreeRTOSConfig.h
/*
* FreeRTOS Kernel V11.3.0
* 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
*
*/
/*******************************************************************************
* This file provides an example FreeRTOSConfig.h header file, inclusive of an
* abbreviated explanation of each configuration item. Online and reference
* documentation provides more information.
* https://www.freertos.org/a00110.html
*
* Constant values enclosed in square brackets ('[' and ']') must be completed
* before this file will build.
*
* Use the FreeRTOSConfig.h supplied with the RTOS port in use rather than this
* generic file, if one is available.
******************************************************************************/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/******************************************************************************/
/* Hardware description related definitions. **********************************/
/******************************************************************************/
/* In most cases, configCPU_CLOCK_HZ must be set to the frequency of the clock
* that drives the peripheral used to generate the kernels periodic tick
* interrupt. The default value is set to 20MHz and matches the QEMU demo
* settings. Your application will certainly need a different value so set this
* correctly. This is very often, but not always, equal to the main system clock
* frequency. */
// #define configCPU_CLOCK_HZ ( ( unsigned long ) 20000000 )
#define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 ) //修改主频
/* 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. **********************************/
/******************************************************************************/
/* configTICK_RATE_HZ sets frequency of the tick interrupt in Hz, normally
* calculated from the configCPU_CLOCK_HZ value. */
#define configTICK_RATE_HZ 100
/* Set configUSE_PREEMPTION to 1 to use pre-emptive scheduling. Set
* configUSE_PREEMPTION to 0 to use co-operative scheduling.
* See https://www.freertos.org/single-core-amp-smp-rtos-scheduling.html. */
#define configUSE_PREEMPTION 1
/* Set configUSE_TIME_SLICING to 1 to have the scheduler switch between Ready
* state tasks of equal priority on every tick interrupt. Set
* configUSE_TIME_SLICING to 0 to prevent the scheduler switching between Ready
* state tasks just because there was a tick interrupt. See
* https://freertos.org/single-core-amp-smp-rtos-scheduling.html. */
#define configUSE_TIME_SLICING 0
/* Set configUSE_PORT_OPTIMISED_TASK_SELECTION to 1 to select the next task to
* run using an algorithm optimised to the instruction set of the target
* hardware - normally using a count leading zeros assembly instruction. Set to
* 0 to select the next task to run using a generic C algorithm that works for
* all FreeRTOS ports. Not all FreeRTOS ports have this option. Defaults to 0
* if left undefined. */
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
/* Set configUSE_TICKLESS_IDLE to 1 to use the low power tickless mode. Set to
* 0 to keep the tick interrupt running at all times. Not all FreeRTOS ports
* support tickless mode. See
* https://www.freertos.org/low-power-tickless-rtos.html Defaults to 0 if left
* undefined. */
#define configUSE_TICKLESS_IDLE 0
/* configMAX_PRIORITIES Sets the number of available task priorities. Tasks can
* be assigned priorities of 0 to (configMAX_PRIORITIES - 1). Zero is the
* lowest priority. */
#define configMAX_PRIORITIES 5
/* configMINIMAL_STACK_SIZE defines the size of the stack used by the Idle task
* (in words, not in bytes!). The kernel does not use this constant for any
* other purpose. Demo applications use the constant to make the demos somewhat
* portable across hardware architectures. */
#define configMINIMAL_STACK_SIZE 128
/* configMAX_TASK_NAME_LEN sets the maximum length (in characters) of a task's
* human readable name. Includes the NULL terminator. */
#define configMAX_TASK_NAME_LEN 16
/* Time is measured in 'ticks' - which is the number of times the tick interrupt
* has executed since the RTOS kernel was started.
* The tick count is held in a variable of type TickType_t.
*
* configTICK_TYPE_WIDTH_IN_BITS controls the type (and therefore bit-width) of
* TickType_t:
*
* Defining configTICK_TYPE_WIDTH_IN_BITS as TICK_TYPE_WIDTH_16_BITS causes
* TickType_t to be defined (typedef'ed) as an unsigned 16-bit type.
*
* Defining configTICK_TYPE_WIDTH_IN_BITS as TICK_TYPE_WIDTH_32_BITS causes
* TickType_t to be defined (typedef'ed) as an unsigned 32-bit type.
*
* Defining configTICK_TYPE_WIDTH_IN_BITS as TICK_TYPE_WIDTH_64_BITS causes
* TickType_t to be defined (typedef'ed) as an unsigned 64-bit type. */
// #define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_64_BITS
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS // 滴答定时器变量类型
/* Set configIDLE_SHOULD_YIELD to 1 to have the Idle task yield to an
* application task if there is an Idle priority (priority 0) application task
* that can run. Set to 0 to have the Idle task use all of its timeslice.
* Default to 1 if left undefined. */
#define configIDLE_SHOULD_YIELD 1
/* Each task has an array of task notifications.
* configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
* array. See https://www.freertos.org/RTOS-task-notifications.html Defaults to
* 1 if left undefined. */
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1
/* configQUEUE_REGISTRY_SIZE sets the maximum number of queues and semaphores
* that can be referenced from the queue registry. Only required when using a
* kernel aware debugger. Defaults to 0 if left undefined. */
#define configQUEUE_REGISTRY_SIZE 0
/* Set configENABLE_BACKWARD_COMPATIBILITY to 1 to map function names and
* datatypes from old version of FreeRTOS to their latest equivalent. Defaults
* to 1 if left undefined. */
#define configENABLE_BACKWARD_COMPATIBILITY 0
/* Each task has its own array of pointers that can be used as thread local
* storage. configNUM_THREAD_LOCAL_STORAGE_POINTERS set the number of indexes
* in the array. See
* https://www.freertos.org/thread-local-storage-pointers.html Defaults to 0 if
* left undefined. */
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
/* When configUSE_MINI_LIST_ITEM is set to 0, MiniListItem_t and ListItem_t are
* both the same. When configUSE_MINI_LIST_ITEM is set to 1, MiniListItem_t
* contains 3 fewer fields than ListItem_t which saves some RAM at the cost of
* violating strict aliasing rules which some compilers depend on for
* optimization. Defaults to 1 if left undefined. */
#define configUSE_MINI_LIST_ITEM 1
/* Sets the type used by the parameter to xTaskCreate() that specifies the stack
* size of the task being created. The same type is used to return information
* about stack usage in various other API calls. Defaults to size_t if left
* undefined. */
#define configSTACK_DEPTH_TYPE size_t
/* configMESSAGE_BUFFER_LENGTH_TYPE sets the type used to store the length of
* each message written to a FreeRTOS message buffer (the length is also written
* to the message buffer. Defaults to size_t if left undefined - but that may
* waste space if messages never go above a length that could be held in a
* uint8_t. */
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
/* If configHEAP_CLEAR_MEMORY_ON_FREE is set to 1, then blocks of memory
* allocated using pvPortMalloc() will be cleared (i.e. set to zero) when freed
* using vPortFree(). Defaults to 0 if left undefined. */
#define configHEAP_CLEAR_MEMORY_ON_FREE 1
/* vTaskList and vTaskGetRunTimeStats APIs take a buffer as a parameter and
* assume that the length of the buffer is configSTATS_BUFFER_MAX_LENGTH.
* Defaults to 0xFFFF if left undefined. New applications are recommended to use
* vTaskListTasks and vTaskGetRunTimeStatistics APIs instead and supply the
* length of the buffer explicitly to avoid memory corruption. */
#define configSTATS_BUFFER_MAX_LENGTH 0xFFFF
/* Set configUSE_NEWLIB_REENTRANT to 1 to have a newlib reent structure
* allocated for each task. Set to 0 to not support newlib reent structures.
* Default to 0 if left undefined.
*
* Note Newlib support has been included by popular demand, but is not used or
* tested by the FreeRTOS maintainers themselves. FreeRTOS is not responsible
* for resulting newlib operation. User must be familiar with newlib and must
* provide system-wide implementations of the necessary stubs. Note that (at the
* time of writing) the current newlib design implements a system-wide malloc()
* that must be provided with locks. */
#define configUSE_NEWLIB_REENTRANT 0
/******************************************************************************/
/* Software timer related definitions. ****************************************/
/******************************************************************************/
/* Set configUSE_TIMERS to 1 to include software timer functionality in the
* build. Set to 0 to exclude software timer functionality from the build. The
* FreeRTOS/source/timers.c source file must be included in the build if
* configUSE_TIMERS is set to 1. Default to 0 if left undefined. See
* https://www.freertos.org/RTOS-software-timer.html. */
#define configUSE_TIMERS 1
/* configTIMER_TASK_PRIORITY sets the priority used by the timer task. Only
* used if configUSE_TIMERS is set to 1. The timer task is a standard FreeRTOS
* task, so its priority is set like any other task. See
* https://www.freertos.org/RTOS-software-timer-service-daemon-task.html Only
* used if configUSE_TIMERS is set to 1. */
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
/* configTIMER_TASK_STACK_DEPTH sets the size of the stack allocated to the
* timer task (in words, not in bytes!). The timer task is a standard FreeRTOS
* task. See
* https://www.freertos.org/RTOS-software-timer-service-daemon-task.html Only
* used if configUSE_TIMERS is set to 1. */
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
/* configTIMER_QUEUE_LENGTH sets the length of the queue (the number of discrete
* items the queue can hold) used to send commands to the timer task. See
* https://www.freertos.org/RTOS-software-timer-service-daemon-task.html Only
* used if configUSE_TIMERS is set to 1. */
#define configTIMER_QUEUE_LENGTH 10
/******************************************************************************/
/* Event Group related definitions. *******************************************/
/******************************************************************************/
/* Set configUSE_EVENT_GROUPS to 1 to include event group functionality in the
* build. Set to 0 to exclude event group functionality from the build. The
* FreeRTOS/source/event_groups.c source file must be included in the build if
* configUSE_EVENT_GROUPS is set to 1. Defaults to 1 if left undefined. */
#define configUSE_EVENT_GROUPS 1
/******************************************************************************/
/* Stream Buffer related definitions. *****************************************/
/******************************************************************************/
/* Set configUSE_STREAM_BUFFERS to 1 to include stream buffer functionality in
* the build. Set to 0 to exclude event group functionality from the build. The
* FreeRTOS/source/stream_buffer.c source file must be included in the build if
* configUSE_STREAM_BUFFERS is set to 1. Defaults to 1 if left undefined. */
#define configUSE_STREAM_BUFFERS 1
/******************************************************************************/
/* Memory allocation related definitions. *************************************/
/******************************************************************************/
/* Set configSUPPORT_STATIC_ALLOCATION to 1 to include FreeRTOS API functions
* that create FreeRTOS objects (tasks, queues, etc.) using statically allocated
* memory in the build. Set to 0 to exclude the ability to create statically
* allocated objects from the build. Defaults to 0 if left undefined. See
* https://www.freertos.org/Static_Vs_Dynamic_Memory_Allocation.html. */
#define configSUPPORT_STATIC_ALLOCATION 1
/* Set configSUPPORT_DYNAMIC_ALLOCATION to 1 to include FreeRTOS API functions
* that create FreeRTOS objects (tasks, queues, etc.) using dynamically
* allocated memory in the build. Set to 0 to exclude the ability to create
* dynamically allocated objects from the build. Defaults to 1 if left
* undefined. See
* https://www.freertos.org/Static_Vs_Dynamic_Memory_Allocation.html. */
#define configSUPPORT_DYNAMIC_ALLOCATION 1
/* Sets the total size of the FreeRTOS heap, in bytes, when heap_1.c, heap_2.c
* or heap_4.c are included in the build. This value is defaulted to 4096 bytes
* but it must be tailored to each application. Note the heap will appear in
* the .bss section. See https://www.freertos.org/a00111.html. */
#define configTOTAL_HEAP_SIZE 4096
/* Set configAPPLICATION_ALLOCATED_HEAP to 1 to have the application allocate
* the array used as the FreeRTOS heap. Set to 0 to have the linker allocate
* the array used as the FreeRTOS heap. Defaults to 0 if left undefined. */
#define configAPPLICATION_ALLOCATED_HEAP 0
/* Set configSTACK_ALLOCATION_FROM_SEPARATE_HEAP to 1 to have task stacks
* allocated from somewhere other than the FreeRTOS heap. This is useful if you
* want to ensure stacks are held in fast memory. Set to 0 to have task stacks
* come from the standard FreeRTOS heap. The application writer must provide
* implementations for pvPortMallocStack() and vPortFreeStack() if set to 1.
* Defaults to 0 if left undefined. */
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
/* Set configENABLE_HEAP_PROTECTOR to 1 to enable bounds checking and
* obfuscation to internal heap block pointers in heap_4.c and heap_5.c to help
* catch pointer corruptions. Defaults to 0 if left undefined. */
#define configENABLE_HEAP_PROTECTOR 0
/******************************************************************************/
/* Interrupt nesting behaviour configuration. *********************************/
/******************************************************************************/
/* configKERNEL_INTERRUPT_PRIORITY sets the priority of the tick and context
* switch performing interrupts. Not supported by all FreeRTOS ports. See
* https://www.freertos.org/RTOS-Cortex-M3-M4.html for information specific to
* ARM Cortex-M devices. */
// #define configKERNEL_INTERRUPT_PRIORITY 0
/* configMAX_SYSCALL_INTERRUPT_PRIORITY sets the interrupt priority above which
* FreeRTOS API calls must not be made. Interrupts above this priority are
* never disabled, so never delayed by RTOS activity. The default value is set
* to the highest interrupt priority (0). Not supported by all FreeRTOS ports.
* See https://www.freertos.org/RTOS-Cortex-M3-M4.html for information specific
* to ARM Cortex-M devices. */
// #define configMAX_SYSCALL_INTERRUPT_PRIORITY 0
/* Another name for configMAX_SYSCALL_INTERRUPT_PRIORITY - the name used depends
* on the FreeRTOS port. */
// #define configMAX_API_CALL_INTERRUPT_PRIORITY 0
/* 中断优先级配置 - 适用于 STM32F103 (4位优先级) */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 // 最低优先级给内核
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 // 允许调用API的最高优先级(必须 > 0 且 < 15)
/* 以下两个宏由上面的宏计算得出,不要直接修改 */
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << 4 )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << 4 )
#define configMAX_API_CALL_INTERRUPT_PRIORITY configMAX_SYSCALL_INTERRUPT_PRIORITY
/******************************************************************************/
/* Hook and callback function related definitions. ****************************/
/******************************************************************************/
/* Set the following configUSE_* constants to 1 to include the named hook
* functionality in the build. Set to 0 to exclude the hook functionality from
* the build. The application writer is responsible for providing the hook
* function for any set to 1. See https://www.freertos.org/a00016.html. */
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
/* Set configUSE_SB_COMPLETED_CALLBACK to 1 to have send and receive completed
* callbacks for each instance of a stream buffer or message buffer. When the
* option is set to 1, APIs xStreamBufferCreateWithCallback() and
* xStreamBufferCreateStaticWithCallback() (and likewise APIs for message
* buffer) can be used to create a stream buffer or message buffer instance
* with application provided callbacks. Defaults to 0 if left undefined. */
#define configUSE_SB_COMPLETED_CALLBACK 0
/* Set configCHECK_FOR_STACK_OVERFLOW to 1 or 2 for FreeRTOS to check for a
* stack overflow at the time of a context switch. Set to 0 to not look for a
* stack overflow. If configCHECK_FOR_STACK_OVERFLOW is 1 then the check only
* looks for the stack pointer being out of bounds when a task's context is
* saved to its stack - this is fast but somewhat ineffective. If
* configCHECK_FOR_STACK_OVERFLOW is 2 then the check looks for a pattern
* written to the end of a task's stack having been overwritten. This is
* slower, but will catch most (but not all) stack overflows. The application
* writer must provide the stack overflow callback when
* configCHECK_FOR_STACK_OVERFLOW is set to 1. See
* https://www.freertos.org/Stacks-and-stack-overflow-checking.html Defaults to
* 0 if left undefined. */
// #define configCHECK_FOR_STACK_OVERFLOW 2
#define configCHECK_FOR_STACK_OVERFLOW 0 // 关闭任务栈的溢出检测
/******************************************************************************/
/* Run time and task stats gathering related definitions. *********************/
/******************************************************************************/
/* Set configGENERATE_RUN_TIME_STATS to 1 to have FreeRTOS collect data on the
* processing time used by each task. Set to 0 to not collect the data. The
* application writer needs to provide a clock source if set to 1. Defaults to
* 0 if left undefined. See https://www.freertos.org/rtos-run-time-stats.html.
*/
#define configGENERATE_RUN_TIME_STATS 0
/* Set configUSE_TRACE_FACILITY to include additional task structure members
* are used by trace and visualisation functions and tools. Set to 0 to exclude
* the additional information from the structures. Defaults to 0 if left
* undefined. */
#define configUSE_TRACE_FACILITY 0
/* Set to 1 to include the vTaskList() and vTaskGetRunTimeStats() functions in
* the build. Set to 0 to exclude these functions from the build. These two
* functions introduce a dependency on string formatting functions that would
* otherwise not exist - hence they are kept separate. Defaults to 0 if left
* undefined. */
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/******************************************************************************/
/* Co-routine related definitions. ********************************************/
/******************************************************************************/
/* Set configUSE_CO_ROUTINES to 1 to include co-routine functionality in the
* build, or 0 to omit co-routine functionality from the build. To include
* co-routines, croutine.c must be included in the project. Defaults to 0 if
* left undefined. */
#define configUSE_CO_ROUTINES 0
/* configMAX_CO_ROUTINE_PRIORITIES defines the number of priorities available
* to the application co-routines. Any number of co-routines can share the same
* priority. Defaults to 0 if left undefined. */
#define configMAX_CO_ROUTINE_PRIORITIES 1
/******************************************************************************/
/* Debugging assistance. ******************************************************/
/******************************************************************************/
/* configASSERT() has the same semantics as the standard C assert(). It can
* either be defined to take an action when the assertion fails, or not defined
* at all (i.e. comment out or delete the definitions) to completely remove
* assertions. configASSERT() can be defined to anything you want, for example
* you can call a function if an assert fails that passes the filename and line
* number of the failing assert (for example, "vAssertCalled( __FILE__, __LINE__
* )" or it can simple disable interrupts and sit in a loop to halt all
* execution on the failing line for viewing in a debugger. */
/* *INDENT-OFF* */
#define configASSERT( x ) \
if( ( x ) == 0 ) \
{ \
taskDISABLE_INTERRUPTS(); \
for( ; ; ) \
; \
}
/* *INDENT-ON* */
/******************************************************************************/
/* FreeRTOS MPU specific definitions. *****************************************/
/******************************************************************************/
/* If configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS is set to 1 then
* the application writer can provide functions that execute in privileged mode.
* See:
* https://www.freertos.org/a00110.html#configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS
* Defaults to 0 if left undefined. Only used by the FreeRTOS Cortex-M MPU
* ports, not the standard ARMv7-M Cortex-M port. */
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
/* Set configTOTAL_MPU_REGIONS to the number of MPU regions implemented on your
* target hardware. Normally 8 or 16. Only used by the FreeRTOS Cortex-M MPU
* ports, not the standard ARMv7-M Cortex-M port. Defaults to 8 if left
* undefined. */
#define configTOTAL_MPU_REGIONS 8
/* configTEX_S_C_B_FLASH allows application writers to override the default
* values for the for TEX, Shareable (S), Cacheable (C) and Bufferable (B) bits
* for the MPU region covering Flash. Defaults to 0x07UL (which means TEX=000,
* S=1, C=1, B=1) if left undefined. Only used by the FreeRTOS Cortex-M MPU
* ports, not the standard ARMv7-M Cortex-M port. */
#define configTEX_S_C_B_FLASH 0x07UL
/* configTEX_S_C_B_SRAM allows application writers to override the default
* values for the for TEX, Shareable (S), Cacheable (C) and Bufferable (B) bits
* for the MPU region covering RAM. Defaults to 0x07UL (which means TEX=000,
* S=1, C=1, B=1) if left undefined. Only used by the FreeRTOS Cortex-M MPU
* ports, not the standard ARMv7-M Cortex-M port. */
#define configTEX_S_C_B_SRAM 0x07UL
/* Set configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY to 0 to prevent any privilege
* escalations originating from outside of the kernel code itself. Set to 1 to
* allow application tasks to raise privilege. Defaults to 1 if left undefined.
* Only used by the FreeRTOS Cortex-M MPU ports, not the standard ARMv7-M
* Cortex-M port. */
#define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY 1
/* Set configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS to 1 to allow unprivileged
* tasks enter critical sections (effectively mask interrupts). Set to 0 to
* prevent unprivileged tasks entering critical sections. Defaults to 1 if left
* undefined. Only used by the FreeRTOS Cortex-M MPU ports, not the standard
* ARMv7-M Cortex-M port. */
#define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 0
/* FreeRTOS Kernel version 10.6.0 introduced a new v2 MPU wrapper, namely
* mpu_wrappers_v2.c. Set configUSE_MPU_WRAPPERS_V1 to 0 to use the new v2 MPU
* wrapper. Set configUSE_MPU_WRAPPERS_V1 to 1 to use the old v1 MPU wrapper
* (mpu_wrappers.c). Defaults to 0 if left undefined. */
#define configUSE_MPU_WRAPPERS_V1 0
/* When using the v2 MPU wrapper, set configPROTECTED_KERNEL_OBJECT_POOL_SIZE to
* the total number of kernel objects, which includes tasks, queues, semaphores,
* mutexes, event groups, timers, stream buffers and message buffers, in your
* application. The application will not be able to have more than
* configPROTECTED_KERNEL_OBJECT_POOL_SIZE kernel objects at any point of
* time. */
#define configPROTECTED_KERNEL_OBJECT_POOL_SIZE 10
/* When using the v2 MPU wrapper, set configSYSTEM_CALL_STACK_SIZE to the size
* of the system call stack in words. Each task has a statically allocated
* memory buffer of this size which is used as the stack to execute system
* calls. For example, if configSYSTEM_CALL_STACK_SIZE is defined as 128 and
* there are 10 tasks in the application, the total amount of memory used for
* system call stacks is 128 * 10 = 1280 words. */
#define configSYSTEM_CALL_STACK_SIZE 128
/* When using the v2 MPU wrapper, set configENABLE_ACCESS_CONTROL_LIST to 1 to
* enable Access Control List (ACL) feature. When ACL is enabled, an
* unprivileged task by default does not have access to any kernel object other
* than itself. The application writer needs to explicitly grant the
* unprivileged task access to the kernel objects it needs using the APIs
* provided for the same. Defaults to 0 if left undefined. */
#define configENABLE_ACCESS_CONTROL_LIST 1
/******************************************************************************/
/* 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]
*/
/* When using SMP (i.e. configNUMBER_OF_CORES is greater than one), set
* configRUN_MULTIPLE_PRIORITIES to 0 to allow multiple tasks to run
* simultaneously only if they do not have equal priority, thereby maintaining
* the paradigm of a lower priority task never running if a higher priority task
* is able to run. If configRUN_MULTIPLE_PRIORITIES is set to 1, multiple tasks
* with different priorities may run simultaneously - so a higher and lower
* priority task may run on different cores at the same time. */
#define configRUN_MULTIPLE_PRIORITIES 0
/* When using SMP (i.e. configNUMBER_OF_CORES is greater than one), set
* configUSE_CORE_AFFINITY to 1 to enable core affinity feature. When core
* affinity feature is enabled, the vTaskCoreAffinitySet and
* vTaskCoreAffinityGet APIs can be used to set and retrieve which cores a task
* can run on. If configUSE_CORE_AFFINITY is set to 0 then the FreeRTOS
* scheduler is free to run any task on any available core. */
#define configUSE_CORE_AFFINITY 0
/* When using SMP with core affinity feature enabled, set
* configTASK_DEFAULT_CORE_AFFINITY to change the default core affinity mask for
* tasks created without an affinity mask specified. Setting the define to 1
* would make such tasks run on core 0 and setting it to (1 <<
* portGET_CORE_ID()) would make such tasks run on the current core. This config
* value is useful, if swapping tasks between cores is not supported (e.g.
* Tricore) or if legacy code should be controlled. Defaults to tskNO_AFFINITY
* if left undefined. */
#define configTASK_DEFAULT_CORE_AFFINITY tskNO_AFFINITY
/* When using SMP (i.e. configNUMBER_OF_CORES is greater than one), if
* configUSE_TASK_PREEMPTION_DISABLE is set to 1, individual tasks can be set to
* either pre-emptive or co-operative mode using the vTaskPreemptionDisable and
* vTaskPreemptionEnable APIs. */
#define configUSE_TASK_PREEMPTION_DISABLE 0
/* When using SMP (i.e. configNUMBER_OF_CORES is greater than one), set
* configUSE_PASSIVE_IDLE_HOOK to 1 to allow the application writer to use
* the passive idle task hook to add background functionality without the
* overhead of a separate task. Defaults to 0 if left undefined. */
#define configUSE_PASSIVE_IDLE_HOOK 0
/* When using SMP (i.e. configNUMBER_OF_CORES is greater than one),
* configTIMER_SERVICE_TASK_CORE_AFFINITY allows the application writer to set
* the core affinity of the RTOS Daemon/Timer Service task. Defaults to
* tskNO_AFFINITY if left undefined. */
#define configTIMER_SERVICE_TASK_CORE_AFFINITY tskNO_AFFINITY
/******************************************************************************/
/* ARMv8-M secure side port related definitions. ******************************/
/******************************************************************************/
/* secureconfigMAX_SECURE_CONTEXTS define the maximum number of tasks that can
* call into the secure side of an ARMv8-M chip. Not used by any other ports.
*/
#define secureconfigMAX_SECURE_CONTEXTS 5
/* Defines the kernel provided implementation of
* vApplicationGetIdleTaskMemory() and vApplicationGetTimerTaskMemory()
* to provide the memory that is used by the Idle task and Timer task
* respectively. The application can provide it's own implementation of
* vApplicationGetIdleTaskMemory() and vApplicationGetTimerTaskMemory() by
* setting configKERNEL_PROVIDED_STATIC_MEMORY to 0 or leaving it undefined. */
#define configKERNEL_PROVIDED_STATIC_MEMORY 1
/******************************************************************************/
/* ARMv8-M port Specific Configuration definitions. ***************************/
/******************************************************************************/
/* Set configENABLE_TRUSTZONE to 1 when running FreeRTOS on the non-secure side
* to enable the TrustZone support in FreeRTOS ARMv8-M ports which allows the
* non-secure FreeRTOS tasks to call the (non-secure callable) functions
* exported from secure side. */
#define configENABLE_TRUSTZONE 1
/* If the application writer does not want to use TrustZone, but the hardware
* does not support disabling TrustZone then the entire application (including
* the FreeRTOS scheduler) can run on the secure side without ever branching to
* the non-secure side. To do that, in addition to setting
* configENABLE_TRUSTZONE to 0, also set configRUN_FREERTOS_SECURE_ONLY to 1. */
#define configRUN_FREERTOS_SECURE_ONLY 1
/* Set configENABLE_MPU to 1 to enable the Memory Protection Unit (MPU), or 0
* to leave the Memory Protection Unit disabled. */
// #define configENABLE_MPU 1
#define configENABLE_MPU 0 // 关闭MPU
/* Set configENABLE_FPU to 1 to enable the Floating Point Unit (FPU), or 0
* to leave the Floating Point Unit disabled. */
// #define configENABLE_FPU 1
#define configENABLE_FPU 0 // 关闭FPU
/* Set configENABLE_MVE to 1 to enable the M-Profile Vector Extension (MVE)
* support, or 0 to leave the MVE support disabled. This option is only
* applicable to Cortex-M52, Cortex-M55, Cortex-M85 and STAR-MC3 ports as
* M-Profile Vector Extension (MVE) is available only on these architectures.
* configENABLE_MVE must be left undefined, or defined to 0 for the
* Cortex-M23,Cortex-M33 and Cortex-M35P ports. */
// #define configENABLE_MVE 1
#define configENABLE_MVE 0 // 关闭MVE
/******************************************************************************/
/* ARMv7-M and ARMv8-M port Specific Configuration definitions. ***************/
/******************************************************************************/
/* Set configCHECK_HANDLER_INSTALLATION to 1 to enable additional asserts to
* verify that the application has correctly installed FreeRTOS interrupt
* handlers.
*
* An application can install FreeRTOS interrupt handlers in one of the
* following ways:
* 1. Direct Routing - Install the functions vPortSVCHandler and
* xPortPendSVHandler for SVC call and PendSV interrupts respectively.
* 2. Indirect Routing - Install separate handlers for SVC call and PendSV
* interrupts and route program control from those
* handlers to vPortSVCHandler and xPortPendSVHandler functions. The
* applications that use Indirect Routing must set
* configCHECK_HANDLER_INSTALLATION to 0.
*
* Defaults to 1 if left undefined. */
#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_xTaskDelayUntil 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
//增加中断宏定义
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
#endif /* FREERTOS_CONFIG_H */main.c 编写修改
编写LED闪烁任务测试
main.c
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#include "FreeRTOS.h"
#include "task.h"
static TaskHandle_t xHandle1 = NULL;
void vTask1(void *param)
{
while (1)
{
vTaskDelay(pdMS_TO_TICKS(300));
GPIO_SetBits(GPIOC, GPIO_Pin_13);
vTaskDelay(pdMS_TO_TICKS(300));
GPIO_ResetBits(GPIOC, GPIO_Pin_13);
}
}
int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);
GPIO_InitTypeDef GPIO_InitStruct = {
.GPIO_Pin = GPIO_Pin_13,
.GPIO_Mode = GPIO_Mode_Out_PP,
.GPIO_Speed = GPIO_Speed_50MHz};
GPIO_Init(GPIOC, &GPIO_InitStruct);
xTaskCreate(vTask1, "vTask1", 64, NULL, 2, &xHandle1);
vTaskStartScheduler();
}镜像输出
编译成功后完整日志如下
* 正在执行任务: rm * -r
* 终端将被任务重用,按任意键关闭。
* 正在执行任务: cmake -G 'MinGW Makefiles' ..
-- The C compiler identification is GNU 16.1.0
-- The CXX compiler identification is GNU 16.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files/mingw64/bin/cc.exe
-- Check for working C compiler: C:/Program Files/mingw64/bin/cc.exe - works
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files/mingw64/bin/cc.exe
-- Check for working CXX compiler: C:/Program Files/mingw64/bin/cc.exe - works
-- Detecting CXX compile features
-- Detecting CXX compile features - done
build for debug!
-- The ASM compiler identification is GNU
-- Found assembler: C:/Program Files (x86)/GNU Arm Embedded Toolchain/10 2021.10/bin/arm-none-eabi-gcc.exe
-- Configuring done (7.1s)
-- Generating done (0.1s)
-- Build files have been written to: C:/Users/user/Desktop/stm32f103c8t6-rtos/build
* 终端将被任务重用,按任意键关闭。
* 正在执行任务: make
[ 2%] Building C object CMakeFiles/app.elf.dir/main.c.obj
[ 5%] Building C object CMakeFiles/app.elf.dir/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_md.s.obj
[ 8%] Building C object CMakeFiles/app.elf.dir/CMSIS/CM3/CoreSupport/core_cm3.c.obj
[ 10%] Building C object CMakeFiles/app.elf.dir/CMSIS/CM3/DeviceSupport/ST/STM32F10x/system_stm32f10x.c.obj
[ 13%] Building C object CMakeFiles/app.elf.dir/FreeRTOS-Kernel/croutine.c.obj
[ 16%] Building C object CMakeFiles/app.elf.dir/FreeRTOS-Kernel/event_groups.c.obj
[ 18%] Building C object CMakeFiles/app.elf.dir/FreeRTOS-Kernel/list.c.obj
[ 21%] Building C object CMakeFiles/app.elf.dir/FreeRTOS-Kernel/portable/GCC/ARM_CM3/port.c.obj
[ 24%] Building C object CMakeFiles/app.elf.dir/FreeRTOS-Kernel/portable/MemMang/heap_4.c.obj
[ 27%] Building C object CMakeFiles/app.elf.dir/FreeRTOS-Kernel/queue.c.obj
[ 29%] Building C object CMakeFiles/app.elf.dir/FreeRTOS-Kernel/stream_buffer.c.obj
[ 32%] Building C object CMakeFiles/app.elf.dir/FreeRTOS-Kernel/tasks.c.obj
[ 35%] Building C object CMakeFiles/app.elf.dir/FreeRTOS-Kernel/timers.c.obj
[ 37%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/misc.c.obj
[ 40%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_adc.c.obj
[ 43%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_bkp.c.obj
[ 45%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_can.c.obj
[ 48%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_cec.c.obj
[ 51%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_crc.c.obj
[ 54%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_dac.c.obj
[ 56%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_dbgmcu.c.obj
[ 59%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_dma.c.obj
[ 62%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_exti.c.obj
[ 64%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_flash.c.obj
[ 67%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_fsmc.c.obj
[ 70%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_gpio.c.obj
[ 72%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_i2c.c.obj
[ 75%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c.obj
[ 78%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_pwr.c.obj
[ 81%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_rcc.c.obj
[ 83%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_rtc.c.obj
[ 86%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_sdio.c.obj
[ 89%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_spi.c.obj
[ 91%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_tim.c.obj
[ 94%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_usart.c.obj
[ 97%] Building C object CMakeFiles/app.elf.dir/STM32F10x_StdPeriph_Driver/src/stm32f10x_wwdg.c.obj
[100%] Linking C executable app.elf
Building demo (bin, hex, elf) and print size
text data bss dec hex filename
7588 16 7408 15012 3aa4 C:/Users/user/Desktop/stm32f103c8t6-rtos/build/app.elf
0 7604 0 7604 1db4 C:/Users/user/Desktop/stm32f103c8t6-rtos/build/app.hex
[100%] Built target app.elf
* 终端将被任务重用,按任意键关闭。其他
FreeRTOSConfig.h 注释翻译
- FreeRTOSConfig.h 官方配置手册链接
- 以下内容为机器翻译,仔细识别
/*
* FreeRTOS Kernel V11.3.0
* 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
*
*/
/*******************************************************************************
* 本文件提供一个示例 FreeRTOSConfig.h 头文件,并简要说明每个配置项。
* 在线文档和参考文档包含更多信息。
* https://www.freertos.org/a00110.html
*
* 用方括号('[' 和 ']')括起来的常量值必须在构建前填写。
*
* 如果正使用的 RTOS 移植层已提供 FreeRTOSConfig.h,请优先使用该文件,
* 而不是此通用示例文件。
******************************************************************************/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/******************************************************************************/
/* 硬件描述相关定义。*********************************************************/
/******************************************************************************/
/* 在大多数情况下,configCPU_CLOCK_HZ 必须设置为用于产生内核周期性滴答中断
* 的外设时钟频率。默认值为 20MHz,与 QEMU 演示设置一致。您的应用通常需要
* 不同的值,因此请正确设置。该值通常等于主系统时钟频率,但并非总是如此。 */
#define configCPU_CLOCK_HZ ( ( unsigned long ) 72000000 )
/* configSYSTICK_CLOCK_HZ 仅适用于 ARM Cortex-M 移植层。
*
* 默认情况下,ARM Cortex-M 移植层使用 Cortex-M SysTick 定时器生成 RTOS 滴答中断。
* 对于大多数 Cortex-M MCU,SysTick 定时器与 MCU 本身的频率相同 —— 在这种情况下,
* 无需定义 configSYSTICK_CLOCK_HZ,应保持未定义。如果 SysTick 定时器的时钟频率
* 与 MCU 核心频率不同,则按常规将 configCPU_CLOCK_HZ 设置为 MCU 时钟频率,
* 并将 configSYSTICK_CLOCK_HZ 设置为 SysTick 时钟频率。未定义时不使用该选项。
* 默认值为未定义(已注释)。如果需要此值,请取消注释并设置为适当值。 */
/*
#define configSYSTICK_CLOCK_HZ [Platform specific]
*/
/******************************************************************************/
/* 调度行为相关定义。********************************************************/
/******************************************************************************/
/* configTICK_RATE_HZ 设置滴答中断频率,单位为 Hz,通常根据 configCPU_CLOCK_HZ 计算。 */
#define configTICK_RATE_HZ 100
/* 将 configUSE_PREEMPTION 设置为 1 使用抢占式调度。将 configUSE_PREEMPTION 设置为 0 使用协作式调度。
* 详见 https://www.freertos.org/single-core-amp-smp-rtos-scheduling.html 。 */
#define configUSE_PREEMPTION 1
/* 将 configUSE_TIME_SLICING 设置为 1,可使调度器在每次滴答中断时在相同优先级的就绪任务之间切换。
* 将 configUSE_TIME_SLICING 设置为 0,可防止调度器仅因为滴答中断而切换就绪任务。
* 详见 https://freertos.org/single-core-amp-smp-rtos-scheduling.html 。 */
#define configUSE_TIME_SLICING 0
/* 将 configUSE_PORT_OPTIMISED_TASK_SELECTION 设置为 1,可使用针对目标硬件指令集优化的算法选择下一个运行任务,
* 通常使用计数前导零汇编指令。设置为 0 则使用适用于所有 FreeRTOS 移植层的通用 C 算法。
* 并非所有 FreeRTOS 移植层都支持此选项。如果未定义,则默认为 0。 */
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
/* 将 configUSE_TICKLESS_IDLE 设置为 1,可使用低功耗无滴答模式。
* 设置为 0 可保持滴答中断始终运行。
* 并非所有 FreeRTOS 移植层都支持无滴答模式。
* 详见 https://www.freertos.org/low-power-tickless-rtos.html 。
* 若未定义则默认为 0。 */
#define configUSE_TICKLESS_IDLE 0
/* configMAX_PRIORITIES 设置可用任务优先级数量。任务可以使用 0 到 (configMAX_PRIORITIES - 1) 的优先级。
* 0 是最低优先级。 */
#define configMAX_PRIORITIES 5
/* configMINIMAL_STACK_SIZE 定义空闲任务使用的栈大小(以字为单位,而不是字节)。
* 内核不会将此常量用于其他目的。演示应用使用该常量以提高跨硬件架构的可移植性。 */
#define configMINIMAL_STACK_SIZE 128
/* configMAX_TASK_NAME_LEN 设置任务名称的最大长度(字符数)。包括 NULL 终止符。 */
#define configMAX_TASK_NAME_LEN 16
/* 时间以“滴答”为单位测量 —— 即自 RTOS 内核启动以来滴答中断执行的次数。
* 滴答计数保存在 TickType_t 类型的变量中。
*
* configTICK_TYPE_WIDTH_IN_BITS 控制 TickType_t 的类型(以及比特宽度):
*
* 将 configTICK_TYPE_WIDTH_IN_BITS 定义为 TICK_TYPE_WIDTH_16_BITS 时,
* TickType_t 将 typedef 为无符号 16 位类型。
*
* 将 configTICK_TYPE_WIDTH_IN_BITS 定义为 TICK_TYPE_WIDTH_32_BITS 时,
* TickType_t 将 typedef 为无符号 32 位类型。
*
* 将 configTICK_TYPE_WIDTH_IN_BITS 定义为 TICK_TYPE_WIDTH_64_BITS 时,
* TickType_t 将 typedef 为无符号 64 位类型。 */
#define configTICK_TYPE_WIDTH_IN_BITS TICK_TYPE_WIDTH_32_BITS
/* 将 configIDLE_SHOULD_YIELD 设置为 1,使空闲任务在存在可运行的空闲优先级(优先级 0)应用任务时让出。
* 将其设置为 0,则空闲任务将使用其整个时间片。若未定义则默认为 1。 */
#define configIDLE_SHOULD_YIELD 1
/* 每个任务都有一个任务通知数组。
* configTASK_NOTIFICATION_ARRAY_ENTRIES 设置数组索引数量。详见 https://www.freertos.org/RTOS-task-notifications.html 。
* 若未定义则默认为 1。 */
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 1
/* configQUEUE_REGISTRY_SIZE 设置可由队列注册表引用的队列和信号量的最大数量。
* 仅在使用内核感知调试器时需要。如果未定义则默认为 0。 */
#define configQUEUE_REGISTRY_SIZE 0
/* 将 configENABLE_BACKWARD_COMPATIBILITY 设置为 1,可将旧版本 FreeRTOS 的函数名和数据类型映射为其最新等效项。
* 若未定义,则默认为 1。 */
#define configENABLE_BACKWARD_COMPATIBILITY 0
/* 每个任务都有自己的指针数组,可用于线程本地存储。
* configNUM_THREAD_LOCAL_STORAGE_POINTERS 设置数组索引数量。详见
* https://www.freertos.org/thread-local-storage-pointers.html 。若未定义则默认为 0。 */
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0
/* 当 configUSE_MINI_LIST_ITEM 设置为 0 时,MiniListItem_t 与 ListItem_t 相同。
* 当设置为 1 时,MiniListItem_t 比 ListItem_t 少 3 个字段,可节省部分 RAM,
* 但可能违反某些编译器依赖的严格别名规则,从而影响优化。若未定义则默认为 1。 */
#define configUSE_MINI_LIST_ITEM 1
/* 设置 xTaskCreate() 的参数类型,用于指定创建任务的栈大小。
* 该类型也用于在各种其他 API 调用中返回栈使用情况信息。
* 若未定义则默认为 size_t。 */
#define configSTACK_DEPTH_TYPE size_t
/* configMESSAGE_BUFFER_LENGTH_TYPE 设置用于存储写入 FreeRTOS 消息缓冲区的每条消息长度的类型
*(该长度也会写入消息缓冲区)。若未定义则默认为 size_t,
* 但如果消息长度永远不会超过 uint8_t 能表示的范围,则可能浪费空间。 */
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
/* 如果将 configHEAP_CLEAR_MEMORY_ON_FREE 设置为 1,则通过 pvPortMalloc() 分配的内存块在使用 vPortFree() 释放时
* 会被清零。若未定义则默认为 0。 */
#define configHEAP_CLEAR_MEMORY_ON_FREE 1
/* vTaskList 和 vTaskGetRunTimeStats API 接收一个缓冲区作为参数,
* 并假定该缓冲区的长度为 configSTATS_BUFFER_MAX_LENGTH。
* 若未定义则默认为 0xFFFF。建议新应用使用 vTaskListTasks 和
* vTaskGetRunTimeStatistics API 并显式传入缓冲区长度,以避免内存损坏。 */
#define configSTATS_BUFFER_MAX_LENGTH 0xFFFF
/* 将 configUSE_NEWLIB_REENTRANT 设置为 1,可为每个任务分配一个 newlib reent 结构。
* 设置为 0 则不支持 newlib reent 结构。若未定义则默认为 0。
*
* 注意:newlib 支持是应用户需求而加入的,但 FreeRTOS 维护者本身不负责
* newlib 的使用或测试。FreeRTOS 不对由此产生的 newlib 运行结果负责。
* 用户必须熟悉 newlib,并提供必要的系统级存根实现。
* 当前 newlib 设计实现了系统范围的 malloc(),必须提供锁机制。 */
#define configUSE_NEWLIB_REENTRANT 0
/******************************************************************************/
/* Software timer related definitions. ****************************************/
/******************************************************************************/
/* 将 configUSE_TIMERS 设置为 1,可在构建中包含软件定时器功能。
* 设置为 0 可从构建中排除软件定时器功能。
* 如果 configUSE_TIMERS 设置为 1,则必须将 FreeRTOS/source/timers.c 源文件包含在构建中。
* 若未定义则默认为 0。详见 https://www.freertos.org/RTOS-software-timer.html 。 */
#define configUSE_TIMERS 1
/* configTIMER_TASK_PRIORITY 设置定时器任务使用的优先级。
* 仅在 configUSE_TIMERS 设置为 1 时使用。
* 定时器任务是标准 FreeRTOS 任务,因此其优先级与其他任务相同。
* 详见 https://www.freertos.org/RTOS-software-timer-service-daemon-task.html 。 */
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
/* configTIMER_TASK_STACK_DEPTH 设置为定时器任务分配的栈大小(以字为单位,而不是字节)。
* 定时器任务是标准 FreeRTOS 任务。
* 详见 https://www.freertos.org/RTOS-software-timer-service-daemon-task.html 。
* 仅在 configUSE_TIMERS 设置为 1 时使用。 */
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
/* configTIMER_QUEUE_LENGTH 设置用于向定时器任务发送命令的队列长度
*(队列可保存的离散项数)。
* 详见 https://www.freertos.org/RTOS-software-timer-service-daemon-task.html 。
* 仅在 configUSE_TIMERS 设置为 1 时使用。 */
#define configTIMER_QUEUE_LENGTH 10
/******************************************************************************/
/* 事件组相关定义。**********************************************************/
/******************************************************************************/
/* 将 configUSE_EVENT_GROUPS 设置为 1,可在构建中包含事件组功能。
* 设置为 0 可从构建中排除事件组功能。
* 如果 configUSE_EVENT_GROUPS 设置为 1,则必须将 FreeRTOS/source/event_groups.c
* 源文件包含在构建中。若未定义则默认为 1。 */
#define configUSE_EVENT_GROUPS 1
/******************************************************************************/
/* 流缓冲区相关定义。********************************************************/
/******************************************************************************/
/* 将 configUSE_STREAM_BUFFERS 设置为 1,可在构建中包含流缓冲区功能。
* 设置为 0 可从构建中排除该功能。
* 如果 configUSE_STREAM_BUFFERS 设置为 1,则必须将 FreeRTOS/source/stream_buffer.c
* 源文件包含在构建中。若未定义则默认为 1。 */
#define configUSE_STREAM_BUFFERS 1
/******************************************************************************/
/* 内存分配相关定义。********************************************************/
/******************************************************************************/
/* 将 configSUPPORT_STATIC_ALLOCATION 设置为 1,可在构建中包含使用静态分配内存
* 创建 FreeRTOS 对象(任务、队列等)的 API 函数。设置为 0 可从构建中排除
* 创建静态分配对象的能力。若未定义则默认为 0。详见
* https://www.freertos.org/Static_Vs_Dynamic_Memory_Allocation.html 。 */
#define configSUPPORT_STATIC_ALLOCATION 1
/* 将 configSUPPORT_DYNAMIC_ALLOCATION 设置为 1,可在构建中包含使用动态分配内存
* 创建 FreeRTOS 对象(任务、队列等)的 API 函数。设置为 0 可从构建中排除
* 创建动态分配对象的能力。若未定义则默认为 1。详见
* https://www.freertos.org/Static_Vs_Dynamic_Memory_Allocation.html 。 */
#define configSUPPORT_DYNAMIC_ALLOCATION 1
/* 设置 FreeRTOS 堆的总大小(以字节为单位),当 heap_1.c、heap_2.c 或 heap_4.c
* 包含在构建中时使用。该值默认 4096 字节,但必须针对每个应用进行调整。
* 注意堆将出现在 .bss 段中。详见 https://www.freertos.org/a00111.html 。 */
#define configTOTAL_HEAP_SIZE 4096
/* 将 configAPPLICATION_ALLOCATED_HEAP 设置为 1,可由应用分配 FreeRTOS 堆使用的数组。
* 设置为 0 则由链接器分配 FreeRTOS 堆使用的数组。若未定义则默认为 0。 */
#define configAPPLICATION_ALLOCATED_HEAP 0
/* 将 configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 设置为 1,可让任务栈从 FreeRTOS 堆之外的内存分配。
* 如果希望确保栈保存在高速内存中,则很有用。设置为 0 则任务栈从标准 FreeRTOS 堆中分配。
* 如果设置为 1,则应用程序编写者须提供 pvPortMallocStack() 和 vPortFreeStack() 的实现。
* 若未定义则默认为 0。 */
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
/* 将 configENABLE_HEAP_PROTECTOR 设置为 1,可在 heap_4.c 和 heap_5.c 中启用边界检查并对内部堆块指针进行混淆,
* 以帮助捕获指针损坏。若未定义则默认为 0。 */
#define configENABLE_HEAP_PROTECTOR 0
/******************************************************************************/
/* Interrupt nesting behaviour configuration. *********************************/
/******************************************************************************/
/* configKERNEL_INTERRUPT_PRIORITY 设置用于处理滴答和上下文切换的中断优先级。
* 并非所有 FreeRTOS 移植层都支持此选项。
* 详见 https://www.freertos.org/RTOS-Cortex-M3-M4.html ,适用于 ARM Cortex-M 设备。 */
// #define configKERNEL_INTERRUPT_PRIORITY 0
/* configMAX_SYSCALL_INTERRUPT_PRIORITY 设置在其优先级之上不得调用 FreeRTOS API 的中断优先级。
* 优先级高于该值的中断永远不会被禁用,因此不会被 RTOS 活动延迟。
* 默认值设置为最高中断优先级(0)。并非所有 FreeRTOS 移植层都支持此选项。
* 详见 https://www.freertos.org/RTOS-Cortex-M3-M4.html ,适用于 ARM Cortex-M 设备。 */
// #define configMAX_SYSCALL_INTERRUPT_PRIORITY 0
/* configMAX_API_CALL_INTERRUPT_PRIORITY 是 configMAX_SYSCALL_INTERRUPT_PRIORITY 的另一个名称 ——
* 使用哪个名称取决于 FreeRTOS 移植层。 */
// #define configMAX_API_CALL_INTERRUPT_PRIORITY 0
/* 中断优先级配置 - 适用于 STM32F103 (4 位优先级) */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 // 最低优先级给内核
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 // 允许调用API的最高优先级(必须 > 0 且 < 15)
/* 以下两个宏由上面的宏计算得出,不要直接修改 */
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << 4 )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << 4 )
#define configMAX_API_CALL_INTERRUPT_PRIORITY configMAX_SYSCALL_INTERRUPT_PRIORITY
/******************************************************************************/
/* 钩子和回调函数相关定义。*************************************************/
/******************************************************************************/
/* 将以下 configUSE_* 常量设置为 1,可在构建中包含对应的钩子功能。
* 设置为 0 可从构建中排除该钩子功能。
* 应用程序编写者负责为设置为 1 的钩子提供函数实现。
* 详见 https://www.freertos.org/a00016.html 。 */
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configUSE_MALLOC_FAILED_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0
/* 将 configUSE_SB_COMPLETED_CALLBACK 设置为 1,可为每个流缓冲区或消息缓冲区实例提供发送和接收完成回调。
* 当该选项设置为 1 时,可使用 xStreamBufferCreateWithCallback() 和
* xStreamBufferCreateStaticWithCallback()(以及消息缓冲区的类似 API)创建带有应用程序回调的实例。
* 若未定义则默认为 0。 */
#define configUSE_SB_COMPLETED_CALLBACK 0
/* 将 configCHECK_FOR_STACK_OVERFLOW 设置为 1 或 2,可使 FreeRTOS 在上下文切换时检查栈溢出。
* 设置为 0 可不进行栈溢出检查。
* 如果设置为 1,则检查仅检查任务上下文保存到栈时栈指针是否越界——速度较快但效果有限。
* 如果设置为 2,则检查栈底端写入的模式是否被覆盖——速度较慢,但可捕获大多数(但不是全部)栈溢出。
* 当 configCHECK_FOR_STACK_OVERFLOW 设置为 1 时,应用程序编写者必须提供栈溢出回调。
* 详见 https://www.freertos.org/Stacks-and-stack-overflow-checking.html 。若未定义则默认为 0。 */
#define configCHECK_FOR_STACK_OVERFLOW 0
/******************************************************************************/
/* 运行时与任务统计信息收集相关定义。****************************************/
/******************************************************************************/
/* 将 configGENERATE_RUN_TIME_STATS 设置为 1,可让 FreeRTOS 收集每个任务使用的处理时间数据。
* 设置为 0 可不收集该数据。
* 如果设置为 1,则应用程序编写者需要提供时钟源。
* 若未定义则默认为 0。详见 https://www.freertos.org/rtos-run-time-stats.html 。 */
#define configGENERATE_RUN_TIME_STATS 0
/* 将 configUSE_TRACE_FACILITY 设置为 1,可在任务结构中包含用于跟踪和可视化功能的附加成员。
* 设置为 0 可从结构中排除这些附加信息。若未定义则默认为 0。 */
#define configUSE_TRACE_FACILITY 0
/* 将 configUSE_STATS_FORMATTING_FUNCTIONS 设置为 1,可在构建中包含 vTaskList() 和 vTaskGetRunTimeStats() 函数。
* 设置为 0 则将这些函数从构建中排除。
* 这两个函数会引入对字符串格式化函数的依赖,因此单独控制。
* 若未定义则默认为 0。 */
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/******************************************************************************/
/* 协程相关定义。************************************************************/
/******************************************************************************/
/* 将 configUSE_CO_ROUTINES 设置为 1,可在构建中包含协程功能。
* 设置为 0 可从构建中排除协程功能。要包含协程,必须将 croutine.c 包含在项目中。
* 若未定义则默认为 0。 */
#define configUSE_CO_ROUTINES 0
/* configMAX_CO_ROUTINE_PRIORITIES 定义应用协程可用的优先级数量。
* 任何数量的协程可以共享相同优先级。若未定义则默认为 0。 */
#define configMAX_CO_ROUTINE_PRIORITIES 1
/******************************************************************************/
/* 调试辅助。**************************************************************/
/******************************************************************************/
/* configASSERT() 的语义与标准 C assert() 相同。
* 它可以在断言失败时执行某项操作,也可以完全不定义(即注释掉或删除定义),
* 以完全移除断言。
* configASSERT() 可以定义为任意内容,例如在断言失败时调用一个函数,
* 并传递失败断言的文件名和行号(例如 "vAssertCalled( __FILE__, __LINE__ )"),
* 或者它可以简单地禁用中断并进入循环,从而在调试器中查看失败行时停止全部执行。 */
/* *INDENT-OFF* */
#define configASSERT( x ) \
if( ( x ) == 0 ) \
{ \
taskDISABLE_INTERRUPTS(); \
for( ; ; ) \
; \
}
/* *INDENT-ON* */
/******************************************************************************/
/* FreeRTOS MPU specific definitions. *****************************************/
/******************************************************************************/
/* 如果将 configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 设置为 1,
* 应用程序编写者可以提供在特权模式下执行的函数。
* 详见:
* https://www.freertos.org/a00110.html#configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS
* 若未定义则默认为 0。仅用于 FreeRTOS Cortex-M MPU 移植层,
* 不用于标准 ARMv7-M Cortex-M 移植层。 */
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
/* 将 configTOTAL_MPU_REGIONS 设置为目标硬件实现的 MPU 区域数量。
* 通常为 8 或 16。仅用于 FreeRTOS Cortex-M MPU 移植层,
* 不用于标准 ARMv7-M Cortex-M 移植层。若未定义则默认为 8。 */
#define configTOTAL_MPU_REGIONS 8
/* configTEX_S_C_B_FLASH 允许应用程序覆盖用于 Flash MPU 区域的 TEX、
* Shareable (S)、Cacheable (C) 和 Bufferable (B) 位的默认值。
* 若未定义则默认为 0x07UL(表示 TEX=000、S=1、C=1、B=1)。
* 仅用于 FreeRTOS Cortex-M MPU 移植层,
* 不用于标准 ARMv7-M Cortex-M 移植层。 */
#define configTEX_S_C_B_FLASH 0x07UL
/* configTEX_S_C_B_SRAM 允许应用程序覆盖用于 SRAM MPU 区域的 TEX、
* Shareable (S)、Cacheable (C) 和 Bufferable (B) 位的默认值。
* 若未定义则默认为 0x07UL(表示 TEX=000、S=1、C=1、B=1)。
* 仅用于 FreeRTOS Cortex-M MPU 移植层,
* 不用于标准 ARMv7-M Cortex-M 移植层。 */
#define configTEX_S_C_B_SRAM 0x07UL
/* configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY 设置为 0 可防止来自内核代码外部的权限提升。
* 设置为 1 可允许应用任务提升权限。若未定义则默认为 1。
* 仅用于 FreeRTOS Cortex-M MPU 移植层,
* 不用于标准 ARMv7-M Cortex-M 移植层。 */
#define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY 1
/* configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 设置为 1,可允许非特权任务进入临界区(等效于屏蔽中断)。
* 设置为 0 可阻止非特权任务进入临界区。若未定义则默认为 1。
* 仅用于 FreeRTOS Cortex-M MPU 移植层,
* 不用于标准 ARMv7-M Cortex-M 移植层。 */
#define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS 0
/* FreeRTOS 内核 10.6.0 版本引入了新的 v2 MPU 包装器,即 mpu_wrappers_v2.c。
* 将 configUSE_MPU_WRAPPERS_V1 设置为 0 使用新的 v2 MPU 包装器。
* 将 configUSE_MPU_WRAPPERS_V1 设置为 1 使用旧的 v1 MPU 包装器(mpu_wrappers.c)。
* 若未定义则默认为 0。 */
#define configUSE_MPU_WRAPPERS_V1 0
/* 当使用 v2 MPU 包装器时,将 configPROTECTED_KERNEL_OBJECT_POOL_SIZE 设置为
* 应用中的内核对象总数,包括任务、队列、信号量、互斥量、事件组、定时器、
* 流缓冲区和消息缓冲区。应用程序在任何时刻都不能拥有超过
* configPROTECTED_KERNEL_OBJECT_POOL_SIZE 的内核对象。 */
#define configPROTECTED_KERNEL_OBJECT_POOL_SIZE 10
/* 当使用 v2 MPU 包装器时,将 configSYSTEM_CALL_STACK_SIZE 设置为系统调用栈的大小,单位为字。
* 每个任务都有一个静态分配的内存缓冲区,用作执行系统调用时的栈。
* 例如,如果 configSYSTEM_CALL_STACK_SIZE 定义为 128 并且应用程序中有 10 个任务,
* 则系统调用栈所占内存总量为 128 * 10 = 1280 字。 */
#define configSYSTEM_CALL_STACK_SIZE 128
/* 当使用 v2 MPU 包装器时,将 configENABLE_ACCESS_CONTROL_LIST 设置为 1 可启用访问控制列表(ACL)功能。
* 启用 ACL 时,默认情况下非特权任务除自身外无法访问任何内核对象。
* 应用程序编写者需要使用相应 API 明确授予非特权任务访问所需内核对象的权限。
* 若未定义则默认为 0。 */
#define configENABLE_ACCESS_CONTROL_LIST 1
/******************************************************************************/
/* SMP(对称多处理)特定配置定义。******************************************/
/******************************************************************************/
/* 将 configNUMBER_OF_CORES 设置为可用处理器核心数量。
* 若未定义则默认为 1。 */
/*
#define configNUMBER_OF_CORES [Num of available cores]
*/
/* 当使用 SMP(即 configNUMBER_OF_CORES 大于 1)时,将 configRUN_MULTIPLE_PRIORITIES 设置为 0,
* 仅在任务优先级不同且高优先级任务不可运行时才允许多个任务同时运行,
* 从而保持低优先级任务不会在高优先级任务可运行时运行的语义。
* 如果将 configRUN_MULTIPLE_PRIORITIES 设置为 1,则优先级不同的多个任务可能同时运行,
* 例如高优先级任务和低优先级任务可以在不同核心上同时运行。 */
#define configRUN_MULTIPLE_PRIORITIES 0
/* 当使用 SMP(即 configNUMBER_OF_CORES 大于 1)时,将 configUSE_CORE_AFFINITY 设置为 1 可启用核心亲和性功能。
* 启用该功能后,可使用 vTaskCoreAffinitySet 和 vTaskCoreAffinityGet API 设置和获取任务可运行的核心。
* 如果将 configUSE_CORE_AFFINITY 设置为 0,则 FreeRTOS 调度器可以在任何可用核心上运行任何任务。 */
#define configUSE_CORE_AFFINITY 0
/* 在启用核心亲和性功能的 SMP 中,将 configTASK_DEFAULT_CORE_AFFINITY 设置为默认核心亲和性掩码,
* 用于未指定亲和性的任务。
* 如果定义为 1,则此类任务运行在核心 0 上;
* 如果定义为 (1 << portGET_CORE_ID()),则此类任务运行在当前核心上。
* 当不支持在核心间交换任务(例如 Tricore)或需要控制遗留代码时,此配置值很有用。
* 若未定义则默认为 tskNO_AFFINITY。 */
#define configTASK_DEFAULT_CORE_AFFINITY tskNO_AFFINITY
/* 当使用 SMP(即 configNUMBER_OF_CORES 大于 1)时,若将 configUSE_TASK_PREEMPTION_DISABLE 设置为 1,
* 则可以使用 vTaskPreemptionDisable 和 vTaskPreemptionEnable API 将单个任务设为抢占模式或协作模式。 */
#define configUSE_TASK_PREEMPTION_DISABLE 0
/* 当使用 SMP(即 configNUMBER_OF_CORES 大于 1)时,将 configUSE_PASSIVE_IDLE_HOOK 设置为 1,
* 允许应用程序编写者使用被动空闲任务钩子,以在不增加单独任务开销的情况下添加后台功能。
* 若未定义则默认为 0。 */
#define configUSE_PASSIVE_IDLE_HOOK 0
/* 当使用 SMP(即 configNUMBER_OF_CORES 大于 1)时,
* configTIMER_SERVICE_TASK_CORE_AFFINITY 允许应用程序编写者设置 RTOS 守护/定时器服务任务的核心亲和性。
* 若未定义则默认为 tskNO_AFFINITY。 */
#define configTIMER_SERVICE_TASK_CORE_AFFINITY tskNO_AFFINITY
/******************************************************************************/
/* ARMv8-M 安全侧移植相关定义。**********************************************/
/******************************************************************************/
/* secureconfigMAX_SECURE_CONTEXTS 定义可调用 ARMv8-M 芯片安全侧的任务最大数量。
* 不适用于其他移植层。 */
#define secureconfigMAX_SECURE_CONTEXTS 5
/* 定义内核提供的 vApplicationGetIdleTaskMemory() 和 vApplicationGetTimerTaskMemory() 的实现,
* 用于分别提供空闲任务和定时器任务使用的内存。
* 如果应用程序希望提供自己的实现,可将 configKERNEL_PROVIDED_STATIC_MEMORY 设置为 0 或保持未定义。 */
#define configKERNEL_PROVIDED_STATIC_MEMORY 1
/******************************************************************************/
/* ARMv8-M 移植特定配置定义。*************************************************/
/******************************************************************************/
/* 当在非安全侧运行 FreeRTOS 时,将 configENABLE_TRUSTZONE 设置为 1,可启用 FreeRTOS ARMv8-M 移植层中的 TrustZone 支持,
* 允许非安全 FreeRTOS 任务调用从安全侧导出的(非安全可调用)函数。 */
#define configENABLE_TRUSTZONE 1
/* 如果应用程序不想使用 TrustZone,但硬件不支持禁用 TrustZone,
* 则整个应用程序(包括 FreeRTOS 调度器)可以在安全侧运行而不跳转到非安全侧。
* 为此,除了将 configENABLE_TRUSTZONE 设置为 0 外,还需将 configRUN_FREERTOS_SECURE_ONLY 设置为 1。 */
#define configRUN_FREERTOS_SECURE_ONLY 1
/* 将 configENABLE_MPU 设置为 1,可启用内存保护单元(MPU);设置为 0 可禁用 MPU。 */
#define configENABLE_MPU 0
/* 将 configENABLE_FPU 设置为 1,可启用浮点单元(FPU);设置为 0 可禁用 FPU。 */
#define configENABLE_FPU 0
/* 将 configENABLE_MVE 设置为 1,可启用 M-Profile 向量扩展 (MVE) 支持;设置为 0 可禁用 MVE 支持。
* 该选项仅适用于 Cortex-M52、Cortex-M55、Cortex-M85 和 STAR-MC3 移植层,
* 因为 MVE 仅在这些架构上可用。
* 对于 Cortex-M23、Cortex-M33 和 Cortex-M35P 移植层,configENABLE_MVE 必须保持未定义或定义为 0。 */
#define configENABLE_MVE 0
/******************************************************************************/
/* ARMv7-M 和 ARMv8-M 移植特定配置定义。****************************************/
/******************************************************************************/
/* 将 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
/******************************************************************************/
/* 包含或排除功能的定义。****************************************************/
/******************************************************************************/
/* 将以下 configUSE_* 常量设置为 1,可在构建中包含对应功能;设置为 0 可排除对应功能。 */
#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 启用任务级全局变量 FreeRTOS_errno,该变量将保存该任务的最近错误码。 */
#define configUSE_POSIX_ERRNO 0
/* 将以下 INCLUDE_* 常量设置为 1,可包含对应 API 函数;设置为 0 可排除对应 API 函数。
* 大多数链接器即使该常量为 1,也会删除未使用的函数。 */
#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_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
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
#endif /* FREERTOS_CONFIG_H */