野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 46373|回复: 184

[freertos] FreeRTOSConfig.h 配置头文件详细注解,另加配套STM32的FreeRTOS工程模版。

  [复制链接]
发表于 2016-11-18 10:30:12 | 显示全部楼层 |阅读模式
1.jpg

FreeRTOSConfig.h (10.61 KB, 下载次数: 169)
2-移植 FreeRTOS 到 STM32F103.zip (1.05 MB, 下载次数: 266)


回复

使用道具 举报

 楼主| 发表于 2016-11-18 10:31:16 | 显示全部楼层


  1. /*
  2.     FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
  3.     All rights reserved

  4.     VISIT [url]http://www.FreeRTOS.org[/url] TO ENSURE YOU ARE USING THE LATEST VERSION.

  5.     This file is part of the FreeRTOS distribution.

  6.     FreeRTOS is free software; you can redistribute it and/or modify it under
  7.     the terms of the GNU General Public License (version 2) as published by the
  8.     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.

  9.     ***************************************************************************
  10.     >>!   NOTE: The modification to the GPL is included to allow you to     !<<
  11.     >>!   distribute a combined work that includes FreeRTOS without being   !<<
  12.     >>!   obliged to provide the source code for proprietary components     !<<
  13.     >>!   outside of the FreeRTOS kernel.                                   !<<
  14.     ***************************************************************************

  15.     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
  16.     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17.     FOR A PARTICULAR PURPOSE.  Full license text is available on the following
  18.     link: [url]http://www.freertos.org/a00114.html[/url]

  19.     ***************************************************************************
  20.      *                                                                       *
  21.      *    FreeRTOS provides completely free yet professionally developed,    *
  22.      *    robust, strictly quality controlled, supported, and cross          *
  23.      *    platform software that is more than just the market leader, it     *
  24.      *    is the industry's de facto standard.                               *
  25.      *                                                                       *
  26.      *    Help yourself get started quickly while simultaneously helping     *
  27.      *    to support the FreeRTOS project by purchasing a FreeRTOS           *
  28.      *    tutorial book, reference manual, or both:                          *
  29.      *    [url]http://www.FreeRTOS.org/Documentation[/url]                              *
  30.      *                                                                       *
  31.     ***************************************************************************

  32.     [url]http://www.FreeRTOS.org/FAQHelp.html[/url] - Having a problem?  Start by reading
  33.     the FAQ page "My application does not run, what could be wrong?".  Have you
  34.     defined configASSERT()?

  35.     [url]http://www.FreeRTOS.org/support[/url] - In return for receiving this top quality
  36.     embedded software for free we request you assist our global community by
  37.     participating in the support forum.

  38.     [url]http://www.FreeRTOS.org/training[/url] - Investing in training allows your team to
  39.     be as productive as possible as early as possible.  Now you can receive
  40.     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
  41.     Ltd, and the world's leading authority on the world's leading RTOS.

  42.     [url]http://www.FreeRTOS.org/plus[/url] - A selection of FreeRTOS ecosystem products,
  43.     including FreeRTOS+Trace - an indispensable productivity tool, a DOS
  44.     compatible FAT file system, and our tiny thread aware UDP/IP stack.

  45.     [url]http://www.FreeRTOS.org/labs[/url] - Where new FreeRTOS products go to incubate.
  46.     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.

  47.     [url]http://www.OpenRTOS.com[/url] - Real Time Engineers ltd. license FreeRTOS to High
  48.     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
  49.     licenses offer ticketed support, indemnification and commercial middleware.

  50.     [url]http://www.SafeRTOS.com[/url] - High Integrity Systems also provide a safety
  51.     engineered and independently SIL3 certified version for use in safety and
  52.     mission critical applications that require provable dependability.

  53.     1 tab == 4 spaces!
  54. */

  55. /*
  56. *=================================== 中文注解 =======================================
  57. *
  58. * 作者:野火 Fire
  59. * 论坛:[url]www.firebbs.cn[/url]
  60. * 淘宝:[url]www.fire-stm32.taobao.com[/url]
  61. *
  62. * FreeRTOSConfig.h这个头文件用来配置FreeRTOS的功能,但是并不全面,剩下的其他功能可以
  63. * 在FreeRTOS.h这个头文件配置,比如使能互斥信号量,使能递归信号量,使能事件标志组这些
  64. * 内核对象的功能时,是在FreeRTOS.h这个头文件里面配置的。即要想完全使用FreeRTOS的功能
  65. * 需要这两个头文件一起联合使用。
  66. *====================================================================================
  67. */

  68. #ifndef FREERTOS_CONFIG_H
  69. #define FREERTOS_CONFIG_H

  70. /*-----------------------------------------------------------
  71. * Application specific definitions.
  72. *
  73. * These definitions should be adjusted for your particular hardware and
  74. * application requirements.
  75. *
  76. * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
  77. * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
  78. *
  79. * See [url]http://www.freertos.org/a00110.html.[/url]
  80. *----------------------------------------------------------*/

  81. #define configUSE_PREEMPTION                1                               /* 使能抢占式调度,否则用合作式调度,默认我们都是用抢占式 */
  82. #define configUSE_IDLE_HOOK                        0                               /* 空闲任务钩子函数 */
  83. #define configUSE_TICK_HOOK                        0                               /* 时基任务钩子函数 */
  84. #define configCPU_CLOCK_HZ                        ( ( unsigned long ) 72000000 )        /* 系统时钟,单位为HZ */
  85. #define configTICK_RATE_HZ                        ( ( TickType_t ) 1000 )         /* SysTick中断周期,单位为HZ,1000HZ即1ms中断一次 */
  86. #define configMAX_PRIORITIES                ( 5 )                           /* 任务能使用最大优先级个数,数字越大优先级越高,范围为:0~configMAX_PRIORITIES-1
  87.                                                                    最低的0由系统分配给空闲任务,每个任务的优先级可以相同 */
  88. #define configMINIMAL_STACK_SIZE        ( ( unsigned short ) 128 )
  89. #define configTOTAL_HEAP_SIZE                ( ( size_t ) ( 17 * 1024 ) )    /* 堆空间大小,内核在创建各种对象时需要用到,单位为字,即4个字节 */
  90. #define configMAX_TASK_NAME_LEN                ( 16 )                        /* 任务名称的长度,即字符串的长度 */
  91. #define configUSE_TRACE_FACILITY        0
  92. #define configUSE_16_BIT_TICKS                0                             /* SysTick Counter的宽度,0表示32bit,1表示16bit,STM32用的是32bit */
  93. #define configIDLE_SHOULD_YIELD                1                             /* 上下文切换强制使能,即当前任务执行完毕之后还有剩余的时间片,可以强制自己放弃
  94.                                                                    剩余的时间片,然后执行上下文切换去执行其他的任务*/

  95. /* Co-routine definitions. */
  96. #define configUSE_CO_ROUTINES                 0                             /* 合作式调度配置 */
  97. #define configMAX_CO_ROUTINE_PRIORITIES ( 2 )

  98. /* Set the following definitions to 1 to include the API function, or zero
  99. to exclude the API function. */

  100. #define INCLUDE_vTaskPrioritySet                1
  101. #define INCLUDE_uxTaskPriorityGet                1
  102. #define INCLUDE_vTaskDelete                                1
  103. #define INCLUDE_vTaskCleanUpResources        0
  104. #define INCLUDE_vTaskSuspend                        1
  105. #define INCLUDE_vTaskDelayUntil                        1
  106. #define INCLUDE_vTaskDelay                                1

  107. /*=========================================== SysTick 和 PendSV 的中断优先级配置 ======================================*/
  108. /* This is the raw value as per the Cortex-M3 NVIC.  Values can be 255
  109. (lowest) to 0 (1?) (highest). */
  110. /*
  111. * 当把配置好的优先级写到寄存器的时候是按照这个公式来写的:((priority << (8 - __NVIC_PRIO_BITS)) & 0xff) = 255 => priority = 15
  112. * 因为在Cortex-M 系列中是用8位来表示优先级,操作的时候以8bit来写的,但是ST的处理器只用了其中的高四位,即__NVIC_PRIO_BITS=4。
  113. *
  114. * configKERNEL_INTERRUPT_PRIORITY 宏用来配置 SysTick 和 PendSV 的中断优先级,这里配置为 15,即无论中断优先级如何分钟,都是最低。
  115. *
  116. * 当 SysTick 和 PendSV 的中断优先级 配置为最低的时候,可以提供系统的实时性,即外部中断可以随时响应。
  117. */
  118. #define configKERNEL_INTERRUPT_PRIORITY                 255         
  119. /* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
  120. See [url]http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html.[/url] */

  121. /*===========================================可屏蔽的中断优先级配置====================================================*/
  122. /*
  123. * 用于配置STM32的特殊寄存器basepri寄存器的值,用于屏蔽中断,当大于basepri值的
  124. * 优先级的中断将被全部屏蔽。basepri只有4bit有效,默认只为0,即全部中断都没有被屏蔽。
  125. * 这里191对应的二进制为(1011 1111)b只有高四位有效,即(1011)b=11,意思就是中断优先级大于11的中断都被屏蔽
  126. *
  127. * 在FreeRTOS中,关中断是通过配置basepri寄存器来实现的,关掉的中断由配置的basepri的值决定,小于basepri值的
  128. * 中断FreeRTOS是关不掉的,这样做的好处是可以系统设计者可以人为的控制哪些非常重要的中断不能被关闭,在紧要的关头必须被响应。
  129. * 而在UCOS中,关中断是通过控制PRIMASK来实现的,PRIMASK是一个单1的二进制位,写1则除能除了NMI和硬 fault的所有中断。当os关闭
  130. * 中断之后,即使是你在系统中设计的非常紧急的中断来了都不能马上响应,这加大了中断延迟的时间,如果是性命攸关的场合,那后果估计挺严重。
  131. *
  132. * 当把配置好的优先级写到寄存器的时候是按照这个公式来写的:((priority << (8 - __NVIC_PRIO_BITS)) & 0xff) = 191 => priority = 11
  133. */
  134. #define configMAX_SYSCALL_INTERRUPT_PRIORITY         191 /* equivalent to 0xb0, or priority 11. */


  135. /* This is the value being used as per the ST library which permits 16
  136. priority values, 0 to 15.  This must correspond to the
  137. configKERNEL_INTERRUPT_PRIORITY setting.  Here 15 corresponds to the lowest
  138. NVIC value of 255. */
  139. /*
  140. * configLIBRARY_KERNEL_INTERRUPT_PRIORITY 宏就是 这个公式:((priority << (8 - __NVIC_PRIO_BITS)) & 0xff)里面的priority
  141. * 即实际用来配置STM32的中断优先级,但是要写到8位的中断优先级的寄存器里面,还是需要用上面的公式先转化下。通过计算之后就
  142. * 是上面configKERNEL_INTERRUPT_PRIORITY这个宏的值,用于配置SysTick和PendSV 的中断优先级。
  143. */
  144. #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY        15       // 0x0f


  145. /*=================================== SVC,PendSV 和 SysTick 中断服务函数的配置 ========================================*/
  146. /*
  147. * 在移植FreeRTOS的时候,需要用到STM32的三个中断,分别是SVC,PendSV和SysTick,这三个中断在向量表
  148. * 里面的名字分别是:SVC_Handler,PendSV_Handler和SysTick_Handler(在启动文件:startup_stm32f10x_hd.s中)
  149. *
  150. * 而在port.c里面写的这三个中断的服务函数的名称跟向量表里面的名称不一样,为了中断响应之后能正确的执行port.c
  151. * 里面写好的中断服务函数,我们需要统一向量表和中断服务函数的名字。
  152. *
  153. * 为了实现这个目的,可以有两种方法:
  154. * 1:把启动文件里面的向量表里面的名字改成跟port.c里面的中断服务函数名一样。
  155. * 2:把port.c里面的中断服务函数名改成跟启动文件里面的中断向量表里面的名字一样。
  156. *
  157. * 这里为了保持启动文件的完整性,我们统一修改port.c里面的中断函数名,即添加下面三个宏定义即可。
  158. * 如果你在stm32f10x_it.c这里面实现了这三个中断服务函数的定义的话,那么为了避免跟port.c里面的重复定义,应该
  159. * 把stm32f10x_it.c里面的注释掉。
  160. */

  161. #define xPortPendSVHandler   PendSV_Handler
  162. #define xPortSysTickHandler  SysTick_Handler
  163. #define vPortSVCHandler      SVC_Handler

  164. #endif /* FREERTOS_CONFIG_H */



复制代码

回复 支持 反对

使用道具 举报

发表于 2016-11-18 10:34:39 | 显示全部楼层
66666666666666666666666
回复 支持 反对

使用道具 举报

发表于 2016-11-18 10:41:09 | 显示全部楼层
666666,FREERTOS教程要来了嘛
回复 支持 反对

使用道具 举报

发表于 2016-11-18 10:41:25 | 显示全部楼层
6666666666666666666666666666666666666666
回复 支持 反对

使用道具 举报

发表于 2016-11-18 10:42:58 | 显示全部楼层
好东西啊
回复

使用道具 举报

发表于 2016-11-18 11:24:51 | 显示全部楼层
正在学习FreeRTOS,学习一下
回复 支持 反对

使用道具 举报

发表于 2016-11-18 14:34:42 | 显示全部楼层
好东西呀,,收了
回复 支持 反对

使用道具 举报

发表于 2016-11-21 17:00:07 | 显示全部楼层
学习火哥,支持火哥
回复 支持 反对

使用道具 举报

发表于 2016-11-23 19:01:16 | 显示全部楼层
学习学习······
回复 支持 反对

使用道具 举报

发表于 2016-11-23 20:10:15 | 显示全部楼层
这么好的东西,收下了
回复 支持 反对

使用道具 举报

发表于 2016-11-25 16:32:16 | 显示全部楼层
正在学习,先下资料
回复 支持 反对

使用道具 举报

发表于 2016-11-26 13:10:51 | 显示全部楼层
正在用,学习下
回复 支持 反对

使用道具 举报

发表于 2016-12-25 19:53:43 | 显示全部楼层
       学习学习
回复 支持 反对

使用道具 举报

发表于 2016-12-30 19:46:59 | 显示全部楼层
最近在 学FreeRTOS,看看
回复 支持 反对

使用道具 举报

发表于 2017-1-2 11:10:03 | 显示全部楼层
多谢,看一下了
回复 支持 反对

使用道具 举报

发表于 2017-1-4 15:49:59 | 显示全部楼层
研究研究,有视频没啊?
回复 支持 反对

使用道具 举报

发表于 2017-1-11 16:02:51 | 显示全部楼层
学习学习学习。。。。。。。。。。
回复 支持 反对

使用道具 举报

发表于 2017-1-16 00:15:31 | 显示全部楼层
学习学习学习。。。。。。。。。。
回复 支持 反对

使用道具 举报

发表于 2017-1-16 09:37:21 | 显示全部楼层
谢谢分享!!
回复

使用道具 举报

发表于 2017-1-27 07:53:17 | 显示全部楼层
这个需要学习学习
回复 支持 反对

使用道具 举报

发表于 2017-2-4 14:29:17 | 显示全部楼层
fdxgjfyipho[h
回复 支持 反对

使用道具 举报

发表于 2017-2-4 17:01:48 | 显示全部楼层
FreeRTOS好东西,学习中,正需要
回复 支持 反对

使用道具 举报

发表于 2017-2-6 21:55:30 | 显示全部楼层
haodongxikankan
回复 支持 反对

使用道具 举报

发表于 2017-2-7 20:11:01 | 显示全部楼层
学习一下!
回复

使用道具 举报

发表于 2017-2-20 08:20:40 | 显示全部楼层
不错,学习了
回复 支持 反对

使用道具 举报

发表于 2017-3-3 09:40:10 | 显示全部楼层
学习以下。
回复

使用道具 举报

发表于 2017-3-3 12:03:41 | 显示全部楼层
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
回复

使用道具 举报

发表于 2017-3-9 20:15:12 | 显示全部楼层
详细注解,另加配套STM32的FreeRTOS工程模
回复 支持 反对

使用道具 举报

发表于 2017-3-14 18:05:36 | 显示全部楼层
学习学习学习学习学习
回复 支持 反对

使用道具 举报

发表于 2017-3-14 18:32:07 | 显示全部楼层
FreeRTOSConfig.h 配置头文件详细注解,另加配套STM32的FreeRTOS工程模版
回复 支持 反对

使用道具 举报

发表于 2017-3-20 18:55:42 | 显示全部楼层
学习来了,FreeRTOS
回复 支持 反对

使用道具 举报

发表于 2017-3-20 21:29:46 | 显示全部楼层
瞧一瞧看一看
回复 支持 反对

使用道具 举报

发表于 2017-3-21 14:03:50 | 显示全部楼层
支持火哥!!!!!!!!!!!!!
回复

使用道具 举报

发表于 2017-4-4 13:26:55 | 显示全部楼层
教程快出来了吧
回复 支持 反对

使用道具 举报

发表于 2017-4-20 12:23:25 | 显示全部楼层
要做一个stm32上的FreeRTOS的移植学习学习配置文件
回复 支持 反对

使用道具 举报

发表于 2017-4-20 17:46:35 | 显示全部楼层
我只想看个全文
回复 支持 反对

使用道具 举报

发表于 2017-4-24 10:04:55 | 显示全部楼层
看完配置就学会了一半啊!
回复 支持 反对

使用道具 举报

发表于 2017-4-28 09:23:25 | 显示全部楼层
很好很好很好很好很好
回复 支持 反对

使用道具 举报

发表于 2017-5-5 15:01:06 | 显示全部楼层
最近正在了解
回复 支持 反对

使用道具 举报

发表于 2017-5-6 10:53:42 | 显示全部楼层
FreeRTOSConfig.h 配置头文件详细注解,另加配套STM32的FreeRTOS工程模版
回复 支持 反对

使用道具 举报

发表于 2017-5-6 17:10:16 | 显示全部楼层
学习中,正需要
回复 支持 反对

使用道具 举报

发表于 2017-5-9 12:58:03 | 显示全部楼层
参考火哥的工程移植了一份freertos,开始深入学习
回复 支持 反对

使用道具 举报

发表于 2017-5-9 16:41:00 | 显示全部楼层
666666666666666666666666666666
回复 支持 反对

使用道具 举报

发表于 2017-5-15 11:38:04 | 显示全部楼层
dddddddddddddddddd
回复 支持 反对

使用道具 举报

发表于 2017-5-22 11:02:45 | 显示全部楼层
6666666666666666666666
回复 支持 反对

使用道具 举报

发表于 2017-6-5 16:25:02 | 显示全部楼层
666666666666
回复 支持 反对

使用道具 举报

发表于 2017-6-9 22:32:50 | 显示全部楼层
火哥,学习一下。
回复 支持 反对

使用道具 举报

发表于 2017-6-10 08:55:57 | 显示全部楼层
学习,学习,学习
回复 支持 反对

使用道具 举报

发表于 2017-6-10 14:00:34 | 显示全部楼层
学习学习,谢火哥分享
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-4-28 04:31 , Processed in 0.094326 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表