Added build macro option to disable range checks

This commit is contained in:
jgromes 2021-02-21 16:56:19 +01:00
parent 0cdd49ca11
commit ef7a8b6e0f

View file

@ -380,9 +380,19 @@
* Uncomment to enable "paranoid" SPI mode * Uncomment to enable "paranoid" SPI mode
* Every write to an SPI register using SPI set function will be verified by a subsequent read operation. * Every write to an SPI register using SPI set function will be verified by a subsequent read operation.
* This improves reliablility, but slightly slows down communication. * This improves reliablility, but slightly slows down communication.
* Note: Enabled by default.
*/ */
#define RADIOLIB_SPI_PARANOID #define RADIOLIB_SPI_PARANOID
/*
* 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.
*/
#define RADIOLIB_CHECK_RANGE
/* /*
* Uncomment to enable god mode - all methods and member variables in all classes will be made public, thus making them accessible from Arduino code. * 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. * Warning: Come on, it's called GOD mode - obviously only use this if you know what you're doing.
@ -399,7 +409,6 @@
* Uncomment to enable static-only memory management: no dynamic allocation will be performed. * 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. * Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode.
*/ */
//#define RADIOLIB_STATIC_ONLY //#define RADIOLIB_STATIC_ONLY
// set the size of static arrays to use // set the size of static arrays to use
@ -413,9 +422,13 @@
#define RADIOLIB_ASSERT(STATEVAR) { if((STATEVAR) != ERR_NONE) { return(STATEVAR); } } #define RADIOLIB_ASSERT(STATEVAR) { if((STATEVAR) != ERR_NONE) { return(STATEVAR); } }
/*! /*!
\brief Macro to check variable is within constraints - this is commonly used to check parameter ranges. \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_RANGE)
#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
#define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) {}
#endif
// version definitions // version definitions
#define RADIOLIB_VERSION_MAJOR (0x04) #define RADIOLIB_VERSION_MAJOR (0x04)