diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 05d8d4cb..8122f727 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -410,6 +410,20 @@ */ #define RADIOLIB_CHECK_PARAMS +/* + * 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. + */ +//#define RADIOLIB_FIX_ERRATA_SX127X + +#if defined(RADIOLIB_FIX_ERRATA_SX127X) + #define RADIOLIB_ERRATA_SX127X(...) { errataFix(__VA_ARGS__); } +#else + #define RADIOLIB_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. diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 354b72b4..b0f1f8ab 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -324,7 +324,7 @@ int16_t SX127x::transmitDirect(uint32_t frf) { RADIOLIB_ASSERT(state); // apply fixes to errata - errataFix(false); + RADIOLIB_ERRATA_SX127X(false); // start transmitting return(setMode(SX127X_TX)); @@ -344,7 +344,7 @@ int16_t SX127x::receiveDirect() { RADIOLIB_ASSERT(state); // apply fixes to errata - errataFix(true); + RADIOLIB_ERRATA_SX127X(true); // start receiving return(setMode(SX127X_RX)); @@ -392,7 +392,7 @@ int16_t SX127x::startReceive(uint8_t len, uint8_t mode) { } // apply fixes to errata - errataFix(true); + RADIOLIB_ERRATA_SX127X(true); // clear interrupt flags clearIRQFlags(); @@ -460,7 +460,7 @@ int16_t SX127x::startTransmit(uint8_t* data, size_t len, uint8_t addr) { _mod->SPIsetRegValue(SX127X_REG_DIO_MAPPING_1, SX127X_DIO0_TX_DONE, 7, 6); // apply fixes to errata - errataFix(false); + RADIOLIB_ERRATA_SX127X(false); // clear interrupt flags clearIRQFlags();