The Applications of RT-Thread RTOS
The Applications of RT-Thread RTOS
Introduction
The user application is the application layer of RT-Thread RTOS. The developer can develop his/her application out of RT-Thread RTOS firmware environment.
There are two mode for RT-Thread Applications,
- Standalone Application
- Shared Library
The standalone application has a main() function as the program entry. It more like a program in the PC/Linux.
The shared library is compose of functions, and provide these APIs to other programs.
Build Application
First of all, these programs must base on RT-Thread RTOS environment, and run inside. In the RT-Thread RTOS, the module option must be enable in rtconfig.h File:
#define RT_USING_MODULE
And provide the flags for Application building in rtconfig.py file (since RT-Thread 2.1.x, these flags will be gradually added to each BSP):
- M_CFLAGS - User Application C/C++ compiler flags
- M_LFLAGS - User Application link flags
And Provide the ENV variable BSP_ROOT which points to your board support package directory.
Windows:
set BSP_ROOT=your_bsp_directory
Linux:
export BSP_ROOT=your_bsp_directory
And to run the command under your BSP directory:
scons --target=ua -s
To generate the information for User Application, such as the header file search path, the macro defined in the RT-Thread RTOS etc.
Finally, you can build the user application in rtthread-apps directory, for example:
scons --app=hello
To build hello program.
scons --lib=libtar
To build a shared library.
A Simple Application
This is a simple application of Hello World:
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Hello World!\n");
return 0;
}
It's just like the Hello World program in the PC/Linux. Beside that, the user application can use the most of APIs of RT-Thread, for example:
#include <rtthread.h>
void my_thread_entry(void* parameter)
{
int index;
while (1)
{
rt_kprintf("index => %d\n", index ++);
rt_thread_delay(RT_TICK_PER_SECOND);
}
}
int my_thread_init(void)
{
rt_thread_t tid;
tid = rt_thread_create("tMyTask', my_thread_entry, RT_NULL,
2048, 20, 20);
if (tid != RT_NULL) rt_thread_startup(tid);
return 0;
}
This example will create a sub-thread, which named as 'tMyTask'.
Build the POSIX application in the host
If you didn't set RTT_ROOT/BSP_ROOT, The command scons --app=hello will build the program in host environment, for example, build it as a Linux program.
Therefore, only POSIX application can be built like that.
License
All of user application are standalone program, if there is no special explanation, the license of these program is GPLv2. While the license of RT-Thread RTOS is GPLv2+.
【来源】
The Applications of RT-Thread RTOS的更多相关文章
- RT Thread 通过ENV来配置SFUD,操作SPI Flash
本实验基于正点原子stm32f4探索者板子 请移步我的RT Thread论坛帖子. https://www.rt-thread.org/qa/forum.php?mod=viewthread& ...
- STM32 + RT Thread OS 学习笔记[二]
串口通讯例程 通过上面的练习,对STM32项目开发有了一个直观印象,接下来尝试对串口RS232进行操作. 1. 目标需求: 开机打开串口1,侦听上位机(使用电脑串口测试软件)发送的信息,然后原样输 ...
- STM32 + RT Thread OS 串口通讯
1. 创建项目 a) 禁用Finsh和console b) 默认情况下,项目文件包含了finsh,它使用COM1来通讯,另外,console输出(rt_kprintf)也使用了COM1.因 ...
- STM32 + RT Thread OS 学习笔记[四]
1. 补注 a) 硬件,打通通讯通道 若学习者购买了学习板,通常可以在学习板提供的示例代码中找到LCD的相关驱动代码,基本上,这里的驱动的所有代码都可以从里面找到. 从上面的示意图可见,M ...
- RT thread 设备驱动组件之USART设备
本文以stm32f4xx平台介绍串口驱动,主要目的是:1.RTT中如何编写中断处理程序:2.如何编写RTT设备驱动接口代码:3.了解串行设备的常见处理机制.所涉及的主要源码文件有:驱动框架文件(usa ...
- STM32 + RT Thread OS 学习笔记[三]
RTGUI 据说RTGUI是多线程的,因此与RT-Thread OS的耦合度较高,有可能要访问RT-Thread的线程控制块.如果要移植到其它OS,估计难度较大.目前还处于Alpha状态,最终将会包含 ...
- RT Thread的SPI设备驱动框架的使用以及内部机制分析
注释:这是19年初的博客,写得很一般,理解不到位也不全面.19年末得空时又重新看了RTThread的SPI和GPIO,这次理解得比较深刻.有时间时再整理上传. -------------------- ...
- RT Thread SPI设备 使用
后记: 之前,我把SPI的片选在Cubemx中配置成了SPI_NSS.现在我给它改为了GPIO_OUTPUT. 同时参考了别人的类似的一个操作无线模块(采用SPI设备驱动)的例子程序(清楚了RTT的 ...
- Java theory and practice: Thread pools and work queues--reference
Why thread pools? Many server applications, such as Web servers, database servers, file servers, or ...
- 优先级反转实验,使用信号量实现【RT-Thread学习笔记 5】
RTOS中很经典的问题.就是在使用共享资源的时候,优先级低的进程在优先级高的进程之前执行的问题.这里模拟这种情况. 下面的实验模拟了优先级反转的情况: 先定义三个线程: //优先级反转实验 rt_se ...
随机推荐
- 在 R 中估计 GARCH 参数存在的问题(续)
目录 在 R 中估计 GARCH 参数存在的问题(续) rugarch 包的使用 简单实验 rugarch 参数估计的行为 极端大样本 结论 在 R 中估计 GARCH 参数存在的问题(续) 本文承接 ...
- python基础——类定义(转)
一.类定义: class <类名>: <语句> 类实例化后,可以使用其属性,实际上,创建一个类之后,可以通过类名访问其属性.如果直接使用类名修改其属性,那么将直接影响到已经实例 ...
- Scala学习(一)--Scala基础学习
Scala基础学习 摘要: 在篇主要内容:如何把Scala当做工业级的便携计算器使用,如何用Scala处理数字以及其他算术操作.在这个过程中,我们将介绍一系列重要的Scala概念和惯用法.同时你还将学 ...
- 【第八课】php-fpm.conf配置文件解析
在discuz论坛的nginx配置文件当中,我们可以看到有一段php解析的配置,如下: location ~ \.php$ { try_files $uri = 404; fastcgi_pass 1 ...
- 解决 配置springmvc拦截所有请求后请求静态资源404的问题
<servlet-mapping> <servlet-name>spring-servlet</servlet-name> <url-pattern>/ ...
- python常用算法实现
排序是计算机语言需要实现的基本算法之一,有序的数据结构会带来效率上的极大提升. 1.插入排序 插入排序默认当前被插入的序列是有序的,新元素插入到应该插入的位置,使得新序列仍然有序. def inser ...
- 利用Kinect实现用指尖隔空控制鼠标(源码放出)
简介 此程序为利用Kinect实现用手指隔空控制鼠标,是我另一个项目的一部分,因为在另外那个项目中鼠标的click是通过一种特殊的方式实现的,因此这个程序只实现了用手控制鼠标的移动,并没有点击的功能. ...
- 【分享】熟练的Java程序员应该掌握哪些技术?
Java程序员应该掌握哪些能力才能算是脱离菜鸟达到熟练的程度? 1.语法:Java程序员必须比较熟悉语法,在写代码的时候IDE的编辑器对某一行报错应该能够根据报错信息 知道是什么样的语法错误并且知道任 ...
- Asp.Net_Mvc3.5语法_<%%>的用法
一. <%%>这种格式实际上就是和asp的用法一样的,只是asp中里面是vbscript或 者javascript代码,而在asp.net中用的是.net平台下支持的语言.特别 注意:服务 ...
- 《杜增强讲Unity之Tanks坦克大战》4-坦克的移动和旋转
4 坦克移动和旋转 本节课的目标是实现同时wsad和上下左右控制两个坦克分别移动和旋转 4.1 本节代码预览 image 将上节课场景s2另存为s3. 4.2 添加车轮扬沙效果 从Prefabs里 ...