10 Porting to non Arduino Platforms
Jan Gromeš edytuje tę stronę 2023-07-22 19:22:33 +02:00

Even though RadioLib was originally written for Arduino, it can run on any platform that can compile C++ code. This page shows how to install and use RadioLib on any generic platform. Go here to see an example for Raspberry Pi.

To port RadioLib, follow these steps:

  1. Install the library
    There are two options how to do this. The more common way is to use RadioLib source directly in your project. Alternatively, you can also install RadioLib as a shared library, to make it available system-wide. This is useful if you are compiling the library directly on the target platform, and not cross-compiling:
$ mkdir build/
$ cd build
$ cmake ..
$ sudo make install
  1. Include RadioLib in your project
    In the appropriate file in your project, include the library header:
    #include <RadioLib.h>
    NOTE: If you installed RadioLib as a shared library in the previous step, you will have to include it like this:
    #include <RadioLib/RadioLib.h>

  2. Provide your hardware abstraction layer to RadioLib
    To run on different platforms (e.g., esp-idf for ESP32, stm32hal for STM32, pigpio for Raspberry Pi etc.), RadioLib includes a light abstraction layer class. It's up to the user to add implementation of this abstraction layer - usually this boils down to providing functions that perform GPIO operations, SPI transactions etc. An example for Raspberry Pi using the pigpio library can be found here: https://github.com/jgromes/RadioLib/blob/master/examples/NonArduino/Raspberry/PiHal.h

  3. Done!
    Congratulations, you have now succesfully ported RadioLib to your platform!