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