实验作业之FreeRTOS实操

实验作业之FreeRTOS实操

    • 1.FreeRTOS 移植
    • 2 多任务的编程

1.FreeRTOS 移植

本次实验,我将使用AHT20数据采集电路以及FreeRTOS的实操

首先,在网上寻找FreeRTOS的实例程序

在这里插入图片描述
点击其PROJECT文件,随后用MDK打开其实例代码
实验作业之FreeRTOS实操_第1张图片
进入代码后点击运行,系统未报错
实验作业之FreeRTOS实操_第2张图片
然后,依次点击下载的FreeRTOS9.0.0–>FreeRTOS–>Source,复制其中的include函数。
实验作业之FreeRTOS实操_第3张图片
新建一个文件夹放置include函数,然后新建一个port文件夹和一个src文件夹。
在这里插入图片描述

点击FreeRTOSv9.0.0–>FreeRTOS–>Source–>portable路径下,把MemMang,RVDS 文件夹复制到刚刚新建的 port 文件夹中。

实验作业之FreeRTOS实操_第4张图片

点击FreeRTOSv9.0.0–>FreeRTOS–>Source路径下,将 .c 文件复制到新建的 src 文件夹中。
实验作业之FreeRTOS实操_第5张图片
点击FreeRTOSv9.0.0–>FreeRTOS–>Demo–>CORTEX_STM32F103_Keil路径下,把FreeRTOSConfig.h复制到工程的 user 文件夹中。
实验作业之FreeRTOS实操_第6张图片
实验作业之FreeRTOS实操_第7张图片
添加对应的port和src文件夹
实验作业之FreeRTOS实操_第8张图片
将port与src的文件全部添加完毕

heap_4.c 文件(FreeRTOS工程\FreeRTOS\port\MemMang)
FreeRTOS 端口源程序:(FreeRTOS工程\FreeRTOS\port\RVDS\ARM_CM3)

实验作业之FreeRTOS实操_第9张图片
最终的文件夹大概是这样子
实验作业之FreeRTOS实操_第10张图片
点击魔术棒,进入C/C++,点击下面的三个点,进入添加新的地址。
实验作业之FreeRTOS实操_第11张图片
点击build,编译没有错误,不需要修改.实验作业之FreeRTOS实操_第12张图片
截取下面代码,代替掉 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://www.FreeRTOS.org/training - Investing in training allows your team to
    be as productive as possible as early as possible.  Now you can receive
    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
    Ltd, and the world's leading authority on the world's leading RTOS.

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

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

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

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

*/


#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

#include "stm32f10x.h"
#include "bsp_usart.h"


//针对不同的编译器调用不同的stdint.h文件
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
    #include 
    extern uint32_t SystemCoreClock;
#endif

//断言
#define vAssertCalled(char,int) printf("Error:%s,%d\r\n",char,int)
#define configASSERT(x) if((x)==0) vAssertCalled(__FILE__,__LINE__)

/************************************************************************
 *               FreeRTOS基础配置配置选项 
 *********************************************************************/
/* 置1:RTOS使用抢占式调度器;置0:RTOS使用协作式调度器(

你可能感兴趣的:(嵌入式)