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