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
// the base address for persistent storage
108
// some protocols (e.g. LoRaWAN) require a method
109
// to store some data persistently
110
// on Arduino, this will use EEPROM, on non-Arduino platform,
111
// it will use anything provided by the hardware abstraction layer
112
// RadioLib will place these starting at this address
113
#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_BASE)
114
#define RADIOLIB_HAL_PERSISTENT_STORAGE_BASE (0)
115
#endif
116
117
// the amount of space allocated to the persistent storage
118
#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE)
119
#define RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE (0x01C0)
120
#endif
121
122
/*
123
* Uncomment on boards whose clock runs too slow or too fast
124
* Set the value according to the following scheme:
125
* Enable timestamps on your terminal
126
* Print something to terminal, wait 1000 milliseconds, print something again
127
* If the difference is e.g. 1014 milliseconds between the prints, set this value to 14
128
* Or, for more accuracy, wait for 100,000 milliseconds and divide the total drift by 100
129
*/
130
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
131
//#define RADIOLIB_CLOCK_DRIFT_MS (0)
132
#endif
133
134
#if ARDUINO >= 100
135
// Arduino build
136
#include "Arduino.h"
137
#define RADIOLIB_BUILD_ARDUINO
138
#else
139
// generic build
140
#include <stdio.h>
141
#define RADIOLIB_BUILD_GENERIC
142
#endif
143
144
#if defined(RADIOLIB_BUILD_ARDUINO)
145
/*
146
* Platform-specific configuration.
147
*
148
* RADIOLIB_PLATFORM - platform name, used in debugging to quickly check the correct platform is detected.
149
* RADIOLIB_NC - alias for unused pin, usually the largest possible value of uint8_t.
150
* RADIOLIB_DEFAULT_SPI - default SPIClass instance to use.
151
* RADIOLIB_NONVOLATILE - macro to place variable into program storage (usually Flash).
152
* RADIOLIB_NONVOLATILE_READ_BYTE - function/macro to read variables saved in program storage (usually Flash).
153
* RADIOLIB_TYPE_ALIAS - construct to create an alias for a type, usually vai the `using` keyword.
154
* RADIOLIB_TONE_UNSUPPORTED - some platforms do not have tone()/noTone(), which is required for AFSK.
155
* RADIOLIB_BUILTIN_MODULE - some platforms have a builtin radio module on fixed pins, this macro is used to specify that pinout.
156
*
157
* In addition, some platforms may require RadioLib to disable specific drivers (such as ESP8266).
158
*
159
* Users may also specify their own configuration by uncommenting the RADIOLIB_CUSTOM_ARDUINO,
160
* and then specifying all platform parameters in the section below. This will override automatic
161
* platform detection.
162
*/
163
164
// uncomment to enable custom platform definition
165
//#define RADIOLIB_CUSTOM_ARDUINO
166
167
#if defined(RADIOLIB_CUSTOM_ARDUINO)
168
// name for your platform
169
#define RADIOLIB_PLATFORM "Custom"
170
171
// the following must be defined if the Arduino core does not support tone or yield function
172
//#define RADIOLIB_TONE_UNSUPPORTED
173
//#define RADIOLIB_YIELD_UNSUPPORTED
174
175
// in addition, the following macros may be defined if the Arduino core differs from the defaults
176
#define RADIOLIB_NC (0xFFFFFFFF)
177
#define RADIOLIB_DEFAULT_SPI SPI
178
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
179
#define RADIOLIB_NONVOLATILE PROGMEM
180
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
181
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
182
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
183
184
// you might also have to define these if the Arduino core has some uncommon pin mode/status types
185
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST
186
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST
187
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST
188
189
// some of RadioLib drivers may be excluded, to prevent collisions with platforms (or to speed up build process)
190
// the following is a complete list of all possible exclusion macros, uncomment any of them to disable that driver
191
// NOTE: Some of the exclusion macros are dependent on each other. For example, it is not possible to exclude RF69
192
// while keeping SX1231 (because RF69 is the base class for SX1231). The dependency is always uni-directional,
193
// so excluding SX1231 and keeping RF69 is valid.
194
//#define RADIOLIB_EXCLUDE_CC1101 (1)
195
//#define RADIOLIB_EXCLUDE_NRF24 (1)
196
//#define RADIOLIB_EXCLUDE_RF69 (1)
197
//#define RADIOLIB_EXCLUDE_SX1231 (1) // dependent on RADIOLIB_EXCLUDE_RF69
198
//#define RADIOLIB_EXCLUDE_SI443X (1)
199
//#define RADIOLIB_EXCLUDE_RFM2X (1) // dependent on RADIOLIB_EXCLUDE_SI443X
200
//#define RADIOLIB_EXCLUDE_SX127X (1)
201
//#define RADIOLIB_EXCLUDE_SX126X (1)
202
//#define RADIOLIB_EXCLUDE_STM32WLX (1) // dependent on RADIOLIB_EXCLUDE_SX126X
203
//#define RADIOLIB_EXCLUDE_SX128X (1)
204
//#define RADIOLIB_EXCLUDE_AFSK (1)
205
//#define RADIOLIB_EXCLUDE_AX25 (1)
206
//#define RADIOLIB_EXCLUDE_HELLSCHREIBER (1)
207
//#define RADIOLIB_EXCLUDE_MORSE (1)
208
//#define RADIOLIB_EXCLUDE_RTTY (1)
209
//#define RADIOLIB_EXCLUDE_SSTV (1)
210
//#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE (1)
211
212
#elif defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR))
213
// Arduino AVR boards (except for megaAVR) - Uno, Mega etc.
214
#define RADIOLIB_PLATFORM "Arduino AVR"
215
216
#if !(defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__))
217
#define RADIOLIB_LOWEND_PLATFORM
218
#endif
219
220
#elif defined(ESP8266)
221
// ESP8266 boards
222
#define RADIOLIB_PLATFORM "ESP8266"
223
224
#elif defined(ESP32) || defined(ARDUINO_ARCH_ESP32)
225
#define RADIOLIB_ESP32
226
227
// ESP32 boards
228
#define RADIOLIB_PLATFORM "ESP32"
229
230
// ESP32 doesn't support tone(), but it can be emulated via LED control peripheral
231
#define RADIOLIB_TONE_UNSUPPORTED
232
#define RADIOLIB_TONE_ESP32_CHANNEL (1)
233
234
#elif defined(ARDUINO_ARCH_STM32)
235
// official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32)
236
#define RADIOLIB_PLATFORM "Arduino STM32 (official)"
237
238
#elif defined(SAMD_SERIES)
239
// Adafruit SAMD boards (M0 and M4)
240
#define RADIOLIB_PLATFORM "Adafruit SAMD"
241
#define RADIOLIB_EEPROM_UNSUPPORTED
242
243
#elif defined(ARDUINO_ARCH_SAMD)
244
// Arduino SAMD (Zero, MKR, etc.)
245
#define RADIOLIB_PLATFORM "Arduino SAMD"
246
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
247
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
248
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
249
#define RADIOLIB_EEPROM_UNSUPPORTED
250
251
#elif defined(__SAM3X8E__)
252
// Arduino Due
253
#define RADIOLIB_PLATFORM "Arduino Due"
254
#define RADIOLIB_TONE_UNSUPPORTED
255
#define RADIOLIB_EEPROM_UNSUPPORTED
256
257
#elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE)
258
// Adafruit nRF52 boards
259
#define RADIOLIB_PLATFORM "Adafruit nRF52"
260
#define RADIOLIB_EEPROM_UNSUPPORTED
261
262
#elif defined(ARDUINO_ARC32_TOOLS)
263
// Intel Curie
264
#define RADIOLIB_PLATFORM "Intel Curie"
265
266
#elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(PORTDUINO)
267
// Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every
268
#define RADIOLIB_PLATFORM "Arduino megaAVR"
269
270
#elif defined(ARDUINO_ARCH_APOLLO3)
271
// Sparkfun Apollo3 boards
272
#define RADIOLIB_PLATFORM "Sparkfun Apollo3"
273
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (Arduino_PinMode)
274
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
275
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
276
277
#elif defined(ARDUINO_ARDUINO_NANO33BLE)
278
// Arduino Nano 33 BLE
279
#define RADIOLIB_PLATFORM "Arduino Nano 33 BLE"
280
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
281
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
282
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
283
#define RADIOLIB_EEPROM_UNSUPPORTED
284
285
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
286
#define RADIOLIB_TONE_UNSUPPORTED
287
#define RADIOLIB_MBED_TONE_OVERRIDE
288
289
#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
290
// Arduino Portenta H7
291
#define RADIOLIB_PLATFORM "Portenta H7"
292
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
293
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
294
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
295
#define RADIOLIB_EEPROM_UNSUPPORTED
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(__STM32F4__) || defined(__STM32F1__)
302
// Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32)
303
#define RADIOLIB_PLATFORM "STM32duino (unofficial)"
304
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (WiringPinMode)
305
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (ExtIntTriggerMode)
306
307
#elif defined(ARDUINO_ARCH_MEGAAVR)
308
// MegaCoreX by MCUdude (https://github.com/MCUdude/MegaCoreX)
309
#define RADIOLIB_PLATFORM "MegaCoreX"
310
311
#elif defined(ARDUINO_ARCH_MBED_RP2040)
312
// Raspberry Pi Pico (official mbed core)
313
#define RADIOLIB_PLATFORM "Raspberry Pi Pico"
314
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
315
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
316
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
317
#define RADIOLIB_EEPROM_UNSUPPORTED
318
319
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
320
#define RADIOLIB_TONE_UNSUPPORTED
321
#define RADIOLIB_MBED_TONE_OVERRIDE
322
323
#elif defined(ARDUINO_ARCH_RP2040)
324
// Raspberry Pi Pico (unofficial core)
325
#define RADIOLIB_PLATFORM "Raspberry Pi Pico (unofficial)"
326
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
327
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
328
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
329
330
#elif defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || defined(DARDUINO_ARCH_ASR6601)
331
// CubeCell
332
#define RADIOLIB_PLATFORM "CubeCell"
333
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(1000000, MSBFIRST, SPI_MODE0)
// see issue #709
334
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PINMODE)
335
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (IrqModes)
336
337
// provide an easy access to the on-board module
338
#include "board-config.h"
339
#define RADIOLIB_BUILTIN_MODULE RADIO_NSS, RADIO_DIO_1, RADIO_RESET, RADIO_BUSY
340
341
// CubeCell doesn't seem to define nullptr, let's do something like that now
342
#define nullptr NULL
343
344
// ... and also defines pinMode() as a macro, which is by far the stupidest thing I have seen on Arduino
345
#undef pinMode
346
347
// ... and uses an outdated GCC which does not support type aliases
348
#define RADIOLIB_TYPE_ALIAS(type, alias) typedef class type alias;
349
350
// ... and it also has no tone(). This platform was designed by an idiot.
351
#define RADIOLIB_TONE_UNSUPPORTED
352
353
// ... AND as the (hopefully) final nail in the coffin, IT F*CKING DEFINES YIELD() AS A MACRO THAT DOES NOTHING!!!
354
#define RADIOLIB_YIELD_UNSUPPORTED
355
#if defined(yield)
356
#undef yield
357
#endif
358
359
#elif defined(RASPI)
360
// RaspiDuino framework (https://github.com/me-no-dev/RasPiArduino)
361
#define RADIOLIB_PLATFORM "RasPiArduino"
362
363
// let's start off easy - no tone on this platform, that can happen
364
#define RADIOLIB_TONE_UNSUPPORTED
365
366
// hmm, no yield either - weird on something like Raspberry PI, but sure, we can handle it
367
#define RADIOLIB_YIELD_UNSUPPORTED
368
369
// aight, getting to the juicy stuff - PGM_P seems missing, that's the first time
370
#define PGM_P const char *
371
372
// ... and for the grand finale, we have millis() and micros() DEFINED AS MACROS!
373
#if defined(millis)
374
#undef millis
375
inline
unsigned
long
millis() {
return
((
unsigned
long
)(STCV / 1000)); };
376
#endif
377
378
#if defined(micros)
379
#undef micros
380
inline
unsigned
long
micros() {
return
((
unsigned
long
)(STCV)); };
381
#endif
382
383
#elif defined(TEENSYDUINO)
384
// Teensy
385
#define RADIOLIB_PLATFORM "Teensy"
386
387
#elif defined(ARDUINO_ARCH_RENESAS)
388
// Arduino Renesas (UNO R4)
389
#define RADIOLIB_PLATFORM "Arduino Renesas (UNO R4)"
390
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
391
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
392
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
393
394
#else
395
// other Arduino platforms not covered by the above list - this may or may not work
396
#define RADIOLIB_PLATFORM "Unknown Arduino"
397
#define RADIOLIB_UNKNOWN_PLATFORM
398
399
#endif
400
401
// set the default values for all macros
402
// these will be applied if they were not defined above
403
#if !defined(RADIOLIB_NC)
404
#define RADIOLIB_NC (0xFFFFFFFF)
405
#endif
406
407
#if !defined(RADIOLIB_DEFAULT_SPI)
408
#define RADIOLIB_DEFAULT_SPI SPI
409
#endif
410
411
#if !defined(RADIOLIB_DEFAULT_SPI_SETTINGS)
412
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
413
#endif
414
415
#if !defined(RADIOLIB_NONVOLATILE)
416
#define RADIOLIB_NONVOLATILE PROGMEM
417
#endif
418
419
#if !defined(RADIOLIB_NONVOLATILE_PTR)
420
#define RADIOLIB_NONVOLATILE_PTR PGM_P
421
#endif
422
423
#if !defined(RADIOLIB_NONVOLATILE_READ_BYTE)
424
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
425
#endif
426
427
#if !defined(RADIOLIB_NONVOLATILE_READ_DWORD)
428
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
429
#endif
430
431
#if !defined(RADIOLIB_TYPE_ALIAS)
432
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
433
#endif
434
435
#if !defined(RADIOLIB_ARDUINOHAL_PIN_MODE_CAST)
436
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST
437
#endif
438
439
#if !defined(RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST)
440
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST
441
#endif
442
443
#if !defined(RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST)
444
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST
445
#endif
446
447
#else
448
// generic non-Arduino platform
449
#define RADIOLIB_PLATFORM "Generic"
450
451
#define RADIOLIB_NC (0xFF)
452
#define RADIOLIB_NONVOLATILE
453
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) (*((uint8_t *)(void *)(addr)))
454
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) (*((uint32_t *)(void *)(addr)))
455
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
456
457
#if !defined(RADIOLIB_DEBUG_PORT)
458
#define RADIOLIB_DEBUG_PORT stdout
459
#endif
460
461
#define DEC 10
462
#define HEX 16
463
#define OCT 8
464
#define BIN 2
465
466
#include <stdint.h>
467
468
#endif
469
470
// This only compiles on STM32 boards with SUBGHZ module, but also
471
// include when generating docs
472
#if (!defined(ARDUINO_ARCH_STM32) || !defined(SUBGHZSPI_BASE)) && !defined(DOXYGEN)
473
#define RADIOLIB_EXCLUDE_STM32WLX (1)
474
#endif
475
476
// set the global debug mode flag
477
#if RADIOLIB_DEBUG_BASIC || RADIOLIB_DEBUG_PROTOCOL || RADIOLIB_DEBUG_SPI
478
#define RADIOLIB_DEBUG (1)
479
#else
480
#define RADIOLIB_DEBUG (0)
481
#endif
482
483
#if RADIOLIB_DEBUG
484
#if defined(RADIOLIB_BUILD_ARDUINO)
485
#define RADIOLIB_DEBUG_PRINT(...) Module::serialPrintf(__VA_ARGS__)
486
#define RADIOLIB_DEBUG_PRINTLN(M, ...) Module::serialPrintf(M "\n"
, ##__VA_ARGS__)
487
#define RADIOLIB_DEBUG_PRINT_LVL(LEVEL, M, ...) Module::serialPrintf(LEVEL ""
M, ##__VA_ARGS__)
488
#define RADIOLIB_DEBUG_PRINTLN_LVL(LEVEL, M, ...) Module::serialPrintf(LEVEL ""
M "\n", ##__VA_ARGS__)
489
490
// some platforms do not support printf("%f"), so it has to be done this way
491
#define RADIOLIB_DEBUG_PRINT_FLOAT(LEVEL, VAL, DECIMALS) RADIOLIB_DEBUG_PRINT(LEVEL); RADIOLIB_DEBUG_PORT.print(VAL, DECIMALS)
492
#else
493
#if !defined(RADIOLIB_DEBUG_PRINT)
494
#define RADIOLIB_DEBUG_PRINT(...) fprintf(RADIOLIB_DEBUG_PORT, __VA_ARGS__)
495
#define RADIOLIB_DEBUG_PRINT_LVL(LEVEL, M, ...) fprintf(RADIOLIB_DEBUG_PORT, LEVEL ""
M, ##__VA_ARGS__)
496
#endif
497
#if !defined(RADIOLIB_DEBUG_PRINTLN)
498
#define RADIOLIB_DEBUG_PRINTLN(M, ...) fprintf(RADIOLIB_DEBUG_PORT, M "\n"
, ##__VA_ARGS__)
499
#define RADIOLIB_DEBUG_PRINTLN_LVL(LEVEL, M, ...) fprintf(RADIOLIB_DEBUG_PORT, LEVEL ""
M "\n", ##__VA_ARGS__)
500
#endif
501
#define RADIOLIB_DEBUG_PRINT_FLOAT(LEVEL, VAL, DECIMALS) RADIOLIB_DEBUG_PRINT(LEVEL "%.3f"
, VAL)
502
#endif
503
504
#define RADIOLIB_DEBUG_HEXDUMP(LEVEL, ...) RADIOLIB_DEBUG_PRINT(LEVEL); Module::hexdump(__VA_ARGS__)
505
#else
506
#define RADIOLIB_DEBUG_PRINT(...) {}
507
#define RADIOLIB_DEBUG_PRINTLN(...) {}
508
#define RADIOLIB_DEBUG_PRINT_FLOAT(VAL, DECIMALS) {}
509
#define RADIOLIB_DEBUG_HEXDUMP(...) {}
510
#endif
511
512
#if RADIOLIB_DEBUG_BASIC
513
#define RADIOLIB_DEBUG_BASIC_PRINT(...) RADIOLIB_DEBUG_PRINT_LVL("RLB_DBG: "
, __VA_ARGS__)
514
#define RADIOLIB_DEBUG_BASIC_PRINT_NOTAG(...) RADIOLIB_DEBUG_PRINT_LVL(""
, __VA_ARGS__)
515
#define RADIOLIB_DEBUG_BASIC_PRINTLN(...) RADIOLIB_DEBUG_PRINTLN_LVL("RLB_DBG: "
, __VA_ARGS__)
516
#define RADIOLIB_DEBUG_BASIC_PRINT_FLOAT(...) RADIOLIB_DEBUG_PRINT_FLOAT("RLB_DBG: "
, __VA_ARGS__);
517
#define RADIOLIB_DEBUG_BASIC_HEXDUMP(...) RADIOLIB_DEBUG_HEXDUMP("RLB_DBG: "
, __VA_ARGS__);
518
#else
519
#define RADIOLIB_DEBUG_BASIC_PRINT(...) {}
520
#define RADIOLIB_DEBUG_BASIC_PRINT_NOTAG(...) {}
521
#define RADIOLIB_DEBUG_BASIC_PRINTLN(...) {}
522
#define RADIOLIB_DEBUG_BASIC_PRINT_FLOAT(...) {}
523
#define RADIOLIB_DEBUG_BASIC_HEXDUMP(...) {}
524
#endif
525
526
#if RADIOLIB_DEBUG_PROTOCOL
527
#define RADIOLIB_DEBUG_PROTOCOL_PRINT(...) RADIOLIB_DEBUG_PRINT_LVL("RLB_PRO: "
, __VA_ARGS__)
528
#define RADIOLIB_DEBUG_PROTOCOL_PRINTLN(...) RADIOLIB_DEBUG_PRINTLN_LVL("RLB_PRO: "
, __VA_ARGS__)
529
#define RADIOLIB_DEBUG_PROTOCOL_PRINT_FLOAT(...) RADIOLIB_DEBUG_PRINT_FLOAT("RLB_PRO: "
, __VA_ARGS__);
530
#define RADIOLIB_DEBUG_PROTOCOL_HEXDUMP(...) RADIOLIB_DEBUG_HEXDUMP("RLB_PRO: "
, __VA_ARGS__);
531
#else
532
#define RADIOLIB_DEBUG_PROTOCOL_PRINT(...) {}
533
#define RADIOLIB_DEBUG_PROTOCOL_PRINTLN(...) {}
534
#define RADIOLIB_DEBUG_PROTOCOL_PRINT_FLOAT(...) {}
535
#define RADIOLIB_DEBUG_PROTOCOL_HEXDUMP(...) {}
536
#endif
537
538
#if RADIOLIB_DEBUG_SPI
539
#define RADIOLIB_DEBUG_SPI_PRINT(...) RADIOLIB_DEBUG_PRINT_LVL("RLB_SPI: "
, __VA_ARGS__)
540
#define RADIOLIB_DEBUG_SPI_PRINT_NOTAG(...) RADIOLIB_DEBUG_PRINT_LVL(""
, __VA_ARGS__)
541
#define RADIOLIB_DEBUG_SPI_PRINTLN(...) RADIOLIB_DEBUG_PRINTLN_LVL("RLB_SPI: "
, __VA_ARGS__)
542
#define RADIOLIB_DEBUG_SPI_PRINTLN_NOTAG(...) RADIOLIB_DEBUG_PRINTLN_LVL(""
, __VA_ARGS__)
543
#define RADIOLIB_DEBUG_SPI_PRINT_FLOAT(...) RADIOLIB_DEBUG_PRINT_FLOAT("RLB_SPI: "
, __VA_ARGS__);
544
#define RADIOLIB_DEBUG_SPI_HEXDUMP(...) RADIOLIB_DEBUG_HEXDUMP("RLB_SPI: "
, __VA_ARGS__);
545
#else
546
#define RADIOLIB_DEBUG_SPI_PRINT(...) {}
547
#define RADIOLIB_DEBUG_SPI_PRINT_NOTAG(...) {}
548
#define RADIOLIB_DEBUG_SPI_PRINTLN(...) {}
549
#define RADIOLIB_DEBUG_SPI_PRINTLN_NOTAG(...) {}
550
#define RADIOLIB_DEBUG_SPI_PRINT_FLOAT(...) {}
551
#define RADIOLIB_DEBUG_SPI_HEXDUMP(...) {}
552
#endif
553
554
558
#define RADIOLIB_ASSERT(STATEVAR) { if((STATEVAR) != RADIOLIB_ERR_NONE) { return(STATEVAR); } }
559
563
#if RADIOLIB_CHECK_PARAMS
564
#define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) { if(!(((VAR) >= (MIN)) && ((VAR) <= (MAX)))) { return(ERR); } }
565
#else
566
#define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) {}
567
#endif
568
569
#if RADIOLIB_FIX_ERRATA_SX127X
570
#define RADIOLIB_ERRATA_SX127X(...) { errataFix(__VA_ARGS__); }
571
#else
572
#define RADIOLIB_ERRATA_SX127X(...) {}
573
#endif
574
575
// these macros are usually defined by Arduino, but some platforms undef them, so its safer to use our own
576
#define RADIOLIB_MIN(a,b) ((a)<(b)?(a):(b))
577
#define RADIOLIB_MAX(a,b) ((a)>(b)?(a):(b))
578
#define RADIOLIB_ABS(x) ((x)>0?(x):-(x))
579
580
// version definitions
581
#define RADIOLIB_VERSION_MAJOR 6
582
#define RADIOLIB_VERSION_MINOR 4
583
#define RADIOLIB_VERSION_PATCH 2
584
#define RADIOLIB_VERSION_EXTRA 0
585
586
#define RADIOLIB_VERSION (((RADIOLIB_VERSION_MAJOR) << 24) | ((RADIOLIB_VERSION_MINOR) << 16) | ((RADIOLIB_VERSION_PATCH) << 8) | (RADIOLIB_VERSION_EXTRA))
587
588
#endif
src
BuildOpt.h
Generated by
1.9.1