A week ago I started messing with LoRa. I got my STM32L151 IM880A kit.

Company that provided SX1272 LoRa modem chip (used in kit), provided some libraries, but lots of functionalities are still not implemented and is still not suitable for use in multi P2P aplications.

After googling I came across Libelium company which used SX1272 chip in their products design and they provided useful set of libraries that provides lots of functionalities and also implements some sort of LoRa frame protocol stack ideal for use in P2P applications.

The problem is that I'm using STM32 in my project and Libelium libraries are written for Arduino. So I was wondering if there is a smart way to port Arduino libraries so I could use them in my STM32 Keil projects, since the libraries seems huge.

Tips, hints, links would be appreciated (I don't have experience in using Arduino and I'm not familiar with Arduino library structure).

  • Are you familiar with stm32/ARM cortex programming instead?
    – Marcus Müller
    Commented Jul 19, 2016 at 9:28
  • You can use Arduino software on an STM32: jeelabs.org/book/1545d
    – JimmyB
    Commented Jul 19, 2016 at 9:51
  • I don't want to use Arduino, I just want to know if it is possible to port libraries and in what measure is it convenient.
    – spasoye
    Commented Jul 19, 2016 at 10:20
  • 2
    @Ivan47 well "is it possible to port if it runs natively?": yes. "Is it easy to port": depends. Since you say you feel confident enough in doing Cortex programming: the library really isn't that big. Just port over these C++ methods you need. It'll be mainly a replacement of C++ with C (assuming you're not doing C++ on a cortex-m deliberately), and usage of CMSIS/STM32lib instead of things like arduino's "SPI" class.
    – Marcus Müller
    Commented Jul 19, 2016 at 10:27
  • Notice that the Libelium library you linked is licensed under the GNU LGPL 2.1. While this probably (IANAL) won't restrict your cross-usage of it, you definitely need to check about license compatibility if you produce a product with that code.
    – user2943160
    Commented Jul 19, 2016 at 11:03

2 Answers 2


Every time I work on a project I use arduino libraries and port them to my micro controller. I used sublime text editor with multiple selection and editing(ctrl-d). Then I copy the arduino code to both sublime and my uC IDE then compile it in the IDE, scroll up to the first undefined function and add its definition to the code or modify it using sublime multiple editing and selecting (like digital read and write was in my opinion useless). After that update the file in your IDE and compile again.

You would do that till you have finished and it would take some time.


So I was wondering if there is a smart way to port Arduino libraries so I could use them in my STM32 Keil projects, since the libraries seems huge.

Yes. the STM32 port of arduino uses GCC, which isn't that different MDK or ADS - I have ported quite a few from back and forth from GCC <-> MDK, and one from GCC to ADS. If the code is well written, in many times all you need to do is to change the isr-related code pieces (a few names) and hit the recompile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.