From 4e5fb27fc5bbfc598a955d0cf4e29f1ed54fad29 Mon Sep 17 00:00:00 2001 From: ltree Date: Sat, 7 Sep 2024 19:26:16 +0800 Subject: [PATCH] add Chinese[zh] readme file. --- README.md | 20 +++++---- README_zh.md | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 9 deletions(-) create mode 100644 README_zh.md diff --git a/README.md b/README.md index 98f2a0d..882f146 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ -# The Applications of RT-Thread RTOS # +# The Applications of RT-Thread RTOS -## Introduction ## +**English** | [中文 ](README_zh.md) + +## 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. @@ -15,7 +17,7 @@ a program in the PC/Linux. The shared library is compose of functions, and provide these APIs to other programs. -## Build Application ## +## 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: @@ -56,7 +58,7 @@ To build `hello` program. To build a shared library. -## A Simple Application ## +## A Simple Application This is a simple application of `Hello World`: @@ -76,7 +78,7 @@ application can use the most of APIs of RT-Thread, for example: void my_thread_entry(void* parameter) { int index; - + while (1) { rt_kprintf("index => %d\n", index ++); @@ -87,24 +89,24 @@ application can use the most of APIs of RT-Thread, for example: 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 ## +## 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 ## +## License All of user application are standalone program, if there is no special explanation, the license of these program is [GPLv2](LICENSE). While the license of RT-Thread RTOS is GPLv2+. diff --git a/README_zh.md b/README_zh.md new file mode 100644 index 0000000..7472dd9 --- /dev/null +++ b/README_zh.md @@ -0,0 +1,121 @@ +# RT-Thread RTOS 的应用 + +[English](README.md)| **中文** + +## [介绍](https://gitee.com/rtthread/rtthread-apps#introduction) + +rtthread-apps是 RT-Thread RTOS 的应用层,开发人员可以 在 RT-Thread 实时操作系统环境中开发应用程序。 + +RT-Thread 应用程序有两种模式, + +- 独立应用程序 +- 共享库 + +独立应用程序具有 main() 函数作为程序入口,它更像 PC/Linux 中的程序。 + +共享库由函数组成,并将这些 API 提供给其他程序。 + +## [构建应用程序](https://gitee.com/rtthread/rtthread-apps#build-application) + +首先,这些程序必须基于 RT-Thread 实时操作系统环境,并在内部运行。 在 RT-Thread 实时操作系统中,必须在 rtconfig.h 文件中启用 module 选项: + +``` +#define RT_USING_MODULE +``` + +并在 rtconfig.py 文件中提供构建应用程序的标志(从 RT-Thread 2.1.x 开始, 这些标志将逐步添加到每个 BSP 中): + +- M_CFLAGS - User Application C/C++ 编译器标志 +- M_LFLAGS - User Application 链接标志 + +并提供 ENV 变量 `BSP_ROOT` 指向您的板级支持包目录 + +Windows: + +``` +set BSP_ROOT=`your_bsp_directory` +``` + +Linux: + +``` +export BSP_ROOT=`your_bsp_directory` +``` + +要在 BSP 目录下运行命令: + +``` +scons --target=ua -s +``` + +要为 User Application 生成信息,例如头文件搜索路径、 RT-Thread RTOS etc 中定义的宏。 + +最后,您可以在`rtthread-apps`目录中构建用户应用程序,例如: + +``` +scons --app=hello +``` + +构建程序 `hello` + +``` +scons --lib=libtar +``` + +构建共享库 `libtar` + + + +## [一个简单的应用程序](https://gitee.com/rtthread/rtthread-apps#a-simple-application) + +这是一个简单的应用程序:`Hello World` + +```Hello +#include + +int main(int argc, char **argv) +{ + printf("Hello World!\n"); + return 0; +} +``` + +它就像 PC/Linux 中的程序一样。除此之外,用户应用程序可以使用 RT-Thread 的大部分 API,例如:`Hello World` + +```Hello +#include + +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; +} +``` + +此示例将创建一个名为 'tMyTask' 的子线程。 + +## [在主机中构建 POSIX应用程序](https://gitee.com/rtthread/rtthread-apps#build-the-posix-application-in-the-host) + +如果您没有设置` RTT_ROOT`或者`BSP_ROOT`,该命令将`scons --app=hello`将在主机环境中构建程序,例如作为一个 Linux 程序来构建。 + +因此,只有 POSIX 应用程序可以像这样构建。 + +## [许可证](https://gitee.com/rtthread/rtthread-apps#license) + +所有用户应用程序均为独立程序,如无特别说明, 这些程序的许可证是 [GPLv2](https://gitee.com/rtthread/rtthread-apps/blob/master/LICENSE)。而 RT-Thread RTOS 的许可证是 GPLv2+。 -- Gitee