Reworked macro configuration system

This commit is contained in:
jgromes 2023-11-27 19:38:10 +01:00
parent f4938ea585
commit a2e2003001
6 changed files with 173 additions and 171 deletions

View file

@ -62,7 +62,7 @@ class ArduinoHal : public RadioLibHal {
void yield() override; void yield() override;
uint32_t pinToInterrupt(uint32_t pin) override; uint32_t pinToInterrupt(uint32_t pin) override;
#if !defined(RADIOLIB_GODMODE) #if !RADIOLIB_GODMODE
private: private:
#endif #endif
SPIClass* spi = NULL; SPIClass* spi = NULL;

View file

@ -1,6 +1,132 @@
#if !defined(_RADIOLIB_BUILD_OPTIONS_H) #if !defined(_RADIOLIB_BUILD_OPTIONS_H)
#define _RADIOLIB_BUILD_OPTIONS_H #define _RADIOLIB_BUILD_OPTIONS_H
/* RadioLib build configuration options */
/*
* Debug output enable.
* Warning: Debug output will slow down the whole system significantly.
* Also, it will result in larger compiled binary.
* Levels: debug - only main info
* verbose - full transcript of all SPI communication
*/
#if !defined(RADIOLIB_DEBUG)
#define RADIOLIB_DEBUG (0)
#endif
#if !defined(RADIOLIB_VERBOSE)
#define RADIOLIB_VERBOSE (0)
#endif
// set which output port should be used for debug output
// may be Serial port (on Arduino) or file like stdout or stderr (on generic platforms)
#if !defined(RADIOLIB_DEBUG_PORT)
#define RADIOLIB_DEBUG_PORT Serial
#endif
/*
* Comment to disable "paranoid" SPI mode, or set RADIOLIB_SPI_PARANOID to 0
* Every write to an SPI register using SPI set function will be verified by a subsequent read operation.
* This improves reliability, but slightly slows down communication.
* Note: Enabled by default.
*/
#if !defined(RADIOLIB_SPI_PARANOID)
#define RADIOLIB_SPI_PARANOID (1)
#endif
/*
* Comment to disable parameter range checking
* RadioLib will check provided parameters (such as frequency) against limits determined by the device manufacturer.
* It is highly advised to keep this macro defined, removing it will allow invalid values to be set,
* possibly leading to bricked module and/or program crashing.
* Note: Enabled by default.
*/
#if !defined(RADIOLIB_CHECK_PARAMS)
#define RADIOLIB_CHECK_PARAMS (1)
#endif
/*
* SX127x errata fix enable
* Warning: SX127x errata fix has been reported to cause issues with LoRa bandwidths lower than 62.5 kHz.
* It should only be enabled if you really are observing some errata-related issue.
* Note: Disabled by default.
*/
#if !defined(RADIOLIB_FIX_ERRATA_SX127X)
#define RADIOLIB_FIX_ERRATA_SX127X (0)
#endif
/*
* God mode enable - all methods and member variables in all classes will be made public, thus making them accessible from Arduino code.
* Warning: Come on, it's called GOD mode - obviously only use this if you know what you're doing.
* Failure to heed the above warning may result in bricked module.
*/
#if !defined(RADIOLIB_GODMODE)
#define RADIOLIB_GODMODE (0)
#endif
/*
* Low-level hardware access enable
* This will make some hardware methods like SPI get/set accessible from the user sketch - think of it as "god mode lite"
* Warning: RadioLib won't stop you from writing invalid stuff into your device, so it's quite easy to brick your module with this.
*/
#if !defined(RADIOLIB_LOW_LEVEL)
#define RADIOLIB_LOW_LEVEL (0)
#endif
/*
* Enable pre-defined modules when using RadioShield, disabled by default.
*/
#if !defined(RADIOLIB_RADIOSHIELD)
#define RADIOLIB_RADIOSHIELD (0)
#endif
/*
* Enable interrupt-based timing control
* For details, see https://github.com/jgromes/RadioLib/wiki/Interrupt-Based-Timing
*/
#if !defined(RADIOLIB_INTERRUPT_TIMING)
#define RADIOLIB_INTERRUPT_TIMING (0)
#endif
/*
* Enable static-only memory management: no dynamic allocation will be performed.
* Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode.
*/
#if !defined(RADIOLIB_STATIC_ONLY)
#define RADIOLIB_STATIC_ONLY (0)
#endif
// set the size of static arrays to use
#if !defined(RADIOLIB_STATIC_ARRAY_SIZE)
#define RADIOLIB_STATIC_ARRAY_SIZE (256)
#endif
// the base address for persistent storage
// some protocols (e.g. LoRaWAN) require a method
// to store some data persistently
// on Arduino, this will use EEPROM, on non-Arduino platform,
// it will use anything provided by the hardware abstraction layer
// RadioLib will place these starting at this address
#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_BASE)
#define RADIOLIB_HAL_PERSISTENT_STORAGE_BASE (0)
#endif
// the amount of space allocated to the persistent storage
#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE)
#define RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE (0x0180)
#endif
/*
* Uncomment on boards whose clock runs too slow or too fast
* Set the value according to the following scheme:
* Enable timestamps on your terminal
* Print something to terminal, wait 1000 milliseconds, print something again
* If the difference is e.g. 1014 milliseconds between the prints, set this value to 14
* Or, for more accuracy, wait for 100,000 milliseconds and divide the total drift by 100
*/
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
//#define RADIOLIB_CLOCK_DRIFT_MS (0)
#endif
#if ARDUINO >= 100 #if ARDUINO >= 100
// Arduino build // Arduino build
#include "Arduino.h" #include "Arduino.h"
@ -61,23 +187,23 @@
// NOTE: Some of the exclusion macros are dependent on each other. For example, it is not possible to exclude RF69 // NOTE: Some of the exclusion macros are dependent on each other. For example, it is not possible to exclude RF69
// while keeping SX1231 (because RF69 is the base class for SX1231). The dependency is always uni-directional, // while keeping SX1231 (because RF69 is the base class for SX1231). The dependency is always uni-directional,
// so excluding SX1231 and keeping RF69 is valid. // so excluding SX1231 and keeping RF69 is valid.
//#define RADIOLIB_EXCLUDE_CC1101 //#define RADIOLIB_EXCLUDE_CC1101 (1)
//#define RADIOLIB_EXCLUDE_NRF24 //#define RADIOLIB_EXCLUDE_NRF24 (1)
//#define RADIOLIB_EXCLUDE_RF69 //#define RADIOLIB_EXCLUDE_RF69 (1)
//#define RADIOLIB_EXCLUDE_SX1231 // dependent on RADIOLIB_EXCLUDE_RF69 //#define RADIOLIB_EXCLUDE_SX1231 (1) // dependent on RADIOLIB_EXCLUDE_RF69
//#define RADIOLIB_EXCLUDE_SI443X //#define RADIOLIB_EXCLUDE_SI443X (1)
//#define RADIOLIB_EXCLUDE_RFM2X // dependent on RADIOLIB_EXCLUDE_SI443X //#define RADIOLIB_EXCLUDE_RFM2X (1) // dependent on RADIOLIB_EXCLUDE_SI443X
//#define RADIOLIB_EXCLUDE_SX127X //#define RADIOLIB_EXCLUDE_SX127X (1)
//#define RADIOLIB_EXCLUDE_SX126X //#define RADIOLIB_EXCLUDE_SX126X (1)
//#define RADIOLIB_EXCLUDE_STM32WLX // dependent on RADIOLIB_EXCLUDE_SX126X //#define RADIOLIB_EXCLUDE_STM32WLX (1) // dependent on RADIOLIB_EXCLUDE_SX126X
//#define RADIOLIB_EXCLUDE_SX128X //#define RADIOLIB_EXCLUDE_SX128X (1)
//#define RADIOLIB_EXCLUDE_AFSK //#define RADIOLIB_EXCLUDE_AFSK (1)
//#define RADIOLIB_EXCLUDE_AX25 //#define RADIOLIB_EXCLUDE_AX25 (1)
//#define RADIOLIB_EXCLUDE_HELLSCHREIBER //#define RADIOLIB_EXCLUDE_HELLSCHREIBER (1)
//#define RADIOLIB_EXCLUDE_MORSE //#define RADIOLIB_EXCLUDE_MORSE (1)
//#define RADIOLIB_EXCLUDE_RTTY //#define RADIOLIB_EXCLUDE_RTTY (1)
//#define RADIOLIB_EXCLUDE_SSTV //#define RADIOLIB_EXCLUDE_SSTV (1)
//#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE //#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE (1)
#elif defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR)) #elif defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR))
// Arduino AVR boards (except for megaAVR) - Uno, Mega etc. // Arduino AVR boards (except for megaAVR) - Uno, Mega etc.
@ -337,137 +463,13 @@
#endif #endif
/*
* Uncomment to enable debug output.
* Warning: Debug output will slow down the whole system significantly.
* Also, it will result in larger compiled binary.
* Levels: debug - only main info
* verbose - full transcript of all SPI communication
*/
#if !defined(RADIOLIB_DEBUG)
//#define RADIOLIB_DEBUG
#endif
#if !defined(RADIOLIB_VERBOSE)
//#define RADIOLIB_VERBOSE
#endif
// set which output port should be used for debug output
// may be Serial port (on Arduino) or file like stdout or stderr (on generic platforms)
#if defined(RADIOLIB_BUILD_ARDUINO) && !defined(RADIOLIB_DEBUG_PORT)
#define RADIOLIB_DEBUG_PORT Serial
#endif
/*
* Comment to disable "paranoid" SPI mode, or set RADIOLIB_SPI_PARANOID to 0
* Every write to an SPI register using SPI set function will be verified by a subsequent read operation.
* This improves reliability, but slightly slows down communication.
* Note: Enabled by default.
*/
#if !defined(RADIOLIB_SPI_PARANOID)
#define RADIOLIB_SPI_PARANOID 1
#endif
/*
* Uncomment to enable parameter range checking
* RadioLib will check provided parameters (such as frequency) against limits determined by the device manufacturer.
* It is highly advised to keep this macro defined, removing it will allow invalid values to be set,
* possibly leading to bricked module and/or program crashing.
* Note: Enabled by default.
*/
#if !defined(RADIOLIB_CHECK_PARAMS)
#define RADIOLIB_CHECK_PARAMS
#endif
/*
* Uncomment to enable SX127x errata fix
* Warning: SX127x errata fix has been reported to cause issues with LoRa bandwidths lower than 62.5 kHz.
* It should only be enabled if you really are observing some errata-related issue.
* Note: Disabled by default.
*/
#if !defined(RADIOLIB_FIX_ERRATA_SX127X)
//#define RADIOLIB_FIX_ERRATA_SX127X
#endif
/*
* Uncomment to enable god mode - all methods and member variables in all classes will be made public, thus making them accessible from Arduino code.
* Warning: Come on, it's called GOD mode - obviously only use this if you know what you're doing.
* Failure to heed the above warning may result in bricked module.
*/
#if !defined(RADIOLIB_GODMODE)
//#define RADIOLIB_GODMODE
#endif
/*
* Uncomment to enable low-level hardware access
* This will make some hardware methods like SPI get/set accessible from the user sketch - think of it as "god mode lite"
* Warning: RadioLib won't stop you from writing invalid stuff into your device, so it's quite easy to brick your module with this.
*/
#if !defined(RADIOLIB_LOW_LEVEL)
//#define RADIOLIB_LOW_LEVEL
#endif
/*
* Uncomment to enable pre-defined modules when using RadioShield.
*/
#if !defined(RADIOLIB_RADIOSHIELD)
//#define RADIOLIB_RADIOSHIELD
#endif
/*
* Uncomment to enable interrupt-based timing control
* For details, see https://github.com/jgromes/RadioLib/wiki/Interrupt-Based-Timing
*/
#if !defined(RADIOLIB_INTERRUPT_TIMING)
//#define RADIOLIB_INTERRUPT_TIMING
#endif
/*
* Uncomment to enable static-only memory management: no dynamic allocation will be performed.
* Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode.
*/
#if !defined(RADIOLIB_STATIC_ONLY)
//#define RADIOLIB_STATIC_ONLY
#endif
// set the size of static arrays to use
#if !defined(RADIOLIB_STATIC_ARRAY_SIZE)
#define RADIOLIB_STATIC_ARRAY_SIZE (256)
#endif
// the base address for persistent storage
// some protocols (e.g. LoRaWAN) require a method
// to store some data persistently
// on Arduino, this will use EEPROM, on non-Arduino platform,
// it will use anything provided by the hardware abstraction layer
// RadioLib will place these starting at this address
#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_BASE)
#define RADIOLIB_HAL_PERSISTENT_STORAGE_BASE (0)
#endif
// the amount of space allocated to the persistent storage
#if !defined(RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE)
#define RADIOLIB_HAL_PERSISTENT_STORAGE_SIZE (0x0180)
#endif
/*
* Uncomment on boards whose clock runs too slow or too fast
* Set the value according to the following scheme:
* Enable timestamps on your terminal
* Print something to terminal, wait 1000 milliseconds, print something again
* If the difference is e.g. 1014 milliseconds between the prints, set this value to 14
* Or, for more accuracy, wait for 100,000 milliseconds and divide the total drift by 100
*/
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
//#define RADIOLIB_CLOCK_DRIFT_MS (0)
#endif
// This only compiles on STM32 boards with SUBGHZ module, but also // This only compiles on STM32 boards with SUBGHZ module, but also
// include when generating docs // include when generating docs
#if (!defined(ARDUINO_ARCH_STM32) || !defined(SUBGHZSPI_BASE)) && !defined(DOXYGEN) #if (!defined(ARDUINO_ARCH_STM32) || !defined(SUBGHZSPI_BASE)) && !defined(DOXYGEN)
#define RADIOLIB_EXCLUDE_STM32WLX #define RADIOLIB_EXCLUDE_STM32WLX (1)
#endif #endif
#if defined(RADIOLIB_DEBUG) #if RADIOLIB_DEBUG
#if defined(RADIOLIB_BUILD_ARDUINO) #if defined(RADIOLIB_BUILD_ARDUINO)
#define RADIOLIB_DEBUG_PRINT(...) Module::serialPrintf(__VA_ARGS__) #define RADIOLIB_DEBUG_PRINT(...) Module::serialPrintf(__VA_ARGS__)
#define RADIOLIB_DEBUG_PRINTLN(M, ...) Module::serialPrintf(M "\n", ##__VA_ARGS__) #define RADIOLIB_DEBUG_PRINTLN(M, ...) Module::serialPrintf(M "\n", ##__VA_ARGS__)
@ -491,7 +493,7 @@
#define RADIOLIB_DEBUG_HEXDUMP(...) {} #define RADIOLIB_DEBUG_HEXDUMP(...) {}
#endif #endif
#if defined(RADIOLIB_VERBOSE) #if RADIOLIB_VERBOSE
#define RADIOLIB_VERBOSE_PRINT(...) RADIOLIB_DEBUG_PRINT(__VA_ARGS__) #define RADIOLIB_VERBOSE_PRINT(...) RADIOLIB_DEBUG_PRINT(__VA_ARGS__)
#define RADIOLIB_VERBOSE_PRINTLN(...) RADIOLIB_DEBUG_PRINTLN(__VA_ARGS__) #define RADIOLIB_VERBOSE_PRINTLN(...) RADIOLIB_DEBUG_PRINTLN(__VA_ARGS__)
#else #else
@ -507,13 +509,13 @@
/*! /*!
\brief Macro to check variable is within constraints - this is commonly used to check parameter ranges. Requires RADIOLIB_CHECK_RANGE to be enabled \brief Macro to check variable is within constraints - this is commonly used to check parameter ranges. Requires RADIOLIB_CHECK_RANGE to be enabled
*/ */
#if defined(RADIOLIB_CHECK_PARAMS) #if RADIOLIB_CHECK_PARAMS
#define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) { if(!(((VAR) >= (MIN)) && ((VAR) <= (MAX)))) { return(ERR); } } #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) { if(!(((VAR) >= (MIN)) && ((VAR) <= (MAX)))) { return(ERR); } }
#else #else
#define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) {} #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) {}
#endif #endif
#if defined(RADIOLIB_FIX_ERRATA_SX127X) #if RADIOLIB_FIX_ERRATA_SX127X
#define RADIOLIB_ERRATA_SX127X(...) { errataFix(__VA_ARGS__); } #define RADIOLIB_ERRATA_SX127X(...) { errataFix(__VA_ARGS__); }
#else #else
#define RADIOLIB_ERRATA_SX127X(...) {} #define RADIOLIB_ERRATA_SX127X(...) {}

View file

@ -5,7 +5,7 @@
// most commonly, RADIOLIB_EXCLUDE_* macros // most commonly, RADIOLIB_EXCLUDE_* macros
// or enabling debug output // or enabling debug output
//#define RADIOLIB_DEBUG //#define RADIOLIB_DEBUG (1)
//#define RADIOLIB_VERBOSE //#define RADIOLIB_VERBOSE (1)
#endif #endif

View file

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined(RADIOLIB_DEBUG) #if RADIOLIB_DEBUG
// needed for debug print // needed for debug print
#include <stdarg.h> #include <stdarg.h>
#endif #endif
@ -145,7 +145,7 @@ void Module::SPIwriteRegister(uint16_t reg, uint8_t data) {
void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* dataIn, size_t numBytes) { void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* dataIn, size_t numBytes) {
// prepare the buffers // prepare the buffers
size_t buffLen = this->SPIaddrWidth/8 + numBytes; size_t buffLen = this->SPIaddrWidth/8 + numBytes;
#if defined(RADIOLIB_STATIC_ONLY) #if RADIOLIB_STATIC_ONLY
uint8_t buffOut[RADIOLIB_STATIC_ARRAY_SIZE]; uint8_t buffOut[RADIOLIB_STATIC_ARRAY_SIZE];
uint8_t buffIn[RADIOLIB_STATIC_ARRAY_SIZE]; uint8_t buffIn[RADIOLIB_STATIC_ARRAY_SIZE];
#else #else
@ -182,7 +182,7 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d
} }
// print debug information // print debug information
#if defined(RADIOLIB_VERBOSE) #if RADIOLIB_VERBOSE
uint8_t* debugBuffPtr = NULL; uint8_t* debugBuffPtr = NULL;
if(cmd == SPIwriteCommand) { if(cmd == SPIwriteCommand) {
RADIOLIB_VERBOSE_PRINT("W\t%X\t", reg); RADIOLIB_VERBOSE_PRINT("W\t%X\t", reg);
@ -197,7 +197,7 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d
RADIOLIB_VERBOSE_PRINTLN(); RADIOLIB_VERBOSE_PRINTLN();
#endif #endif
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] buffOut; delete[] buffOut;
delete[] buffIn; delete[] buffIn;
#endif #endif
@ -262,7 +262,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
if(!write) { if(!write) {
buffLen++; buffLen++;
} }
#if defined(RADIOLIB_STATIC_ONLY) #if RADIOLIB_STATIC_ONLY
uint8_t buffOut[RADIOLIB_STATIC_ARRAY_SIZE]; uint8_t buffOut[RADIOLIB_STATIC_ARRAY_SIZE];
uint8_t buffIn[RADIOLIB_STATIC_ARRAY_SIZE]; uint8_t buffIn[RADIOLIB_STATIC_ARRAY_SIZE];
#else #else
@ -292,7 +292,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
this->hal->yield(); this->hal->yield();
if(this->hal->millis() - start >= timeout) { if(this->hal->millis() - start >= timeout) {
RADIOLIB_DEBUG_PRINTLN("GPIO pre-transfer timeout, is it connected?"); RADIOLIB_DEBUG_PRINTLN("GPIO pre-transfer timeout, is it connected?");
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] buffOut; delete[] buffOut;
delete[] buffIn; delete[] buffIn;
#endif #endif
@ -319,7 +319,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
this->hal->yield(); this->hal->yield();
if(this->hal->millis() - start >= timeout) { if(this->hal->millis() - start >= timeout) {
RADIOLIB_DEBUG_PRINTLN("GPIO post-transfer timeout, is it connected?"); RADIOLIB_DEBUG_PRINTLN("GPIO post-transfer timeout, is it connected?");
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] buffOut; delete[] buffOut;
delete[] buffIn; delete[] buffIn;
#endif #endif
@ -342,7 +342,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
} }
// print debug information // print debug information
#if defined(RADIOLIB_VERBOSE) #if RADIOLIB_VERBOSE
// print command byte(s) // print command byte(s)
RADIOLIB_VERBOSE_PRINT("CMD"); RADIOLIB_VERBOSE_PRINT("CMD");
if(write) { if(write) {
@ -369,7 +369,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
RADIOLIB_VERBOSE_PRINTLN(); RADIOLIB_VERBOSE_PRINTLN();
#endif #endif
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] buffOut; delete[] buffOut;
delete[] buffIn; delete[] buffIn;
#endif #endif
@ -378,7 +378,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
} }
void Module::waitForMicroseconds(uint32_t start, uint32_t len) { void Module::waitForMicroseconds(uint32_t start, uint32_t len) {
#if defined(RADIOLIB_INTERRUPT_TIMING) #if RADIOLIB_INTERRUPT_TIMING
(void)start; (void)start;
if((this->TimerSetupCb != nullptr) && (len != this->prevTimingLen)) { if((this->TimerSetupCb != nullptr) && (len != this->prevTimingLen)) {
prevTimingLen = len; prevTimingLen = len;
@ -403,7 +403,7 @@ uint32_t Module::reflect(uint32_t in, uint8_t bits) {
return(res); return(res);
} }
#if defined(RADIOLIB_DEBUG) #if RADIOLIB_DEBUG
void Module::hexdump(uint8_t* data, size_t len, uint32_t offset, uint8_t width, bool be) { void Module::hexdump(uint8_t* data, size_t len, uint32_t offset, uint8_t width, bool be) {
size_t rem_len = len; size_t rem_len = len;
for(size_t i = 0; i < len; i+=16) { for(size_t i = 0; i < len; i+=16) {
@ -450,20 +450,20 @@ void Module::hexdump(uint8_t* data, size_t len, uint32_t offset, uint8_t width,
} }
void Module::regdump(uint16_t start, size_t len) { void Module::regdump(uint16_t start, size_t len) {
#if defined(RADIOLIB_STATIC_ONLY) #if RADIOLIB_STATIC_ONLY
uint8_t buff[RADIOLIB_STATIC_ARRAY_SIZE]; uint8_t buff[RADIOLIB_STATIC_ARRAY_SIZE];
#else #else
uint8_t* buff = new uint8_t[len]; uint8_t* buff = new uint8_t[len];
#endif #endif
SPIreadRegisterBurst(start, len, buff); SPIreadRegisterBurst(start, len, buff);
hexdump(buff, len, start); hexdump(buff, len, start);
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] buff; delete[] buff;
#endif #endif
} }
#endif #endif
#if defined(RADIOLIB_DEBUG) and defined(RADIOLIB_BUILD_ARDUINO) #if RADIOLIB_DEBUG && defined(RADIOLIB_BUILD_ARDUINO)
// https://github.com/esp8266/Arduino/blob/65579d29081cb8501e4d7f786747bf12e7b37da2/cores/esp8266/Print.cpp#L50 // https://github.com/esp8266/Arduino/blob/65579d29081cb8501e4d7f786747bf12e7b37da2/cores/esp8266/Print.cpp#L50
size_t Module::serialPrintf(const char* format, ...) { size_t Module::serialPrintf(const char* format, ...) {
va_list arg; va_list arg;

View file

@ -168,7 +168,7 @@ class Module {
*/ */
SPIparseStatusCb_t SPIparseStatusCb = nullptr; SPIparseStatusCb_t SPIparseStatusCb = nullptr;
#if defined(RADIOLIB_INTERRUPT_TIMING) #if RADIOLIB_INTERRUPT_TIMING
/*! /*!
\brief Timer interrupt setup callback typedef. \brief Timer interrupt setup callback typedef.
@ -468,7 +468,7 @@ class Module {
*/ */
static uint32_t reflect(uint32_t in, uint8_t bits); static uint32_t reflect(uint32_t in, uint8_t bits);
#if defined(RADIOLIB_DEBUG) #if RADIOLIB_DEBUG
/*! /*!
\brief Function to dump data as hex into the debug port. \brief Function to dump data as hex into the debug port.
\param data Data to dump. \param data Data to dump.
@ -486,11 +486,11 @@ class Module {
void regdump(uint16_t start, size_t len); void regdump(uint16_t start, size_t len);
#endif #endif
#if defined(RADIOLIB_DEBUG) and defined(RADIOLIB_BUILD_ARDUINO) #if RADIOLIB_DEBUG and defined(RADIOLIB_BUILD_ARDUINO)
static size_t serialPrintf(const char* format, ...); static size_t serialPrintf(const char* format, ...);
#endif #endif
#if !defined(RADIOLIB_GODMODE) #if !RADIOLIB_GODMODE
private: private:
#endif #endif
uint32_t csPin = RADIOLIB_NC; uint32_t csPin = RADIOLIB_NC;
@ -502,7 +502,7 @@ class Module {
uint32_t rfSwitchPins[RFSWITCH_MAX_PINS] = { RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC }; uint32_t rfSwitchPins[RFSWITCH_MAX_PINS] = { RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC };
const RfSwitchMode_t *rfSwitchTable = nullptr; const RfSwitchMode_t *rfSwitchTable = nullptr;
#if defined(RADIOLIB_INTERRUPT_TIMING) #if RADIOLIB_INTERRUPT_TIMING
uint32_t prevTimingLen = 0; uint32_t prevTimingLen = 0;
#endif #endif
}; };

View file

@ -47,7 +47,7 @@
// warnings are printed in this file since BuildOpt.h is compiled in multiple places // warnings are printed in this file since BuildOpt.h is compiled in multiple places
// check God mode // check God mode
#if defined(RADIOLIB_GODMODE) #if RADIOLIB_GODMODE
#warning "God mode active, I hope it was intentional. Buckle up, lads." #warning "God mode active, I hope it was intentional. Buckle up, lads."
#endif #endif
@ -120,7 +120,7 @@
#include "utils/Cryptography.h" #include "utils/Cryptography.h"
// only create Radio class when using RadioShield // only create Radio class when using RadioShield
#if defined(RADIOLIB_RADIOSHIELD) #if RADIOLIB_RADIOSHIELD
// RadioShield pin definitions // RadioShield pin definitions
#define RADIOSHIELD_CS_A 10 #define RADIOSHIELD_CS_A 10
@ -152,7 +152,7 @@ class Radio {
ModuleB = new Module(RADIOSHIELD_CS_B, RADIOSHIELD_IRQ_B, RADIOSHIELD_RST_B, RADIOSHIELD_GPIO_B); ModuleB = new Module(RADIOSHIELD_CS_B, RADIOSHIELD_IRQ_B, RADIOSHIELD_RST_B, RADIOSHIELD_GPIO_B);
} }
#if defined(RADIOLIB_GODMODE) #if RADIOLIB_GODMODE
private: private:
#endif #endif