如何将I-CUBE-LRWAN库添加到新项目? [英] How can I add I-CUBE-LRWAN libraries to a new project?

查看:269
本文介绍了如何将I-CUBE-LRWAN库添加到新项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用STM32 B-L072Z-LRWAN1发现套件.在CubeMX上为B-L072Z-LRWAN1发现工具包创建项目之后,如何在外部添加I-CUBE-LRWAN库.因为我创建的项目没有广播库.我正在使用System Workbench进行编码. 在进行此项目之前,我以乒乓球为例.创建一个新项目是不同的.因此,我正在尝试为Lora创建一个新项目. 感谢您的回答.

I am working with STM32 B-L072Z-LRWAN1 discovery kit. How can I add I-CUBE-LRWAN libraries externally, after i have created a project on CubeMX for B-L072Z-LRWAN1 discovery kit. Because project which i have created have not radio libraries. I am coding with System Workbench. Before this project, i used Ping-Pong example. It was divergent for create a fresh project. So i am trying to make a new project for Lora. Thanks for answers.

推荐答案

我打算从Keil项目的角度来回答它,因为那是我已经完成的程序,但是这些步骤应该可以互换与IDE.它主要涉及复制代码并添加正确的链接器和源路径.

I'm going to answer it from te point of view of a Keil project because that is the program wherein I've done it but these steps should be interchangeable with the IDE. It mostly involves copying the code and adding the right linker and source paths.

已设置I-CUBE-LRWAN项目,使得该项目的各个部分已分离.项目的根目录由三个文件夹组成:MiddlewaresProjectsDrivers.这些文件夹在其树形结构中同时包含.h.c文件.

The I-CUBE-LRWAN project has been setup such as that the parts of the project have been separated. The root directory of the project consists of three folders: Middlewares, Projects and Drivers. These folders contain both .h and .c files inside their tree structure.

Drivers文件夹包含与您正在使用的特定板,HAL(硬件抽象层),

The Drivers folder contains all the files related to the specific board you are using, the HAL (Hardware Abstraction Layer), CMSIS and the BSP (Board Support Package). The HAL and CMSIS provide a generalized interface towards the device and when using these creates code that can be ported to other STM32 platforms by changing out the CMSIS board specific definitions. I would recommend that when you create a project you tick the box to include all library files in your project. This will make compilation take longer and your project bigger but will also prevent you from fussing about with missing libraries. The BSP contains Board Specific interfaces for interfaces present on your platform. This includes LEDs and buttons on the L072Z-LRWAN1 and in case of the STM32l4 nucleo the joystick/LCD. I would recommend that you copy your board specific BSP (.h and .c) into your project and use them as a standardized interface to board specific features. You should create a new BSP .h/.c pair when you are using a custom board.

Projects包含您的项目特定代码,并包含您的应用程序的业务端. ST选择在main.c文件中实现其所有LoRaWAN代码,这条路有些艰难.我建议您取出所有与LoRaWAN相关的初始化和传输代码(通常与LoRaMainCallback_t相关的所有代码),并将其放入具有定义接口的单独文件中.这是一项工作,但由于您的常规代码已与LoRaWAN处理分开,因此会带来很多好处.我已经将我的LoRaWAN代码存储在文件lorawan.<h|c>中.关于其余文件:将内容移动到项目中名为LoRaWAN/App/inc/LoRaWAN/App/src/的单独文件夹中.这与以下文件有关:debug.chw_gpio.chw_rtc.chw_rtc.cvcom.cdebug.hhw.hhw_conf.hhw_gpio.hhw_msp.hhw_rtc.hhw_spi.hutilities_conf.hvcom.h.将inc文件夹添加到您的包含路径(-I选项),并将源文件添加到您的项目.

The Projects contains your project specific code and contains the business end of your application. A bit of a bump in the road comes up here as ST has chosen to implement all their LoRaWAN code inside the main.c file. I would recommend that you take out all the LoRaWAN related initialization and transmission code (generally anything related to LoRaMainCallback_t) and put it inside a separate file with a defined interface. This is a bit of work but will pay dividend in the fact that your normal code has been separated from your LoRaWAN handling. I've stored my LoRaWAN code inside the file lorawan.<h|c>. With regard to the rest of the files: move the contents to a separate folders in your project called LoRaWAN/App/inc/ and LoRaWAN/App/src/. This pertains to the files: debug.c, hw_gpio.c, hw_rtc.c, hw_rtc.c, vcom.c, debug.h, hw.h, hw_conf.h, hw_gpio.h, hw_msp.h, hw_rtc.h, hw_spi.h, utilities_conf.h and vcom.h. Add the inc folder to your include path (the -I option) and the source files to your project.

Middlewares文件夹需要从源项目复制到目标项目,并且每个inc文件夹或具有.h文件的文件夹都需要添加到包含路径,并且每个源文件都必须添加到您的项目.我建议将文件夹结构保留在IDE中,以使在项目和文件夹结构之间的导航更加容易.

The Middlewares folder needs to be copied from the source project to your target project and every inc folder or folder with .h files needs to be added to your include path and every source file needs to be added to your project. I would recommend that the folder structure is kept inside your IDE as to make your navigation between project and folder structure easier.

保持文件夹结构相似的另一个积极效果是,使用新的堆栈升级代码应该更容易,因为可以在两个项目中的相同位置找到文件.

Another postive effect of keeping the folder structures similar is that upgrading your code with a newer stack should be easier as the files can be found in a somewhat same place in both projects.

这是最重要的一步.您需要采用在项目内部定义的DEFINE参数并将其复制到您自己的项目中.可以在Keil项目(以及其他项目,但在其他地方)中的以下位置找到:options for target x-> C/C++-> define.它包含类似于以下值的内容:STM32L072xx,USE_B_<board name>,USE_HAL_DRIVER,REGION_EU868,DEBUG,TRACE.如您所见,我正在使用:具有集成STM32,EU 868区域以及调试和跟踪选项的Murata收音机.

And a most important step. You need to take the DEFINE parameters defined inside the project and copy the into your own project. This can be found inside the Keil project (and the other projects also but in other places) under: options for target x->C/C++->define. It contains something akin to these values: STM32L072xx,USE_B_<board name>,USE_HAL_DRIVER,REGION_EU868,DEBUG,TRACE. As you can see I'm using: a Murata radio with integrated STM32, the EU 868 region and debugging and tracing options.

应该可能包括"hw.h"完成一切正确的工作后再编译程序.

It should be possible to include "hw.h" and compile your program when you've done everything right.

这篇关于如何将I-CUBE-LRWAN库添加到新项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆