当前位置:网站首页>FreeRTOS overview and experience
FreeRTOS overview and experience
2022-06-24 11:34:00 【~Old】
1.1 FreeRTOS Directory structure
With Keil Under the tools STM32F103 Chip as an example , its FreeRTOS Directory as follows :

Mainly involves 2 A catalog :
- Demo
- Demo Under the directory is the project file , With “ Chips and compilers are combined into one name ”
- such as :CORTEX_STM32F103_Keil
- Source
- The root directory is the core file , These documents are FreeRTOS Source code , These files are generic
- portable Directories are files that need to be implemented during migration , Hardware interface layer ,FreeRTOS And the chip .
- The directory name is :[complier]/[architecture]
- such as :RVDS/ARM_CM3, This means cortexM3 Architecture in RVDS Migration files on tools
1.2 Core documents
FreeRTOS Strictly speaking, the most core document of is 2 individual :
- FreeRTOS/Source/task.c
- FreeRTOS/Source/list.c
Broad sense of queue.c It is often used , But it's not necessary , Some places also put queue.c This document is also considered necessary .
The functions of other documents are also listed as follows :
| FreeRTOS/Source The files under the | effect |
| tasks.c | It's necessary , Task operation |
| list.c | It's necessary , The list of operations |
| queue.c | Basically , Provides queue operations , Semaphore (semaphore) operation |
| timer.c | Optional ,software timer |
| event_groups.c | Optional , Provide event group function |
| croutine.c | Optional , coroutines ,FreeRTOS No more updates , Out of date |
1.3 Files involved in migration
transplant FreeRTOS The documents involved are placed in FreeRTOS/Source/portable/[complier]/[architecture] Under the table of contents ,
such as :RVDS/ARM_CM3, This means cortexM3 Architecture in RVDS or Keil Migration files on tools
There are 2 File :
- port.c
- portmacro.h
1.4 Header file related
1.4.1 Header Directory
FreeRTOS Three header directories are required :
- FreeRTOS Own header file :FreeRTOS/Source/include
- Header files used in migration ,FreeRTOS/Source/portable/[complier]/[architecture]
- With configuration file FreeRTOSConfig.h The catalog of
1.4.2 The header file
| The header file | effect |
| FreeRTO\quSConfig.h | FreeRTOS Configuration file for , For example, select a scheduling algorithm :configUSE_PREEMPTION Every demo Must contain FreeRTOSConfig.h It is suggested to modify demo Medium FreeRTOSConfig.h, Instead of writing from scratch , In fact, this file is provided for users to tailor FreeRTOS System , Defined as needed |
| FreeRTOS.h | Use FreeRTOS API Function time , This file must be included , stay FreeRTOS.h after , Then include other header files , such as :task.h、queue.h、semphr.h、event_group.h |
1.5 memory management
The file in FreeRTOS/Source/portable/MemMang Next , It is also placed in portable Under the table of contents , Means that you can provide your own functions .
The source code provides... By default 5 File , Corresponding to memory management 5 Methods .
| file | advantage | shortcoming |
| heap_1.c | Assignment Brief , Time is set | Allocate only, do not recycle |
| heap_2.c | Dynamic allocation , Best match | debris , Time is uncertain |
| heap_3.c | Call standard library functions | Slow speed , Time is uncertain |
| heap_4.c | Adjacent free memory can be merged | It can solve the problem of fragmentation , Time is uncertain |
| heap_5.c | stay heap_4 Support separate memory blocks based on | It can solve the problem of fragmentation , Time is uncertain |
1.6 Demo
Demo The directory is pre configured , No compilation errors in the project , The purpose is that you can modify based on it , To fit your board .
these Demo You can also continue to streamline , So that FreeRTOS It looks clean and refreshing .
1.7 Data types and programming specifications
Each migrated version contains its own portmacro.h The header file , It's defined in it 2 Data types :
- TickType_t:
- FreeRTOS A periodic clock interrupt is configured :Tick Interrupt
- Every time an interrupt occurs , The number of interrupts is accumulated , This is known as tick count
- tick count The type of this variable is Tick Type_t
- Tick Type_t It can be 16 Bit , It can also be 32 Bit
- FreeRTOSConfig.h In the definition of configUSE_16_BIT_TICKS when ,TickType_t Namely uint16_t
- otherwise TickType_t Namely uint32_t
- about 32 An architecture , Make a proposal to TickType_t Configure to uint32_t
- BaseType_t:
- This is the most efficient data type of the architecture
- 32 Bit architecture , It is uin32_t
- 16 Bit architecture , It is uint16_t
- 8 Bit architecture , It is uint8_t
- BaseType_t Usually used as a simple return value type , And logical values , such as pdTRUE/pdFALSE
1.7.2 Variable name
Variable names are prefixed
| Variable name prefix c | meaning |
| c | char |
| s | int16_t .short |
| l | int32_t,long |
| x | BaseType_t, Other non-standard types : Structure ,task handle、queue handle etc. |
| u | unsigned |
| p | The pointer |
| uc | uint8_t , unsigned char |
| pc | char The pointer |
1.7.3 Function name
The prefix of the function name is 2 part : return type , In which file do you define .
| Function name prefix | meaning |
| vTaskPrioritySet | return type :void stay task.c In the definition of |
| xQueueReceive | return type :BaseType_t stay queue.c In the definition of |
| pvTimerGetTimerID | return type :pointer to void stay timer.c In the definition of |
1.7.4 Macro name
The name of the macro is capitalized , You can add a lowercase prefix . Prefixes are used to denote : In which file are macros defined .
| Prefix of macro | meaning : Define... In that file |
| port( such as portMAX_DELAY) | portable.h or portmacro.h |
| task( such as taskENTER_CRITICAL()) | task.h |
| pd( such as pdTRUE) | projdefs.h |
| config( such as configUSE_PREEMPTION) | FreeRTOSConfig.h |
| err( such as errQUEUE_FULL) | projdefs.h |
The general macro definition is as follows :
| macro | value |
| pdTRUE | 1 |
| pdFALSE | 0 |
| pdPASS | 1 |
| pdFAIL | 1 |
边栏推荐
- Adobe Photoshop using the box selection tool for selection tutorial
- Nxshell session management supports import and export
- Jenkins remote publishing products
- 2008R2 precautions for configuring L2TP pre shared key VPN
- Group policy export import
- Fizz gateway secondary development integration tutorial
- [live review] battle code pioneer phase 7: how third-party application developers contribute to open source
- Reading at night -- about microservices and containers
- Group counting_ Structure and workflow of CPU
- Beauty of script │ VBS introduction interactive practice
猜你喜欢

Programmers spend most of their time not writing code, but...

《opencv学习笔记》-- 离散傅里叶变换

Shell脚本(.sh文件)如何执行完毕之后不自动关闭、闪退?
![[graduation season · attacking technology Er] three turns around the tree, what branch can we rely on?](/img/0a/0ebfa1e5c1bea6033b538528242252.png)
[graduation season · attacking technology Er] three turns around the tree, what branch can we rely on?

《opencv学习笔记》-- 分离颜色通道、多通道混合

齐次坐标的理解

Group counting_ Structure and workflow of CPU

GLOG从入门到入门

New progress in the construction of meituan's Flink based real-time data warehouse platform

我真傻,招了一堆只会“谷歌”的程序员!
随机推荐
电商红包雨是如何实现的?拿去面试用(典型高并发)
Anonymous Messenger: hidden communication of Trojan horse
Any 与 TypeVar,让 IDE 的自动补全更好用
2D 照片变身 3D 模型,来看英伟达的 AI 新“魔法”!
《opencv学习笔记》-- 离散傅里叶变换
Centripetalnet: more reasonable corner matching, improved cornernet | CVPR 2020 in many aspects
The record of 1300+ times of listing and the pursuit of ultimate happiness
集群控制管理
夜晚读书 -- 关于微服务和容器
【Go语言刷题篇】Go从0到入门4:切片的高级用法、初级复习与Map入门学习
Google ranging for PHP wechat development
Attribute observer didset and willset in swift of swiftui swift internal skill
How to improve the quality of Baidu keyword?
Why choose b+ tree as storage engine index structure
Audio knowledge (III) -- MFCCs code implementation
ArrayList#subList这四个坑,一不小心就中招
[digital ic/fpga] booth multiplier
New progress in the construction of meituan's Flink based real-time data warehouse platform
How to open a video number?
【直播回顾】战码先锋第七期:三方应用开发者如何为开源做贡献