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的更多相关文章

  1. RT Thread 通过ENV来配置SFUD,操作SPI Flash

    本实验基于正点原子stm32f4探索者板子 请移步我的RT Thread论坛帖子. https://www.rt-thread.org/qa/forum.php?mod=viewthread& ...

  2. STM32 + RT Thread OS 学习笔记[二]

    串口通讯例程 通过上面的练习,对STM32项目开发有了一个直观印象,接下来尝试对串口RS232进行操作. 1.   目标需求: 开机打开串口1,侦听上位机(使用电脑串口测试软件)发送的信息,然后原样输 ...

  3. STM32 + RT Thread OS 串口通讯

    1.   创建项目 a)   禁用Finsh和console b)   默认情况下,项目文件包含了finsh,它使用COM1来通讯,另外,console输出(rt_kprintf)也使用了COM1.因 ...

  4. STM32 + RT Thread OS 学习笔记[四]

    1.  补注 a)      硬件,打通通讯通道 若学习者购买了学习板,通常可以在学习板提供的示例代码中找到LCD的相关驱动代码,基本上,这里的驱动的所有代码都可以从里面找到. 从上面的示意图可见,M ...

  5. RT thread 设备驱动组件之USART设备

    本文以stm32f4xx平台介绍串口驱动,主要目的是:1.RTT中如何编写中断处理程序:2.如何编写RTT设备驱动接口代码:3.了解串行设备的常见处理机制.所涉及的主要源码文件有:驱动框架文件(usa ...

  6. STM32 + RT Thread OS 学习笔记[三]

    RTGUI 据说RTGUI是多线程的,因此与RT-Thread OS的耦合度较高,有可能要访问RT-Thread的线程控制块.如果要移植到其它OS,估计难度较大.目前还处于Alpha状态,最终将会包含 ...

  7. RT Thread的SPI设备驱动框架的使用以及内部机制分析

    注释:这是19年初的博客,写得很一般,理解不到位也不全面.19年末得空时又重新看了RTThread的SPI和GPIO,这次理解得比较深刻.有时间时再整理上传. -------------------- ...

  8. RT Thread SPI设备 使用

    后记: 之前,我把SPI的片选在Cubemx中配置成了SPI_NSS.现在我给它改为了GPIO_OUTPUT.  同时参考了别人的类似的一个操作无线模块(采用SPI设备驱动)的例子程序(清楚了RTT的 ...

  9. 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 ...

  10. 优先级反转实验,使用信号量实现【RT-Thread学习笔记 5】

    RTOS中很经典的问题.就是在使用共享资源的时候,优先级低的进程在优先级高的进程之前执行的问题.这里模拟这种情况. 下面的实验模拟了优先级反转的情况: 先定义三个线程: //优先级反转实验 rt_se ...

随机推荐

  1. 使用redis

    通过 Nuget获取包StackExchange.Redis 写数据: ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(&quo ...

  2. Cloud Container Service experimentation

    Cloud Container Service experimentation K8S技术社区 举办云容器技术动手工作坊 活动时间:2018年1月13日(周六)13:30-17:30 活动地点:北京海 ...

  3. excel的宏与VBA入门(三)——流程控制

    一.条件控制IF if 逻辑表达式 then 语句块 end if 带else的if语句: If 逻辑表达式1 Then 语句块1 ElseIf 逻辑表达式2 Then 语句块2 ElseIf 逻辑表 ...

  4. Command and Query Responsibility分离模式

    CQRS模式,就是命令和查询责任分离模式. CQRS模式通过使用不同的接口来分离读取数据和更新数据的操作.CQRS模式可以最大化性能,扩展性以及安全性,还会为系统的持续演化提供更多的弹性,防止Upda ...

  5. python 网络爬虫requests模块

    一.requests模块 requests模块是python中原生的基于网络请求的模块,其主要作用是用来模拟浏览器发起请求.功能强大,用法简洁高效. 1.1 模块介绍及请求过程 requests模块模 ...

  6. 【第三课】Centos 7.x系统安装和网络配置以及远程密钥登录

    目录 一.安装CentOS 7.3 二.配置网络 1.使用dhclient命令自动获取ip地址 2.使用ip addr或ifconfig命令查看网卡信息 3.使用route命令查看路由信息 4.通过修 ...

  7. [原创]STM32 BOOT模式配置以及作用

    一.三种BOOT模式介绍 所谓启动,一般来说就是指我们下好程序后,重启芯片时,SYSCLK的第4个上升沿,BOOT引脚的值将被锁存.用户可以通过设置BOOT1和BOOT0引脚的状态,来选择在复位后的启 ...

  8. idea git pull项目到本地时容易出现的问题

    有时候pull到本地,出了各种错误,其实是因为搞来搞去的,容易出问题,所以最好的方法是拿原有打包好的整个稳定能跑的项目环境, 先git add,然后vcs重置head为hard,然后再pull,一般就 ...

  9. Java设计模式-建造者(Builder)模式

    目录 由来 使用 1. 定义抽象 Builder 2. 定义具体 Builder类 3. 定义具体 Director类 4. 测试 定义 文字定义 结构图 优点 举例 @ 最近在看Mybatis的源码 ...

  10. .NetCore实践爬虫系统(二)自定义规则

    回顾 上篇文章NetCore实践爬虫系统(一)解析网页内容 我们讲了利用HtmlAgilityPack,输入XPath路径,识别网页节点,获取我们需要的内容.评论中也得到了大家的一些支持与建议.下面继 ...