开发环境
硬件环境:STM32F103C8T6
软件环境:STM32CubeIDE1.4.0
前置条件
- 准备一个工程
- 下载FreeRTOS的源码
FreeRTOS移植
1.移植FreeRTOS源码- 在工程文件中新建文件夹 —— FreeRTOS(存储FreeRTOS源码)
*打开 FreeRTOS 源码文件夹, 将其中的include文件夹复制到刚刚新建的FreeRTOS文件夹中。
- 然后include同目录下新建一个文件夹——portable
- 进入portable文件夹,在FreeRTOS源码文件夹的FreeRTOSv202012.00\FreeRTOS\Source\portable\GCC\ARM_CM3的路径下,将port.c和portmacro.h文件复制到刚刚新建的protable文件夹中,并将FreeRTOSv202012.00\FreeRTOS\Source\portable\MemMang路径下的heap_4.h也复制到protable文件夹中,此时文件夹中存在以下三个文件。
- 再次打开FreeRTOS源码文件夹,在FreeRTOSv202012.00\FreeRTOS\Source路径下,将所有的.c文件复制到工程的FreeRTOS文件夹中。
- 拷贝FreeRTOSConfig.h文件到src文件夹中
- 打开FreeRTOS源码文件夹,在FreeRTOSv202012.00\FreeRTOS\Demo\CORTEX_STM32F103_Primer_GCC路径下,将FreeRTOSConfig.h文件拷贝到工程的src文件夹下。
3.配置FreeRTOS源码到工程文件中
右键点击工程名——点击Properties进入配置页——点击Paths and Symbols选项——添加Includes路径
选择Source Location添加源文件路径
4.修改FreeRTOSConfig.h文件
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http