FreeRTOS官方文件分析(二)FreeRTOSConfig.h文件分析

  • Post author:
  • Post category:其他


为了以后做项目参考啊


F1Demo的文件哈~仅仅是STM32F1的Demo啊~



目录


FreeRTOSConfig.h


官方文档&翻译


configUSE_IDLE_HOOK


configUSE_TICK_HOOK


configCPU_CLOCK_HZ


configTICK_RATE_HZ


configMAX_PRIORITIES


configMINIMAL_STACK_SIZE


configTOTAL_HEAP_SIZE


configMAX_TASK_NAME_LEN


configUSE_TRACE_FACILITY


configUSE_16_BIT_TICKS


configUSE_PREEMPTION


configUSE_TIME_SLICING


configIDLE_SHOULD_YIELD


configUSE_CO_ROUTINES


configMAX_CO_ROUTINE_PRIORITIES


configKERNEL_INTERRUPT_PRIORITY


configMAX_SYSCALL_INTERRUPT_PRIORITY


configLIBRARY_KERNEL_INTERRUPT_PRIORITY


FreeRTOSConfig.h


自官方文档:


FreeRTOS – The Free RTOS configuration constants and configuration options – FREE Open Source RTOS for small real time embedded systems

FreeRTOS is customised using a configuration file called FreeRTOSConfig.h. Every FreeRTOS application must have a FreeRTOSConfig.h header file in its pre-processor include path. FreeRTOSConfig.h tailors the RTOS kernel to the application being built. It is therefore specific to the application, not the RTOS, and should be located in an application directory, not in one of the RTOS kernel source code directories.

Each demo application included in the RTOS source code download has its own FreeRTOSConfig.h file. Some of the demos are quite old and do not contain all the available configuration options. Configuration options that are omitted are set to a default value within an RTOS source file.

Here is a typical FreeRTOSConfig.h definition, followed by an explanation of each parameter

FreeRTOS 使用名为 FreeRTOSConfig.h 的配置文件进行自定义。 每一个 FreeRTOS 应用程序的预处理器中必须有 FreeRTOSConfig.h 头文件 包括路径。 FreeRTOSConfig.h 为正在运行的应用程序定制 RTOS 内核 建成。 因此,它特定于应用程序,而不是 RTOS,并且应该是 位于应用程序目录中,而不是在 RTOS 内核源代码之一中的目录。

RTOS 源代码下载中包含的每个演示应用程序都有自己的 FreeRTOSConfig.h 文件。 一些演示很老,不包含所有可用的配置选项。 省略的配置选项 在 RTOS 源文件中设置为默认值。

这是一个典型的 FreeRTOSConfig.h 定义,后面是每个的解释 范围:

//文件一开始是版权声明,没啥用。
/*
 * FreeRTOS V202104.00
 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
 *
 * 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.
 *
 * http://www.FreeRTOS.org
 * http://aws.amazon.com/freertos
 *
 * 1 tab == 4 spaces!
 */

/*-----------------------------------------------------------
 * Application specific definitions.
 *
 * These definitions should be adjusted for your particular hardware and
 * application requirements.
 *
 * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
 * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 
 *
 * See http://www.freertos.org/a00110.html
 *----------------------------------------------------------*/

#define configUSE_IDLE_HOOK			1                                //是否定义IDLE空闲任务HOOK函数
#define configUSE_TICK_HOOK			0                                //是否定义TICK滴答HOOK函数
#define configCPU_CLOCK_HZ			( ( unsigned long ) 72000000 )	 //CPU时钟的频率
#define configTICK_RATE_HZ			( ( TickType_t ) 1000 )          //时钟Tick的频率
#define configMAX_PRIORITIES		( 5 )                            //最大优先级数
#define configMINIMAL_STACK_SIZE	( ( unsigned short ) 128 )       //最小堆栈大小
#define configTOTAL_HEAP_SIZE		( ( size_t ) ( 17 * 1024 ) )     //堆中可用RAM总量
#define configMAX_TASK_NAME_LEN		( 16 )                           //最大任务名字长度
#define configUSE_TRACE_FACILITY	0                                //配置使用跟踪
#define configUSE_16_BIT_TICKS		0                                //是否使用16位滴答计数值

#define configUSE_PREEMPTION		1        //允许抢占
#define configUSE_TIME_SLICING      1        //采用时间片
#define configIDLE_SHOULD_YIELD		1        //是否让空闲任务“放弃”抢占

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 		0            //是否使用CO_ROUTINES
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )    //CO_ROUTINE优先级

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
/* 设置为1可以使用函数,设置为0不能使用函数 */
#define INCLUDE_vTaskPrioritySet		1        //设置任务的优先级
#define INCLUDE_uxTaskPriorityGet		1        //获取某个任务的优先级
#define INCLUDE_vTaskDelete				1        //删除任务
#define INCLUDE_vTaskCleanUpResources	0        //可以回收删除任务后的资源
#define INCLUDE_vTaskSuspend			1        //将指定任务设置为挂起
#define INCLUDE_vTaskDelayUntil			1        //任务会进入阻塞状态
#define INCLUDE_vTaskDelay				1        //可用于固定频率的延时,它用来延时一个绝对时间。

/* This is the raw value as per the Cortex-M3 NVIC.  Values can be 255 (lowest) to 0 (1?) (highest). */
/*这是Cortex-M3 NVIC的原始值。值可以是255(最低)到0(1?)(最高)*/ 
#define configKERNEL_INTERRUPT_PRIORITY 		255
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY不能设置为零!!!! */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	191 /* equivalent to 0xb0, or priority 11. */
/*相当于0xb0或优先级11*/ 

/* This is the value being used as per the ST library which permits 16
priority values, 0 to 15.  This must correspond to the
configKERNEL_INTERRUPT_PRIORITY setting.  Here 15 corresponds to the lowest
NVIC value of 255. */
/*这是根据ST库使用的值,该库允许16优先级值,0到15。这必须符合配置内核中断优先级设置。
    这里15对应于最低值NVIC值为255*/ 
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY	15




官方文档&翻译



configUSE_IDLE_HOOK

Set to 1 if you wish to use an idle hook, or 0 to omit an idle hook.

如果希望使用空闲挂钩,请将其设置为1;如果希望省略空闲挂钩,请将其设置为0。

configUSE_TICK_HOOK

Set to 1 if you wish to use an tick hook, or 0 to omit an tick hook.

如果希望使用tick钩子,请将其设置为1;如果希望省略tick钩子,请将其设置为0。


configCPU_CLOCK_HZ

Enter the frequency in Hz at which the

internal

clock that drives the peripheral used to generate the tick interrupt will be executing – this is normally the same clock that drives the internal CPU clock. This value is required in order to correctly configure timer peripherals.

输入驱动用于生成勾选中断的外围设备的内部时钟将执行的频率(以Hz为单位),该频率通常与驱动内部CPU时钟的时钟相同。要正确配置计时器外围设备,需要此值。


configTICK_RATE_HZ

The frequency of the RTOS tick interrupt.

RTOS滴答中断的频率。

configMAX_PRIORITIES

The number of priorities available to the application tasks.

应用程序任务可用的优先级数。

configMINIMAL_STACK_SIZE

The size of the stack used by the idle task.

空闲任务使用的堆栈的大小。

configTOTAL_HEAP_SIZE

configMAX_TASK_NAME_LEN

The maximum permissible length of the descriptive name given to a task when the task is created. The length is specified in the number of characters including the NULL termination byte.

创建任务时赋予任务的描述性名称的最大允许长度。长度以包括空终止字节在内的字符数指定。

configUSE_TRACE_FACILITY

Set to 1 if you wish to include additional structure members and functions to assist with execution visualisation and tracing.

如果希望包含其他结构成员和功能,以协助执行可视化和跟踪,请设置为1。

configUSE_16_BIT_TICKS

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.

Defining configUSE_16_BIT_TICKS as 1 causes TickType_t to be defined (typedef’ed) as an unsigned 16bit type. Defining configUSE_16_BIT_TICKS as 0 causes TickType_t to be defined (typedef’ed) as an unsigned 32bit type.

Using a 16 bit type will greatly improve performance on 8 and 16 bit architectures, but limits the maximum specifiable time period to 65535 ‘ticks’. Therefore, assuming a tick frequency of 250Hz, the maximum time a task can delay or block when a 16bit counter is used is 262 seconds, compared to 17179869 seconds when using a 32bit counter.

时间是以“滴答”来衡量的——这是自RTOS内核启动以来滴答声中断执行的次数。滴答计数保存在TickType_t类型的变量中。


将configUSE_16_BIT_TICKS定义为1会将TickType_t定义为(typedef’ed)无符号16位类型。

将configUSE_16_BIT_TICKS定义为0会将TickType_t定义为(typedef’ed)无符号32位类型。


使用16位类型将大大提高8位和16位体系结构上的性能,但将最大指定时间段限制为65535个“滴答”。因此,假设滴答频率为250Hz,当使用16位计数器时,任务可以延迟或阻止的最长时间为262秒,而使用32位计数器时为17179869秒。

configUSE_PREEMPTION

Set to 1 to use the preemptive RTOS scheduler, or 0 to use the cooperative RTOS scheduler.

设置为1以使用抢占式RTOS调度程序,或设置为0以使用协作式RTOS调度程序。

configUSE_TIME_SLICING

By default (if configUSE_TIME_SLICING is not defined, or if configUSE_TIME_SLICING is defined as 1) FreeRTOS uses prioritised preemptive scheduling with time slicing. That means the RTOS scheduler will always run the highest priority task that is in the Ready state, and will switch between tasks of equal priority on every RTOS tick interrupt. If configUSE_TIME_SLICING is set to 0 then the RTOS scheduler will still run the highest priority task that is in the Ready state, but will not switch between tasks of equal priority just because a tick interrupt has occurred.

默认情况下(如果未定义configUSE_TIME_SLICING,或者如果configUSE_TIME_SLICING定义为1),FreeRTOS使用优先抢占式时间切片调度。这意味着RTOS调度程序将始终运行处于就绪状态的最高优先级任务,并在每个RTOS时钟中断时在同等优先级的任务之间切换。如果configUSE_TIME_SLICING设置为0,则RTOS调度程序仍将运行处于就绪状态的最高优先级任务,但不会仅因为发生了勾号中断而在同等优先级的任务之间切换。

configIDLE_SHOULD_YIELD

This parameter controls the behaviour of tasks at the idle priority. It only has an effect if:

The preemptive scheduler is being used.

The application creates tasks that run at the idle priority.

此参数控制空闲优先级下任务的行为。它只有在以下情况下才有效:

正在使用抢占式调度程序。

应用程序创建以空闲优先级运行的任务。

configUSE_CO_ROUTINES

Set 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.

设置为1可在生成中包含协同例程功能,设置为0可在生成中忽略协同例程功能。包括croutine.c必须包含在项目中。

configMAX_CO_ROUTINE_PRIORITIES

The number of

priorities

available to the application co-routines. Any number of co-routines can share the same priority. Tasks are prioritised separately – see configMAX_PRIORITIES.

应用程序协同例程可用的优先级数。任意数量的共同例程可以共享相同的优先级。任务的优先级是分开的-请参阅configMAX_PRIORITIES。

configKERNEL_INTERRUPT_PRIORITY

configMAX_SYSCALL_INTERRUPT_PRIORITY

configLIBRARY_KERNEL_INTERRUPT_PRIORITY



这一部分等分析中断优先级部分时候再分析吧

Ports that contain a configKERNEL_INTERRUPT_PRIORITY setting include ARM Cortex-M3, PIC24, dsPIC, PIC32, SuperH and RX600. Ports that contain a configMAX_SYSCALL_INTERRUPT_PRIORITY setting include PIC32, RX600, ARM Cortex-A and ARM Cortex-M

包含configKERNEL_中断_优先级设置的端口包括ARM Cortex-M3、PIC24、dsPIC、PIC32、SuperH和RX600。包含configMAX_SYSCALL_INTERRUPT_优先级设置的端口包括PIC32、RX600、ARM Cortex-a和ARM Cortex-M端口。



版权声明:本文为qq_41650023原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。