| 1 | # RF24 Portability |
| 2 | |
| 3 | @tableofcontents |
| 4 | |
| 5 | The RF24 radio driver mainly utilizes the [Arduino API](http://arduino.cc/en/reference/homePage) |
| 6 | for GPIO, SPI, and timing functions, which are easily replicated on various platforms. |
| 7 | |
| 8 | Support files for these platforms are stored under RF24/utility, and can be modified to provide the |
| 9 | required functionality. |
| 10 | |
| 11 | ## Basic Hardware Template |
| 12 | |
| 13 | ### RF24/utility |
| 14 | |
| 15 | The RF24 library now includes a basic hardware template to assist in porting to various platforms. |
| 16 | |
| 17 | The following files can be included to replicate standard Arduino functions as needed, allowing devices from ATTiny to Raspberry Pi to utilize the same core RF24 driver. |
| 18 | |
| 19 | | File | Purpose | |
| 20 | | ------------------ | ---------------------------------------------------------------------------- | |
| 21 | | RF24_arch_config.h | Basic Arduino/AVR compatibility, includes for remaining support files, etc | |
| 22 | | includes.h | Linux only. Defines specific platform, include correct RF24_arch_config file | |
| 23 | | spi.h | Provides standardized SPI (`transfer()`) methods | |
| 24 | | gpio.h | Provides standardized GPIO (`digitalWrite()`) methods | |
| 25 | | compatibility.h | Provides standardized timing (`millis()`, `delay()`) methods | |
| 26 | | your_custom_file.h | Provides access to custom drivers for spi, gpio, etc | |
| 27 | |
| 28 | Examples are provided via the included hardware support templates in **RF24/utility** |
| 29 | |
| 30 | See the [modules](modules.html) page for examples of class declarations. |
| 31 | |
| 32 | ## Device Detection |
| 33 | |
| 34 | 1. The main detection for Linux devices is done in the configure script, with the includes.h from the proper hardware directory copied to RF24/utility/includes.h |
| 35 | 2. Secondary detection is completed in RF24_config.h, causing the include.h file to be included for all supported Linux devices |
| 36 | 3. RF24.h contains the declaration for SPI and GPIO objects 'spi' and 'gpio' to be used for porting-in related functions. |
| 37 | |
| 38 | ## Code |
| 39 | |
| 40 | To have your ported code included in this library, or for assistance in porting, create a pull request or open an issue at [RF24 Library issues](https://github.com/nRF24/RF24) |