1.FreeRTOS的简介&移植FreeRTOS到STM32平台
来源:互联网 发布:怎么看淘宝关注的人 编辑:程序博客网 时间:2024/05/16 19:02
I.说明
作者:WXP(翱翔云端的鸟)
联系方式:328452854@qq.com || 13100610853(联系请注明CSDN)
申明:个人原创,转载请先经过本人同意!
要说的话:个人水平有限,不足之处,还请指正!有疑问欢迎大家联系我交流探讨!
=============================================================================================================================
=============================================================================================================================
II.环境
软件环境:KEIL-MDK v-5.24a
硬件:STM32F103ZET6最小系统板
=============================================================================================================================
=============================================================================================================================
III.FreeRTOS简介
FreeRTOS作为一个RTOS(Real Time Operating System),Free,即免费。公司或者个人在自己的产品中使用了FreeRTOS而不必为各种授权问题而苦恼! 这也是相对其它嵌入式RTOS的优势。其次它十分精简短小,占用很小的空间(4-9K字节大小),同时它支持很多平台,官方的文档也相对比较齐全,上手比较容易,所以比较适合初次接触RTOS的工程师。
FreeRTOS的具体特点如下
1.免商业许可,可以在具体产品中免费试用FreeRTOS
2.支持众多半导体厂家的平台,应用范围广,资料齐全
3.相比较于其它OS,代码更精简,移植更容易
4.提供了一个用于低功耗的Tickless模式
5.任务数量不受限制
6.内部有软件定时器和堆栈检测功能
7.内核对象齐全,在任务同步通信中使用起来很方便
=============================================================================================================================
=============================================================================================================================
IV.移植FreeRTOS到STM32F103平台
1.准备FreeRTOS源码和一个裸机STM32-Demo程序(STM32F103ZET6),FreeRTOS源码可以在官网www.freertos.org下载,同时上面也可以下载到很多文档。
这里我给出我的百度云下载地址(FreeRTOS源码和STM32裸机Demo):http://pan.baidu.com/s/1nvuTOPN
2.查看FreeRTOS源码目录,分为Demo、License、Source 3个目录
Demo目录下存放的是FreeRTOS的相关历程 如下图:
#ifndef __INCLUDES_H__#define __INCLUDES_H__/************************************************************************************STD************************************************************************************/#include <stdarg.h>#include <stdio.h>#include <stdlib.h>#include <math.h>#include "stm32f10x.h"/*************************************************************************************OS*************************************************************************************/#include "FreeRTOS.h"#include "task.h"#include "queue.h"#include "croutine.h"/*************************************************************************************MACRO DEFINE*************************************************************************************//*************************************************************************************APP/BSP*************************************************************************************/#include "bsp.h"#endif
/* 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. 1 tab == 4 spaces!*/#ifndef FREERTOS_CONFIG_H#define FREERTOS_CONFIG_H/*----------------------------------------------------------- * 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. *----------------------------------------------------------*///抢占式调度使能1--ENABLE 0--DISABLE#define configUSE_PREEMPTION1//#define configUSE_IDLE_HOOK0#define configUSE_TICK_HOOK0#define configCPU_CLOCK_HZ( ( unsigned long ) 72000000 )#define configTICK_RATE_HZ( ( TickType_t ) 1000 )#define configMAX_PRIORITIES( 5 )#define configMINIMAL_STACK_SIZE( ( unsigned short ) 128 )#define configTOTAL_HEAP_SIZE( ( size_t ) ( 17 * 1024 ) )#define configMAX_TASK_NAME_LEN( 16 )#define configUSE_TRACE_FACILITY0#define configUSE_16_BIT_TICKS0#define configIDLE_SHOULD_YIELD1/* Co-routine definitions. */#define configUSE_CO_ROUTINES 0#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )/* Set the following definitions to 1 to include the API function, or zeroto exclude the API function. */#define INCLUDE_vTaskPrioritySet1#define INCLUDE_uxTaskPriorityGet1#define INCLUDE_vTaskDelete1#define INCLUDE_vTaskCleanUpResources0#define INCLUDE_vTaskSuspend1#define INCLUDE_vTaskDelayUntil1#define INCLUDE_vTaskDelay1#ifdef __NVIC_PRIO_BITS#define configPRIO_BITS__NVIC_PRIO_BITS#else#define configPRIO_BITS4#endif/* This is the value being used as per the ST library which permits 16priority values, 0 to 15. This must correspond to theconfigKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowestNVIC value of 255. */#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY0x0F#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY0x0F#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY0x01/* Interrupt priorities used by the kernel port layer itself. These are genericto 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.hheader file. */#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }/* Definitions that map the FreeRTOS port interrupt handlers to their CMSISstandard names. */#define vPortSVCHandler SVC_Handler#define xPortPendSVHandler PendSV_Handler#define xPortSysTickHandler SysTick_Handler#endif /* FREERTOS_CONFIG_H */
main.c
/******************************************************************************* File : main.c* Function : 主文件* Description: None * Version : V1.00* Author : WXP* Date : * History : ******************************************************************************/#include "includes.h"/******************************************************************************函数声明******************************************************************************/static void vTask_LED2(void *pvParameters);static void vTask_LED3(void *pvParameters);static TaskHandle_t xHandleTask_LED2 = NULL;static TaskHandle_t xHandleTask_LED3 = NULL;static void AppTaskCreate(void){xTaskCreate( vTask_LED2,"LED2",512,NULL,1,&xHandleTask_LED2);xTaskCreate( vTask_LED3,"LED3",512,NULL,2,&xHandleTask_LED3);}int main(void){Bsp_Init();AppTaskCreate();vTaskStartScheduler();while(1);} static void vTask_LED2(void *pvParameters){while(1){LED2(ON);vTaskDelay(100);LED2(OFF);vTaskDelay(100);}}static void vTask_LED3(void *pvParameters){while(1){LED3(ON);vTaskDelay(300);LED3(OFF);vTaskDelay(300);}}
12.FreeRTOSConfig.h中的内容将在以后讲解,main.c中就是添加了两个不同延时闪LED的任务,编译下载就可以看到两个灯以不同频率闪烁,由此FreeRTOS移植成功!
- 1.FreeRTOS的简介&移植FreeRTOS到STM32平台
- FreeRTOS移植到STM32
- STM32移植FreeRTOS的Tips
- FreeRTOS STM32移植笔记
- FreeRTOS STM32移植笔记
- FreeRTOS STM32移植笔记
- STM32 移植Freertos
- FreeRTOS STM32移植笔记
- STM32上移植FreeRTOS
- STM32上移植FreeRTOS
- FreeRTOS STM32移植笔记
- FreeRTOS STM32移植笔记
- freertos 移植到stm32f103
- 关于freertos移植到stm32出错,程序直接跳到HardFault_Handler的问题。
- FreeRTOS 在STM32上的移植 V1.0
- FreeRTOS 在STM32上的移植 V1.0
- FreeRtos移植到Arduino UNO
- FreeRTOS简单移植到STM32F103ZET6
- stm32控制舵机DS3115转动
- localStorage
- P1059 明明的随机数
- hdu2159 FATE(C语言)
- Arrays.sort()逻辑学习
- 1.FreeRTOS的简介&移植FreeRTOS到STM32平台
- jdbc 批处理
- spring学习-------简介
- 【剑指offer】面试题54:二叉搜索树的第k大节点
- CSS3 Transform变形理解与应用
- MQ 模型
- 【转】最流行的7个JavaScript框架特点
- 安卓语言适配
- Spring学习之路 第一个Spring演示实例