【Feedback】关于在RTOS下开发自定义代码模块的问题 Questions about custom code module under RTOS SDK

wacsy
Posts: 2
Joined: Wed Jul 13, 2016 5:02 pm

【Feedback】关于在RTOS下开发自定义代码模块的问题 Questions about custom code module under RTOS SDK

Postby wacsy » Wed Jul 13, 2016 5:47 pm

学习了一下ESP8266_RTOS_SDK下examples 文件夹下的各个示例代码,尤其是关于Makefile 文件和有多层文件夹由不同代码模块构成的示例,有个问题不是很明白。

如果我想自己写一个模块,例如examples 下的project_template下的sample_lib,其中需要定义一些头文件 例如sample_lib/sample.h(examples/sample_lib 下并没有任何头文件),并且需要include 到 user/user_main.c 中,那么这些头文件应该放在哪里呢?是否可以放在sample_lib中?如果放在sample_lib/include中,那么Makefile文件需要进行如何相应的修改呢?在Makefile 文件中已经有对应库文件修改的SUBDIRS = user sample_lib 以及 COMPONENTS_eagle.app.v6 = user/libuser.a sample_lib/libsample.a, 是否需要关于添加include 文件夹的修改呢?添加成功后,如何在user_main.c中引用呢? 例如 #include "sample_lib/sample.h" ?

或者是否需要放在与user文件夹平级的include 文件夹中?我现在的能够通过编译的是将这些头文件直接放到include下 例如include/sample.h,但是是否可以放在一个自文件下?例如include/sample_lib/sample.h?如果可以的话,如何在Makefile进行相应的修改呢?还有如何在user_main.c中引用呢?我尝试了 #include "sample_lib/sample.h"但是并不能成功进行编译。

我现在的代码结构是这样的
1.将project_template 文件夹中所有内容拷贝出来,粘贴到与RTOS_SDK同级的位置文件夹p1中,
2.将自定义的c代码文件放在sample_lib文件夹下
3.确认p1/sample_lib/Makefile文件中的库名:libsample.a
4.确认在p1/Makefile文件中引用的文件夹名以及库名
5.将sample_lib中的所有c文件对应的header文件直接放在p1/include下
6.在user_main.c中直接引用#include "sample.h"
7.编译成功,下载成功

由于这样做虽然能够成功,但是文件直接的关系比较混乱,而去头文件多了以后,全部直接放在p1/include下就更加混乱,所以我想将头文件放在p1/include/sample_lib下 或者 p1/sample_lib/include下,但是不清楚需要如何修改Makefile文件或其他文件,以及如何在user_main.c中引用。

希望有高手指教,十分感谢

Got some question about where I should put header file in the folder and how to include it in the user_main.c file, based on the ESP8266 RTOS SDK.

I want to wire a module, similar as RTOS_SDK/examples/project_template/sample_lib, what I did as follow:

1. copy the contents of RTOS_SDK/examples/project_template to a fold (named p1) with same level as RTOS_SDK
2. put all my .c files to p1/sample_lib
3. check the lib name in p1/sample_lib/Makefile as libsample.a
4. check the folder name and lib name in the file of p1/Makefile
5. put my .h file sample.h directly into p1/include
6. include the header file in user_main.c by using #include "sample.h"
7. compile and download successfully.

The question is that the structure is not clear. With more than one header files, there will be a lot of header files in p1/include without any clue of which c files they linked to. So I would like to put header files in p1/include/sample_lib or p1/sample_lib/include, but I don't know how to make the compiler happy by modify the Makefile or other files, and how to include it in user_main.c. I tried include it by using #include "sample_lib/sample.h" but no luck.

Appreciate to any tips. Thanks a lot

ESP_Rubin
Posts: 222
Joined: Wed Jun 29, 2016 11:59 am

Re: 关于在RTOS下开发自定义代码模块的问题 Questions about custom code module under RTOS SDK

Postby ESP_Rubin » Thu Jul 14, 2016 9:38 am

你好,
看了您的需求,大概意思是想自己独立建一个工程,该工程除了编译依赖于我们现有的RTOS_SDK,其他可以自己独立管理?
如果是这样的话,您可以参考我们RTOS下的IOT Demo,基本思路和您所需要的差不多,编译时需要指定SDK_PATH和BIN_PATH这两个环节变量,具体请参考链接:https://github.com/espressif/ESP8266_IOT_PLATFORM

wacsy
Posts: 2
Joined: Wed Jul 13, 2016 5:02 pm

Re: 关于在RTOS下开发自定义代码模块的问题 Questions about custom code module under RTOS SDK

Postby wacsy » Thu Jul 14, 2016 5:31 pm

esp_rubin wrote:你好,
看了您的需求,大概意思是想自己独立建一个工程,该工程除了编译依赖于我们现有的RTOS_SDK,其他可以自己独立管理?
如果是这样的话,您可以参考我们RTOS下的IOT Demo,基本思路和您所需要的差不多,编译时需要指定SDK_PATH和BIN_PATH这两个环节变量,具体请参考链接:https://github.com/espressif/ESP8266_IOT_PLATFORM


十分感谢,我再仔细看看这个例子。谢谢

Who is online

Users browsing this forum: No registered users and 328 guests