RadioLib
Universal wireless communication library for Arduino
BuildOpt.h
1 #if !defined(_RADIOLIB_BUILD_OPTIONS_H)
2 #define _RADIOLIB_BUILD_OPTIONS_H
3 
4 /* RadioLib build configuration options */
5 
6 /*
7  * Debug output enable.
8  * Warning: Debug output will slow down the whole system significantly.
9  * Also, it will result in larger compiled binary.
10  * Levels: debug - only main info
11  * verbose - full transcript of all SPI communication
12  */
13 #if !defined(RADIOLIB_DEBUG)
14  #define RADIOLIB_DEBUG (0)
15 #endif
16 #if !defined(RADIOLIB_VERBOSE)
17  #define RADIOLIB_VERBOSE (0)
18 #endif
19 
20 // set which output port should be used for debug output
21 // may be Serial port (on Arduino) or file like stdout or stderr (on generic platforms)
22 #if !defined(RADIOLIB_DEBUG_PORT)
23  #define RADIOLIB_DEBUG_PORT Serial
24 #endif
25 
26 /*
27  * Comment to disable "paranoid" SPI mode, or set RADIOLIB_SPI_PARANOID to 0
28  * Every write to an SPI register using SPI set function will be verified by a subsequent read operation.
29  * This improves reliability, but slightly slows down communication.
30  * Note: Enabled by default.
31  */
32 #if !defined(RADIOLIB_SPI_PARANOID)
33  #define RADIOLIB_SPI_PARANOID (1)
34 #endif
35 
36 /*
37  * Comment to disable parameter range checking
38  * RadioLib will check provided parameters (such as frequency) against limits determined by the device manufacturer.
39  * It is highly advised to keep this macro defined, removing it will allow invalid values to be set,
40  * possibly leading to bricked module and/or program crashing.
41  * Note: Enabled by default.
42  */
43 #if !defined(RADIOLIB_CHECK_PARAMS)
44  #define RADIOLIB_CHECK_PARAMS (1)
45 #endif
46 
47 /*
48  * SX127x errata fix enable
49  * Warning: SX127x errata fix has been reported to cause issues with LoRa bandwidths lower than 62.5 kHz.
50  * It should only be enabled if you really are observing some errata-related issue.
51  * Note: Disabled by default.
52  */
53 #if !defined(RADIOLIB_FIX_ERRATA_SX127X)
54  #define RADIOLIB_FIX_ERRATA_SX127X (0)
55 #endif
56 
57 /*
58  * God mode enable - all methods and member variables in all classes will be made public, thus making them accessible from Arduino code.
59  * Warning: Come on, it's called GOD mode - obviously only use this if you know what you're doing.
60  * Failure to heed the above warning may result in bricked module.
61  */
62 #if !defined(RADIOLIB_GODMODE)
63  #define RADIOLIB_GODMODE (0)
64 #endif
65 
66 /*
67  * Low-level hardware access enable
68  * This will make some hardware methods like SPI get/set accessible from the user sketch - think of it as "god mode lite"
69  * Warning: RadioLib won't stop you from writing invalid stuff into your device, so it's quite easy to brick your module with this.
70  */
71 #if !defined(RADIOLIB_LOW_LEVEL)
72  #define RADIOLIB_LOW_LEVEL (0)
73 #endif
74 
75 /*
76  * Enable pre-defined modules when using RadioShield, disabled by default.
77  */
78 #if !defined(RADIOLIB_RADIOSHIELD)
79  #define RADIOLIB_RADIOSHIELD (0)
80 #endif
81 
82 /*
83  * Enable interrupt-based timing control
84  * For details, see https://github.com/jgromes/RadioLib/wiki/Interrupt-Based-Timing
85  */
86 #if !defined(RADIOLIB_INTERRUPT_TIMING)
87  #define RADIOLIB_INTERRUPT_TIMING (0)
88 #endif
89 
90 /*
91  * Enable static-only memory management: no dynamic allocation will be performed.
92  * Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode.
93  */
94 #if !defined(RADIOLIB_STATIC_ONLY)
95  #define RADIOLIB_STATIC_ONLY (0)
96 #endif
97 
98 // set the size of static arrays to use
99 #if !defined(RADIOLIB_STATIC_ARRAY_SIZE)
100  #define RADIOLIB_STATIC_ARRAY_SIZE (256)
101 #endif
102 
103 // the base address for persistent storage
104 // some protocols (e.g. LoRaWAN) require a method
105 // to store some data persistently
106 // on Arduino, this will use EEPROM, on non-Arduino platform,
107 // it will use anything provided by the hardware abstraction layer
108 // RadioLib will place these starting at this address
109 #if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_BASE)
110  #define RADIOLIB_HAL_PERSISTENT_STORAGE_BASE (0)
111 #endif
112 
113 // the amount of space allocated to the persistent storage
114 #if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE)
115  #define RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE (0x0180)
116 #endif
117 
118 /*
119  * Uncomment on boards whose clock runs too slow or too fast
120  * Set the value according to the following scheme:
121  * Enable timestamps on your terminal
122  * Print something to terminal, wait 1000 milliseconds, print something again
123  * If the difference is e.g. 1014 milliseconds between the prints, set this value to 14
124  * Or, for more accuracy, wait for 100,000 milliseconds and divide the total drift by 100
125  */
126 #if !defined(RADIOLIB_CLOCK_DRIFT_MS)
127  //#define RADIOLIB_CLOCK_DRIFT_MS (0)
128 #endif
129 
130 #if ARDUINO >= 100
131  // Arduino build
132  #include "Arduino.h"
133  #define RADIOLIB_BUILD_ARDUINO
134 #else
135  // generic build
136  #include <stdio.h>
137  #define RADIOLIB_BUILD_GENERIC
138 #endif
139 
140 #if defined(RADIOLIB_BUILD_ARDUINO)
141 /*
142  * Platform-specific configuration.
143  *
144  * RADIOLIB_PLATFORM - platform name, used in debugging to quickly check the correct platform is detected.
145  * RADIOLIB_NC - alias for unused pin, usually the largest possible value of uint8_t.
146  * RADIOLIB_DEFAULT_SPI - default SPIClass instance to use.
147  * RADIOLIB_NONVOLATILE - macro to place variable into program storage (usually Flash).
148  * RADIOLIB_NONVOLATILE_READ_BYTE - function/macro to read variables saved in program storage (usually Flash).
149  * RADIOLIB_TYPE_ALIAS - construct to create an alias for a type, usually vai the `using` keyword.
150  * RADIOLIB_TONE_UNSUPPORTED - some platforms do not have tone()/noTone(), which is required for AFSK.
151  * RADIOLIB_BUILTIN_MODULE - some platforms have a builtin radio module on fixed pins, this macro is used to specify that pinout.
152  *
153  * In addition, some platforms may require RadioLib to disable specific drivers (such as ESP8266).
154  *
155  * Users may also specify their own configuration by uncommenting the RADIOLIB_CUSTOM_ARDUINO,
156  * and then specifying all platform parameters in the section below. This will override automatic
157  * platform detection.
158  */
159 
160  // uncomment to enable custom platform definition
161  //#define RADIOLIB_CUSTOM_ARDUINO
162 
163 #if defined(RADIOLIB_CUSTOM_ARDUINO)
164  // name for your platform
165  #define RADIOLIB_PLATFORM "Custom"
166 
167  // the following must be defined if the Arduino core does not support tone or yield function
168  //#define RADIOLIB_TONE_UNSUPPORTED
169  //#define RADIOLIB_YIELD_UNSUPPORTED
170 
171  // in addition, the following macros may be defined if the Arduino core differs from the defaults
172  #define RADIOLIB_NC (0xFFFFFFFF)
173  #define RADIOLIB_DEFAULT_SPI SPI
174  #define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
175  #define RADIOLIB_NONVOLATILE PROGMEM
176  #define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
177  #define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
178  #define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
179 
180  // you might also have to define these if the Arduino core has some uncommon pin mode/status types
181  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST
182  #define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST
183  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST
184 
185  // some of RadioLib drivers may be excluded, to prevent collisions with platforms (or to speed up build process)
186  // the following is a complete list of all possible exclusion macros, uncomment any of them to disable that driver
187  // NOTE: Some of the exclusion macros are dependent on each other. For example, it is not possible to exclude RF69
188  // while keeping SX1231 (because RF69 is the base class for SX1231). The dependency is always uni-directional,
189  // so excluding SX1231 and keeping RF69 is valid.
190  //#define RADIOLIB_EXCLUDE_CC1101 (1)
191  //#define RADIOLIB_EXCLUDE_NRF24 (1)
192  //#define RADIOLIB_EXCLUDE_RF69 (1)
193  //#define RADIOLIB_EXCLUDE_SX1231 (1) // dependent on RADIOLIB_EXCLUDE_RF69
194  //#define RADIOLIB_EXCLUDE_SI443X (1)
195  //#define RADIOLIB_EXCLUDE_RFM2X (1) // dependent on RADIOLIB_EXCLUDE_SI443X
196  //#define RADIOLIB_EXCLUDE_SX127X (1)
197  //#define RADIOLIB_EXCLUDE_SX126X (1)
198  //#define RADIOLIB_EXCLUDE_STM32WLX (1) // dependent on RADIOLIB_EXCLUDE_SX126X
199  //#define RADIOLIB_EXCLUDE_SX128X (1)
200  //#define RADIOLIB_EXCLUDE_AFSK (1)
201  //#define RADIOLIB_EXCLUDE_AX25 (1)
202  //#define RADIOLIB_EXCLUDE_HELLSCHREIBER (1)
203  //#define RADIOLIB_EXCLUDE_MORSE (1)
204  //#define RADIOLIB_EXCLUDE_RTTY (1)
205  //#define RADIOLIB_EXCLUDE_SSTV (1)
206  //#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE (1)
207 
208 #elif defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR))
209  // Arduino AVR boards (except for megaAVR) - Uno, Mega etc.
210  #define RADIOLIB_PLATFORM "Arduino AVR"
211 
212  #if !(defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
213  #define RADIOLIB_LOWEND_PLATFORM
214  #endif
215 
216 #elif defined(ESP8266)
217  // ESP8266 boards
218  #define RADIOLIB_PLATFORM "ESP8266"
219 
220 #elif defined(ESP32) || defined(ARDUINO_ARCH_ESP32)
221  #define RADIOLIB_ESP32
222 
223  // ESP32 boards
224  #define RADIOLIB_PLATFORM "ESP32"
225 
226  // ESP32 doesn't support tone(), but it can be emulated via LED control peripheral
227  #define RADIOLIB_TONE_UNSUPPORTED
228  #define RADIOLIB_TONE_ESP32_CHANNEL (1)
229 
230 #elif defined(ARDUINO_ARCH_STM32)
231  // official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32)
232  #define RADIOLIB_PLATFORM "Arduino STM32 (official)"
233 
234 #elif defined(SAMD_SERIES)
235  // Adafruit SAMD boards (M0 and M4)
236  #define RADIOLIB_PLATFORM "Adafruit SAMD"
237  #define RADIOLIB_EEPROM_UNSUPPORTED
238 
239 #elif defined(ARDUINO_ARCH_SAMD)
240  // Arduino SAMD (Zero, MKR, etc.)
241  #define RADIOLIB_PLATFORM "Arduino SAMD"
242  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
243  #define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
244  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
245  #define RADIOLIB_EEPROM_UNSUPPORTED
246 
247 #elif defined(__SAM3X8E__)
248  // Arduino Due
249  #define RADIOLIB_PLATFORM "Arduino Due"
250  #define RADIOLIB_TONE_UNSUPPORTED
251  #define RADIOLIB_EEPROM_UNSUPPORTED
252 
253 #elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE)
254  // Adafruit nRF52 boards
255  #define RADIOLIB_PLATFORM "Adafruit nRF52"
256  #define RADIOLIB_EEPROM_UNSUPPORTED
257 
258 #elif defined(ARDUINO_ARC32_TOOLS)
259  // Intel Curie
260  #define RADIOLIB_PLATFORM "Intel Curie"
261 
262 #elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(PORTDUINO)
263  // Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every
264  #define RADIOLIB_PLATFORM "Arduino megaAVR"
265 
266 #elif defined(ARDUINO_ARCH_APOLLO3)
267  // Sparkfun Apollo3 boards
268  #define RADIOLIB_PLATFORM "Sparkfun Apollo3"
269  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (Arduino_PinMode)
270  #define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
271  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
272 
273 #elif defined(ARDUINO_ARDUINO_NANO33BLE)
274  // Arduino Nano 33 BLE
275  #define RADIOLIB_PLATFORM "Arduino Nano 33 BLE"
276  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
277  #define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
278  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
279  #define RADIOLIB_EEPROM_UNSUPPORTED
280 
281  // Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
282  #define RADIOLIB_TONE_UNSUPPORTED
283  #define RADIOLIB_MBED_TONE_OVERRIDE
284 
285 #elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
286  // Arduino Portenta H7
287  #define RADIOLIB_PLATFORM "Portenta H7"
288  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
289  #define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
290  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
291  #define RADIOLIB_EEPROM_UNSUPPORTED
292 
293  // Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
294  #define RADIOLIB_TONE_UNSUPPORTED
295  #define RADIOLIB_MBED_TONE_OVERRIDE
296 
297 #elif defined(__STM32F4__) || defined(__STM32F1__)
298  // Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32)
299  #define RADIOLIB_PLATFORM "STM32duino (unofficial)"
300  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (WiringPinMode)
301  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (ExtIntTriggerMode)
302 
303 #elif defined(ARDUINO_ARCH_MEGAAVR)
304  // MegaCoreX by MCUdude (https://github.com/MCUdude/MegaCoreX)
305  #define RADIOLIB_PLATFORM "MegaCoreX"
306 
307 #elif defined(ARDUINO_ARCH_MBED_RP2040)
308  // Raspberry Pi Pico (official mbed core)
309  #define RADIOLIB_PLATFORM "Raspberry Pi Pico"
310  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
311  #define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
312  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
313  #define RADIOLIB_EEPROM_UNSUPPORTED
314 
315  // Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
316  #define RADIOLIB_TONE_UNSUPPORTED
317  #define RADIOLIB_MBED_TONE_OVERRIDE
318 
319 #elif defined(ARDUINO_ARCH_RP2040)
320  // Raspberry Pi Pico (unofficial core)
321  #define RADIOLIB_PLATFORM "Raspberry Pi Pico (unofficial)"
322  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
323  #define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
324  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
325 
326 #elif defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || defined(DARDUINO_ARCH_ASR6601)
327  // CubeCell
328  #define RADIOLIB_PLATFORM "CubeCell"
329  #define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(1000000, MSBFIRST, SPI_MODE0) // see issue #709
330  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PINMODE)
331  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (IrqModes)
332 
333  // provide an easy access to the on-board module
334  #include "board-config.h"
335  #define RADIOLIB_BUILTIN_MODULE RADIO_NSS, RADIO_DIO_1, RADIO_RESET, RADIO_BUSY
336 
337  // CubeCell doesn't seem to define nullptr, let's do something like that now
338  #define nullptr NULL
339 
340  // ... and also defines pinMode() as a macro, which is by far the stupidest thing I have seen on Arduino
341  #undef pinMode
342 
343  // ... and uses an outdated GCC which does not support type aliases
344  #define RADIOLIB_TYPE_ALIAS(type, alias) typedef class type alias;
345 
346  // ... and it also has no tone(). This platform was designed by an idiot.
347  #define RADIOLIB_TONE_UNSUPPORTED
348 
349  // ... AND as the (hopefully) final nail in the coffin, IT F*CKING DEFINES YIELD() AS A MACRO THAT DOES NOTHING!!!
350  #define RADIOLIB_YIELD_UNSUPPORTED
351  #if defined(yield)
352  #undef yield
353  #endif
354 
355 #elif defined(RASPI)
356  // RaspiDuino framework (https://github.com/me-no-dev/RasPiArduino)
357  #define RADIOLIB_PLATFORM "RasPiArduino"
358 
359  // let's start off easy - no tone on this platform, that can happen
360  #define RADIOLIB_TONE_UNSUPPORTED
361 
362  // hmm, no yield either - weird on something like Raspberry PI, but sure, we can handle it
363  #define RADIOLIB_YIELD_UNSUPPORTED
364 
365  // aight, getting to the juicy stuff - PGM_P seems missing, that's the first time
366  #define PGM_P const char *
367 
368  // ... and for the grand finale, we have millis() and micros() DEFINED AS MACROS!
369  #if defined(millis)
370  #undef millis
371  inline unsigned long millis() { return((unsigned long)(STCV / 1000)); };
372  #endif
373 
374  #if defined(micros)
375  #undef micros
376  inline unsigned long micros() { return((unsigned long)(STCV)); };
377  #endif
378 
379 #elif defined(TEENSYDUINO)
380  // Teensy
381  #define RADIOLIB_PLATFORM "Teensy"
382 
383 #elif defined(ARDUINO_ARCH_RENESAS)
384  // Arduino Renesas (UNO R4)
385  #define RADIOLIB_PLATFORM "Arduino Renesas (UNO R4)"
386  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
387  #define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
388  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
389 
390 #else
391  // other Arduino platforms not covered by the above list - this may or may not work
392  #define RADIOLIB_PLATFORM "Unknown Arduino"
393  #define RADIOLIB_UNKNOWN_PLATFORM
394 
395 #endif
396 
397  // set the default values for all macros
398  // these will be applied if they were not defined above
399  #if !defined(RADIOLIB_NC)
400  #define RADIOLIB_NC (0xFFFFFFFF)
401  #endif
402 
403  #if !defined(RADIOLIB_DEFAULT_SPI)
404  #define RADIOLIB_DEFAULT_SPI SPI
405  #endif
406 
407  #if !defined(RADIOLIB_DEFAULT_SPI_SETTINGS)
408  #define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
409  #endif
410 
411  #if !defined(RADIOLIB_NONVOLATILE)
412  #define RADIOLIB_NONVOLATILE PROGMEM
413  #endif
414 
415  #if !defined(RADIOLIB_NONVOLATILE_PTR)
416  #define RADIOLIB_NONVOLATILE_PTR PGM_P
417  #endif
418 
419  #if !defined(RADIOLIB_NONVOLATILE_READ_BYTE)
420  #define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
421  #endif
422 
423  #if !defined(RADIOLIB_NONVOLATILE_READ_DWORD)
424  #define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
425  #endif
426 
427  #if !defined(RADIOLIB_TYPE_ALIAS)
428  #define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
429  #endif
430 
431  #if !defined(RADIOLIB_ARDUINOHAL_PIN_MODE_CAST)
432  #define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST
433  #endif
434 
435  #if !defined(RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST)
436  #define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST
437  #endif
438 
439  #if !defined(RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST)
440  #define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST
441  #endif
442 
443 #else
444  // generic non-Arduino platform
445  #define RADIOLIB_PLATFORM "Generic"
446 
447  #define RADIOLIB_NC (0xFF)
448  #define RADIOLIB_NONVOLATILE
449  #define RADIOLIB_NONVOLATILE_READ_BYTE(addr) (*((uint8_t *)(void *)(addr)))
450  #define RADIOLIB_NONVOLATILE_READ_DWORD(addr) (*((uint32_t *)(void *)(addr)))
451  #define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
452 
453  #if !defined(RADIOLIB_DEBUG_PORT)
454  #define RADIOLIB_DEBUG_PORT stdout
455  #endif
456 
457  #define DEC 10
458  #define HEX 16
459  #define OCT 8
460  #define BIN 2
461 
462  #include <stdint.h>
463 
464 #endif
465 
466 // This only compiles on STM32 boards with SUBGHZ module, but also
467 // include when generating docs
468 #if (!defined(ARDUINO_ARCH_STM32) || !defined(SUBGHZSPI_BASE)) && !defined(DOXYGEN)
469  #define RADIOLIB_EXCLUDE_STM32WLX (1)
470 #endif
471 
472 #if RADIOLIB_DEBUG
473  #if defined(RADIOLIB_BUILD_ARDUINO)
474  #define RADIOLIB_DEBUG_PRINT(...) Module::serialPrintf(__VA_ARGS__)
475  #define RADIOLIB_DEBUG_PRINTLN(M, ...) Module::serialPrintf(M "\n", ##__VA_ARGS__)
476 
477  // some platforms do not support printf("%f"), so it has to be done this way
478  #define RADIOLIB_DEBUG_PRINT_FLOAT(VAL, DECIMALS) RADIOLIB_DEBUG_PORT.print(VAL, DECIMALS)
479  #else
480  #if !defined(RADIOLIB_DEBUG_PRINT)
481  #define RADIOLIB_DEBUG_PRINT(...) fprintf(RADIOLIB_DEBUG_PORT, __VA_ARGS__)
482  #endif
483  #if !defined(RADIOLIB_DEBUG_PRINTLN)
484  #define RADIOLIB_DEBUG_PRINTLN(M, ...) fprintf(RADIOLIB_DEBUG_PORT, M "\n", ##__VA_ARGS__)
485  #endif
486  #define RADIOLIB_DEBUG_PRINT_FLOAT(VAL, DECIMALS) RADIOLIB_DEBUG_PRINT("%.3f", VAL)
487  #endif
488  #define RADIOLIB_DEBUG_HEXDUMP(...) Module::hexdump(__VA_ARGS__)
489 #else
490  #define RADIOLIB_DEBUG_PRINT(...) {}
491  #define RADIOLIB_DEBUG_PRINTLN(...) {}
492  #define RADIOLIB_DEBUG_PRINT_FLOAT(VAL, DECIMALS) {}
493  #define RADIOLIB_DEBUG_HEXDUMP(...) {}
494 #endif
495 
496 #if RADIOLIB_VERBOSE
497  #define RADIOLIB_VERBOSE_PRINT(...) RADIOLIB_DEBUG_PRINT(__VA_ARGS__)
498  #define RADIOLIB_VERBOSE_PRINTLN(...) RADIOLIB_DEBUG_PRINTLN(__VA_ARGS__)
499 #else
500  #define RADIOLIB_VERBOSE_PRINT(...) {}
501  #define RADIOLIB_VERBOSE_PRINTLN(...) {}
502 #endif
503 
507 #define RADIOLIB_ASSERT(STATEVAR) { if((STATEVAR) != RADIOLIB_ERR_NONE) { return(STATEVAR); } }
508 
512 #if RADIOLIB_CHECK_PARAMS
513  #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) { if(!(((VAR) >= (MIN)) && ((VAR) <= (MAX)))) { return(ERR); } }
514 #else
515  #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) {}
516 #endif
517 
518 #if RADIOLIB_FIX_ERRATA_SX127X
519  #define RADIOLIB_ERRATA_SX127X(...) { errataFix(__VA_ARGS__); }
520 #else
521  #define RADIOLIB_ERRATA_SX127X(...) {}
522 #endif
523 
524 // these macros are usually defined by Arduino, but some platforms undef them, so its safer to use our own
525 #define RADIOLIB_MIN(a,b) ((a)<(b)?(a):(b))
526 #define RADIOLIB_MAX(a,b) ((a)>(b)?(a):(b))
527 #define RADIOLIB_ABS(x) ((x)>0?(x):-(x))
528 
529 // version definitions
530 #define RADIOLIB_VERSION_MAJOR 6
531 #define RADIOLIB_VERSION_MINOR 2
532 #define RADIOLIB_VERSION_PATCH 0
533 #define RADIOLIB_VERSION_EXTRA 0
534 
535 #define RADIOLIB_VERSION (((RADIOLIB_VERSION_MAJOR) << 24) | ((RADIOLIB_VERSION_MINOR) << 16) | ((RADIOLIB_VERSION_PATCH) << 8) | (RADIOLIB_VERSION_EXTRA))
536 
537 #endif