FreeRTOS学习记录第七天

FreeRTOSConfig.h文件配置文件中文注释:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
#include <stdint.h>
#include "main.h"
extern uint32_t SystemCoreClock;
extern volatile uint32_t ulHighFrequencyTimerTicks;
#endif

/*configUSE_PREEMPTION配置为1使能抢占式调度器;配置为0使能合作式调度器*/
#define configUSE_PREEMPTION 1
#define configSUPPORT_STATIC_ALLOCATION 0
#define configSUPPORT_DYNAMIC_ALLOCATION 1
/*当configUSE_IDLE_HOOK定义为1时,空闲任务钩子函数才会被调用*/
#define configUSE_IDLE_HOOK 0
/*配置为1使能滴答定时器中断里面执行的钩子函数;配置为0禁能嘀嗒定时器中断里面执行的钩子函数*/
#define configUSE_TICK_HOOK 0
/*configUSE_TICKLESS_IDLE配置为1使能tickless低功耗模式,为0禁能tickless低功耗模式*/
#define configUSE_TICKLESS_IDLE 0
/*定义CPU的主频*/
#define configCPU_CLOCK_HZ ( SystemCoreClock )
/*心跳中断频率为1000HZ也就是时间片长度1ms*/
#define configTICK_RATE_HZ ((TickType_t)1000)
/*用户可以使用的最大优先级数,定义为7,可用的优先级为0,1,2,3,4,5,6*/
#define configMAX_PRIORITIES ( 7 )
/*用于定义空闲任务的栈空间大小,单位是字,即4字节*/
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
/*定义堆大小,FreeRTOS 内核,用户动态内存申请,任务栈,任务创建,信号量创建,消息队列创建
等都需要用这个空间*/
#define configTOTAL_HEAP_SIZE ((size_t)( 30 * 1024 ) )
/*定义任务名最大的字符数,末尾的结束符 '\0'也要计算在内*/
#define configMAX_TASK_NAME_LEN ( 16 )
/*系统时钟节拍计数使用 TickType_t 数据类型定义的*/
#define configUSE_16_BIT_TICKS 0
/*配置为1使能互斥信号量,配置0禁能互斥信号量*/
#define configUSE_MUTEXES 1
/*通过此定义来设置可以注册的信号量和消息队列个数*/
#define configQUEUE_REGISTRY_SIZE 8
/*配置为1专用方式进行优化;配置为0通用方式没有优化*/
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
/*使能与空闲任务同优先级的任务*/
#define configIDLE_SHOULD_YIELD 1
/*配置为 1使能此配置将添加额外的结构体成员和函数,以此来协助可视化和跟踪,在使用 IAR 中的 FreeRTOS
插件时要使能这个配置,否则无法显示任务栈的使用情况;配置为0则禁用这个特性*/
#define configUSE_TRACE_FACILITY 1
/*设置宏configGENERATE_RUN_TIME_STATS为1使能运行时间统计功能*/
#define configGENERATE_RUN_TIME_STATS 1
/*用户配置宏定义 configUSE_TRACE_FACILITY 和 configUSE_STATS_FORMATTING_FUNCTIONS
都为 1 的时候,将使能函数 vTaskList() 和 vTaskGetRunTimeStats(),如果两者中任何一个为 0,那么
这两个函数都将被禁能*/
#define configUSE_STATS_FORMATTING_FUNCTIONS 1

/* Co-routine definitions. */
/*配置为1使能合作式调度相关函数;配置为0禁能合作式调度相关函数*/
#define configUSE_CO_ROUTINES 0
/*此参数用于定义可供用户使用的最大的合作式任务优先级数,如果这个定义的是 5,那么用户可以使
用的优先级号是 0,1,2,3,4,不包含 5,对于这一点,初学者要特别的注意*/
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
/*将这个设置为1,阻塞等待将没有超时限制*/
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1

/* 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
#endif

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15

/* 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 1

/* 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) )

/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
/* 使用断言功能*/
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );}

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names. */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler

/* IMPORTANT: This define MUST be commented when used with STM32Cube firmware,
to prevent overwriting SysTick_Handler defined within STM32Cube HAL */
/* #define xPortSysTickHandler SysTick_Handler */

/*如果运行时间统计,下面两个函数必须定义*/
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() (ulHighFrequencyTimerTicks = 0ul)
#define portGET_RUN_TIME_COUNTER_VALUE() ulHighFrequencyTimerTicks

#endif

注:这里面的大多数配置在FreeRTOS中都有默认配置,如果需要改变就在这里面改变。