diff --git a/_build_opt_8h_source.html b/_build_opt_8h_source.html index 2dc9dae5..80b1538d 100644 --- a/_build_opt_8h_source.html +++ b/_build_opt_8h_source.html @@ -822,7 +822,7 @@ $(document).ready(function(){initNavTree('_build_opt_8h_source.html',''); initRe
734  #undef yield
735  #endif
736 
-
737 #elif defined(RASPI)
+
737  #elif defined(RASPI)
738  // RaspiDuino framework (https://github.com/me-no-dev/RasPiArduino)
739  #define RADIOLIB_PLATFORM "RasPiArduino"
740  #define RADIOLIB_PIN_TYPE uint8_t
@@ -876,208 +876,242 @@ $(document).ready(function(){initNavTree('_build_opt_8h_source.html',''); initRe
788  inline unsigned long micros() { return((unsigned long)(STCV)); };
789  #endif
790 
-
791  #else
-
792  // other Arduino platforms not covered by the above list - this may or may not work
-
793  #define RADIOLIB_PLATFORM "Unknown Arduino"
-
794  #define RADIOLIB_UNKNOWN_PLATFORM
-
795  #define RADIOLIB_PIN_TYPE uint8_t
-
796  #define RADIOLIB_PIN_MODE uint8_t
-
797  #define RADIOLIB_PIN_STATUS uint8_t
-
798  #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
-
799  #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
-
800  #define RADIOLIB_NC (0xFF)
-
801  #define RADIOLIB_DEFAULT_SPI SPI
-
802  #define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
-
803  #define RADIOLIB_NONVOLATILE PROGMEM
-
804  #define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
-
805  #define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
-
806 
-
807  // Arduino API callbacks
-
808  #define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
-
809  #define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
-
810  #define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint8_t pin)
-
811  #define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
-
812  #define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
-
813  #define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t interruptNum, void (*userFunc)(void), int mode)
-
814  #define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
-
815  #define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
-
816  #define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
-
817  #define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
-
818  #define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
-
819  #define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
-
820  #define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
-
821  #define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
-
822  #define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
-
823  #define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
-
824  #define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
-
825 
-
826  #endif
-
827 #endif
-
828 
-
829 #else
-
830  // generic non-Arduino platform
-
831  #define RADIOLIB_PLATFORM "Generic"
-
832 
-
833  // platform properties may be defined here, or somewhere else in the build system
-
834 
-
835 #endif
-
836 
-
837 /*
-
838  * Uncomment to enable debug output.
-
839  * Warning: Debug output will slow down the whole system significantly.
-
840  * Also, it will result in larger compiled binary.
-
841  * Levels: debug - only main info
-
842  * verbose - full transcript of all SPI communication
-
843  */
-
844 #if !defined(RADIOLIB_DEBUG)
-
845  //#define RADIOLIB_DEBUG
-
846 #endif
-
847 #if !defined(RADIOLIB_VERBOSE)
-
848  //#define RADIOLIB_VERBOSE
-
849 #endif
-
850 
-
851 // set which output port should be used for debug output
-
852 // may be Serial port (on Arduino) or file like stdout or stderr (on generic platforms)
-
853 #if !defined(RADIOLIB_DEBUG_PORT)
-
854  #define RADIOLIB_DEBUG_PORT Serial
-
855 #endif
-
856 
-
857 /*
-
858  * Uncomment to enable "paranoid" SPI mode
-
859  * Every write to an SPI register using SPI set function will be verified by a subsequent read operation.
-
860  * This improves reliablility, but slightly slows down communication.
-
861  * Note: Enabled by default.
-
862  */
-
863 #if !defined(RADIOLIB_SPI_PARANOID)
-
864  #define RADIOLIB_SPI_PARANOID
-
865 #endif
+
791  #elif defined(TEENSYDUINO)
+
792  // Teensy
+
793  #define RADIOLIB_PLATFORM "Teensy"
+
794  #define RADIOLIB_PIN_TYPE uint8_t
+
795  #define RADIOLIB_PIN_MODE uint8_t
+
796  #define RADIOLIB_PIN_STATUS uint8_t
+
797  #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
+
798  #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
+
799  #define RADIOLIB_NC (0xFF)
+
800  #define RADIOLIB_DEFAULT_SPI SPI
+
801  #define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
+
802  #define RADIOLIB_NONVOLATILE PROGMEM
+
803  #define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
+
804  #define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
+
805 
+
806  // Arduino API callbacks
+
807  #define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
+
808  #define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
+
809  #define RADIOLIB_CB_ARGS_DIGITAL_READ (uint8_t, digitalRead, uint8_t pin)
+
810  #define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, short unsigned int frequency, long unsigned int duration)
+
811  #define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
+
812  #define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t interruptNum, void (*userFunc)(void), int mode)
+
813  #define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
+
814  #define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
+
815  #define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
+
816  #define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, long unsigned int us)
+
817  #define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
+
818  #define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
+
819  #define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
+
820  #define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
+
821  #define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
+
822  #define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
+
823  #define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
+
824 
+
825  #else
+
826  // other Arduino platforms not covered by the above list - this may or may not work
+
827  #define RADIOLIB_PLATFORM "Unknown Arduino"
+
828  #define RADIOLIB_UNKNOWN_PLATFORM
+
829  #define RADIOLIB_PIN_TYPE uint8_t
+
830  #define RADIOLIB_PIN_MODE uint8_t
+
831  #define RADIOLIB_PIN_STATUS uint8_t
+
832  #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS
+
833  #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p)
+
834  #define RADIOLIB_NC (0xFF)
+
835  #define RADIOLIB_DEFAULT_SPI SPI
+
836  #define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
+
837  #define RADIOLIB_NONVOLATILE PROGMEM
+
838  #define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
+
839  #define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
+
840 
+
841  // Arduino API callbacks
+
842  #define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode)
+
843  #define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value)
+
844  #define RADIOLIB_CB_ARGS_DIGITAL_READ (int, digitalRead, uint8_t pin)
+
845  #define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, unsigned int frequency, unsigned long duration)
+
846  #define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin)
+
847  #define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t interruptNum, void (*userFunc)(void), int mode)
+
848  #define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum)
+
849  #define RADIOLIB_CB_ARGS_YIELD (void, yield, void)
+
850  #define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms)
+
851  #define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, unsigned int us)
+
852  #define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void)
+
853  #define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void)
+
854  #define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void)
+
855  #define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void)
+
856  #define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b)
+
857  #define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void)
+
858  #define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void)
+
859 
+
860  #endif
+
861 #endif
+
862 
+
863 #else
+
864  // generic non-Arduino platform
+
865  #define RADIOLIB_PLATFORM "Generic"
866 
-
867 /*
-
868  * Uncomment to enable parameter range checking
-
869  * RadioLib will check provided parameters (such as frequency) against limits determined by the device manufacturer.
-
870  * It is highly advised to keep this macro defined, removing it will allow invalid values to be set,
-
871  * possibly leading to bricked module and/or program crashing.
-
872  * Note: Enabled by default.
-
873  */
-
874 #if !defined(RADIOLIB_CHECK_PARAMS)
-
875  #define RADIOLIB_CHECK_PARAMS
-
876 #endif
-
877 
-
878 /*
-
879  * Uncomment to enable SX127x errata fix
-
880  * Warning: SX127x errata fix has been reported to cause issues with LoRa bandwidths lower than 62.5 kHz.
-
881  * It should only be enabled if you really are observing some errata-related issue.
-
882  * Note: Disabled by default.
-
883  */
-
884 #if !defined(RADIOLIB_FIX_ERRATA_SX127X)
-
885  //#define RADIOLIB_FIX_ERRATA_SX127X
-
886 #endif
-
887 
-
888 /*
-
889  * Uncomment to enable god mode - all methods and member variables in all classes will be made public, thus making them accessible from Arduino code.
-
890  * Warning: Come on, it's called GOD mode - obviously only use this if you know what you're doing.
-
891  * Failure to heed the above warning may result in bricked module.
-
892  */
-
893 #if !defined(RADIOLIB_GODMODE)
-
894  //#define RADIOLIB_GODMODE
-
895 #endif
-
896 
-
897 /*
-
898  * Uncomment to enable low-level hardware access
-
899  * This will make some hardware methods like SPI get/set accessible from the user sketch - think of it as "god mode lite"
-
900  * Warning: RadioLib won't stop you from writing invalid stuff into your device, so it's quite easy to brick your module with this.
-
901  */
-
902 #if !defined(RADIOLIB_LOW_LEVEL)
-
903  //#define RADIOLIB_LOW_LEVEL
-
904 #endif
-
905 
-
906 /*
-
907  * Uncomment to enable pre-defined modules when using RadioShield.
-
908  */
-
909 #if !defined(RADIOLIB_RADIOSHIELD)
-
910  //#define RADIOLIB_RADIOSHIELD
-
911 #endif
-
912 
-
913 /*
-
914  * Uncomment to enable static-only memory management: no dynamic allocation will be performed.
-
915  * Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode.
-
916  */
-
917 #if !defined(RADIOLIB_STATIC_ONLY)
-
918  //#define RADIOLIB_STATIC_ONLY
-
919 #endif
-
920 
-
921 // set the size of static arrays to use
-
922 #if !defined(RADIOLIB_STATIC_ARRAY_SIZE)
-
923  #define RADIOLIB_STATIC_ARRAY_SIZE (256)
-
924 #endif
-
925 
-
926 #if defined(RADIOLIB_DEBUG)
-
927  #if defined(RADIOLIB_BUILD_ARDUINO)
-
928  #define RADIOLIB_DEBUG_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); }
-
929  #define RADIOLIB_DEBUG_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); }
-
930  #else
-
931  #if !defined(RADIOLIB_DEBUG_PRINT)
-
932  #define RADIOLIB_DEBUG_PRINT(...) { frintf(RADIOLIB_DEBUG_PORT, __VA_ARGS__); }
-
933  #endif
-
934  #if !defined(RADIOLIB_DEBUG_PRINTLN)
-
935  #define RADIOLIB_DEBUG_PRINTLN(...) { printf(RADIOLIB_DEBUG_PORT, __VA_ARGS__ "\n"); }
-
936  #endif
-
937  #endif
-
938 #else
-
939  #define RADIOLIB_DEBUG_PRINT(...) {}
-
940  #define RADIOLIB_DEBUG_PRINTLN(...) {}
-
941 #endif
-
942 
-
943 #if defined(RADIOLIB_VERBOSE)
-
944  #define RADIOLIB_VERBOSE_PRINT(...) RADIOLIB_DEBUG_PRINT(__VA_ARGS__)
-
945  #define RADIOLIB_VERBOSE_PRINTLN(...) RADIOLIB_DEBUG_PRINTLN(__VA_ARGS__)
-
946 #else
-
947  #define RADIOLIB_VERBOSE_PRINT(...) {}
-
948  #define RADIOLIB_VERBOSE_PRINTLN(...) {}
-
949 #endif
-
950 
-
954 #define RADIOLIB_ASSERT(STATEVAR) { if((STATEVAR) != RADIOLIB_ERR_NONE) { return(STATEVAR); } }
-
955 
-
956 /*
-
957  * Macros that create callback for the hardware abstraction layer.
-
958  *
-
959  * This is the most evil thing I have ever created. I am deeply sorry to anyone currently reading this text.
-
960  * Come one, come all and witness the horror:
-
961  * Variadics, forced expansions, inlined function, string concatenation, and it even messes up access specifiers.
-
962  */
-
963 #define RADIOLIB_FIRST(arg, ...) arg
-
964 #define RADIOLIB_REST(arg, ...) __VA_ARGS__
-
965 #define RADIOLIB_EXP(...) __VA_ARGS__
-
966 
-
967 #define RADIOLIB_GENERATE_CALLBACK_RET_FUNC(RET, FUNC, ...) public: typedef RET (*FUNC##_cb_t)(__VA_ARGS__); void setCb_##FUNC(FUNC##_cb_t cb) { cb_##FUNC = cb; }; private: FUNC##_cb_t cb_##FUNC;
-
968 #define RADIOLIB_GENERATE_CALLBACK_RET(RET, ...) RADIOLIB_GENERATE_CALLBACK_RET_FUNC(RET, __VA_ARGS__)
-
969 #define RADIOLIB_GENERATE_CALLBACK(CB) RADIOLIB_GENERATE_CALLBACK_RET(RADIOLIB_EXP(RADIOLIB_FIRST CB), RADIOLIB_EXP(RADIOLIB_REST CB))
-
970 
-
971 #define RADIOLIB_GENERATE_CALLBACK_SPI_RET_FUNC(RET, FUNC, ...) public: typedef RET (Module::*FUNC##_cb_t)(__VA_ARGS__); void setCb_##FUNC(FUNC##_cb_t cb) { cb_##FUNC = cb; }; private: FUNC##_cb_t cb_##FUNC;
-
972 #define RADIOLIB_GENERATE_CALLBACK_SPI_RET(RET, ...) RADIOLIB_GENERATE_CALLBACK_SPI_RET_FUNC(RET, __VA_ARGS__)
-
973 #define RADIOLIB_GENERATE_CALLBACK_SPI(CB) RADIOLIB_GENERATE_CALLBACK_SPI_RET(RADIOLIB_EXP(RADIOLIB_FIRST CB), RADIOLIB_EXP(RADIOLIB_REST CB))
-
974 
-
978 #if defined(RADIOLIB_CHECK_PARAMS)
-
979  #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) { if(!(((VAR) >= (MIN)) && ((VAR) <= (MAX)))) { return(ERR); } }
+
867  // platform properties may be defined here, or somewhere else in the build system
+
868 
+
869 #endif
+
870 
+
871 /*
+
872  * Uncomment to enable debug output.
+
873  * Warning: Debug output will slow down the whole system significantly.
+
874  * Also, it will result in larger compiled binary.
+
875  * Levels: debug - only main info
+
876  * verbose - full transcript of all SPI communication
+
877  */
+
878 #if !defined(RADIOLIB_DEBUG)
+
879  //#define RADIOLIB_DEBUG
+
880 #endif
+
881 #if !defined(RADIOLIB_VERBOSE)
+
882  //#define RADIOLIB_VERBOSE
+
883 #endif
+
884 
+
885 // set which output port should be used for debug output
+
886 // may be Serial port (on Arduino) or file like stdout or stderr (on generic platforms)
+
887 #if !defined(RADIOLIB_DEBUG_PORT)
+
888  #define RADIOLIB_DEBUG_PORT Serial
+
889 #endif
+
890 
+
891 /*
+
892  * Uncomment to enable "paranoid" SPI mode
+
893  * Every write to an SPI register using SPI set function will be verified by a subsequent read operation.
+
894  * This improves reliablility, but slightly slows down communication.
+
895  * Note: Enabled by default.
+
896  */
+
897 #if !defined(RADIOLIB_SPI_PARANOID)
+
898  #define RADIOLIB_SPI_PARANOID
+
899 #endif
+
900 
+
901 /*
+
902  * Uncomment to enable parameter range checking
+
903  * RadioLib will check provided parameters (such as frequency) against limits determined by the device manufacturer.
+
904  * It is highly advised to keep this macro defined, removing it will allow invalid values to be set,
+
905  * possibly leading to bricked module and/or program crashing.
+
906  * Note: Enabled by default.
+
907  */
+
908 #if !defined(RADIOLIB_CHECK_PARAMS)
+
909  #define RADIOLIB_CHECK_PARAMS
+
910 #endif
+
911 
+
912 /*
+
913  * Uncomment to enable SX127x errata fix
+
914  * Warning: SX127x errata fix has been reported to cause issues with LoRa bandwidths lower than 62.5 kHz.
+
915  * It should only be enabled if you really are observing some errata-related issue.
+
916  * Note: Disabled by default.
+
917  */
+
918 #if !defined(RADIOLIB_FIX_ERRATA_SX127X)
+
919  //#define RADIOLIB_FIX_ERRATA_SX127X
+
920 #endif
+
921 
+
922 /*
+
923  * Uncomment to enable god mode - all methods and member variables in all classes will be made public, thus making them accessible from Arduino code.
+
924  * Warning: Come on, it's called GOD mode - obviously only use this if you know what you're doing.
+
925  * Failure to heed the above warning may result in bricked module.
+
926  */
+
927 #if !defined(RADIOLIB_GODMODE)
+
928  //#define RADIOLIB_GODMODE
+
929 #endif
+
930 
+
931 /*
+
932  * Uncomment to enable low-level hardware access
+
933  * This will make some hardware methods like SPI get/set accessible from the user sketch - think of it as "god mode lite"
+
934  * Warning: RadioLib won't stop you from writing invalid stuff into your device, so it's quite easy to brick your module with this.
+
935  */
+
936 #if !defined(RADIOLIB_LOW_LEVEL)
+
937  //#define RADIOLIB_LOW_LEVEL
+
938 #endif
+
939 
+
940 /*
+
941  * Uncomment to enable pre-defined modules when using RadioShield.
+
942  */
+
943 #if !defined(RADIOLIB_RADIOSHIELD)
+
944  //#define RADIOLIB_RADIOSHIELD
+
945 #endif
+
946 
+
947 /*
+
948  * Uncomment to enable static-only memory management: no dynamic allocation will be performed.
+
949  * Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode.
+
950  */
+
951 #if !defined(RADIOLIB_STATIC_ONLY)
+
952  //#define RADIOLIB_STATIC_ONLY
+
953 #endif
+
954 
+
955 // set the size of static arrays to use
+
956 #if !defined(RADIOLIB_STATIC_ARRAY_SIZE)
+
957  #define RADIOLIB_STATIC_ARRAY_SIZE (256)
+
958 #endif
+
959 
+
960 #if defined(RADIOLIB_DEBUG)
+
961  #if defined(RADIOLIB_BUILD_ARDUINO)
+
962  #define RADIOLIB_DEBUG_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); }
+
963  #define RADIOLIB_DEBUG_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); }
+
964  #else
+
965  #if !defined(RADIOLIB_DEBUG_PRINT)
+
966  #define RADIOLIB_DEBUG_PRINT(...) { frintf(RADIOLIB_DEBUG_PORT, __VA_ARGS__); }
+
967  #endif
+
968  #if !defined(RADIOLIB_DEBUG_PRINTLN)
+
969  #define RADIOLIB_DEBUG_PRINTLN(...) { printf(RADIOLIB_DEBUG_PORT, __VA_ARGS__ "\n"); }
+
970  #endif
+
971  #endif
+
972 #else
+
973  #define RADIOLIB_DEBUG_PRINT(...) {}
+
974  #define RADIOLIB_DEBUG_PRINTLN(...) {}
+
975 #endif
+
976 
+
977 #if defined(RADIOLIB_VERBOSE)
+
978  #define RADIOLIB_VERBOSE_PRINT(...) RADIOLIB_DEBUG_PRINT(__VA_ARGS__)
+
979  #define RADIOLIB_VERBOSE_PRINTLN(...) RADIOLIB_DEBUG_PRINTLN(__VA_ARGS__)
980 #else
-
981  #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) {}
-
982 #endif
-
983 
-
984 #if defined(RADIOLIB_FIX_ERRATA_SX127X)
-
985  #define RADIOLIB_ERRATA_SX127X(...) { errataFix(__VA_ARGS__); }
-
986 #else
-
987  #define RADIOLIB_ERRATA_SX127X(...) {}
-
988 #endif
+
981  #define RADIOLIB_VERBOSE_PRINT(...) {}
+
982  #define RADIOLIB_VERBOSE_PRINTLN(...) {}
+
983 #endif
+
984 
+
988 #define RADIOLIB_ASSERT(STATEVAR) { if((STATEVAR) != RADIOLIB_ERR_NONE) { return(STATEVAR); } }
989 
-
990 // version definitions
-
991 #define RADIOLIB_VERSION_MAJOR (0x05)
-
992 #define RADIOLIB_VERSION_MINOR (0x01)
-
993 #define RADIOLIB_VERSION_PATCH (0x02)
-
994 #define RADIOLIB_VERSION_EXTRA (0x00)
-
995 
-
996 #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA))
-
997 
-
998 #endif
+
990 /*
+
991  * Macros that create callback for the hardware abstraction layer.
+
992  *
+
993  * This is the most evil thing I have ever created. I am deeply sorry to anyone currently reading this text.
+
994  * Come one, come all and witness the horror:
+
995  * Variadics, forced expansions, inlined function, string concatenation, and it even messes up access specifiers.
+
996  */
+
997 #define RADIOLIB_FIRST(arg, ...) arg
+
998 #define RADIOLIB_REST(arg, ...) __VA_ARGS__
+
999 #define RADIOLIB_EXP(...) __VA_ARGS__
+
1000 
+
1001 #define RADIOLIB_GENERATE_CALLBACK_RET_FUNC(RET, FUNC, ...) public: typedef RET (*FUNC##_cb_t)(__VA_ARGS__); void setCb_##FUNC(FUNC##_cb_t cb) { cb_##FUNC = cb; }; private: FUNC##_cb_t cb_##FUNC;
+
1002 #define RADIOLIB_GENERATE_CALLBACK_RET(RET, ...) RADIOLIB_GENERATE_CALLBACK_RET_FUNC(RET, __VA_ARGS__)
+
1003 #define RADIOLIB_GENERATE_CALLBACK(CB) RADIOLIB_GENERATE_CALLBACK_RET(RADIOLIB_EXP(RADIOLIB_FIRST CB), RADIOLIB_EXP(RADIOLIB_REST CB))
+
1004 
+
1005 #define RADIOLIB_GENERATE_CALLBACK_SPI_RET_FUNC(RET, FUNC, ...) public: typedef RET (Module::*FUNC##_cb_t)(__VA_ARGS__); void setCb_##FUNC(FUNC##_cb_t cb) { cb_##FUNC = cb; }; private: FUNC##_cb_t cb_##FUNC;
+
1006 #define RADIOLIB_GENERATE_CALLBACK_SPI_RET(RET, ...) RADIOLIB_GENERATE_CALLBACK_SPI_RET_FUNC(RET, __VA_ARGS__)
+
1007 #define RADIOLIB_GENERATE_CALLBACK_SPI(CB) RADIOLIB_GENERATE_CALLBACK_SPI_RET(RADIOLIB_EXP(RADIOLIB_FIRST CB), RADIOLIB_EXP(RADIOLIB_REST CB))
+
1008 
+
1012 #if defined(RADIOLIB_CHECK_PARAMS)
+
1013  #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) { if(!(((VAR) >= (MIN)) && ((VAR) <= (MAX)))) { return(ERR); } }
+
1014 #else
+
1015  #define RADIOLIB_CHECK_RANGE(VAR, MIN, MAX, ERR) {}
+
1016 #endif
+
1017 
+
1018 #if defined(RADIOLIB_FIX_ERRATA_SX127X)
+
1019  #define RADIOLIB_ERRATA_SX127X(...) { errataFix(__VA_ARGS__); }
+
1020 #else
+
1021  #define RADIOLIB_ERRATA_SX127X(...) {}
+
1022 #endif
+
1023 
+
1024 // version definitions
+
1025 #define RADIOLIB_VERSION_MAJOR (0x05)
+
1026 #define RADIOLIB_VERSION_MINOR (0x01)
+
1027 #define RADIOLIB_VERSION_PATCH (0x02)
+
1028 #define RADIOLIB_VERSION_EXTRA (0x00)
+
1029 
+
1030 #define RADIOLIB_VERSION ((RADIOLIB_VERSION_MAJOR << 24) | (RADIOLIB_VERSION_MINOR << 16) | (RADIOLIB_VERSION_PATCH << 8) | (RADIOLIB_VERSION_EXTRA))
+
1031 
+
1032 #endif