The applications of Rt-thread RTOS

Source: Internet
Author: User
Tags posix

The applications of Rt-thread rtosintroduction

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 is both mode for rt-thread applications,

    • Standalone Application
    • Shared Library

The standalone application have 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 is 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'll be gradually a dded to each BSP):

    • M_cflags-user Application 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 rtthread-apps in directory, for example:

scons --app=hello

To build program hello .

scons --lib=libtar

To build a shared library.

A Simple Application

This was 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 program in the Hello World Pc/linux. Beside that, the user application can use the most of the 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 would 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 would build the program in scons --app=hello host environment, for example, build it a S a Linux program.

Therefore, only POSIX application can is built like that.

License

All of the user application was standalone program, if there was no special explanation, the license of these program is GPLV2. While the license of Rt-thread RTOS is gplv2+.

Source

The applications of Rt-thread RTOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.