diff --git a/src/BuildOpt.h b/src/BuildOpt.h index f09f75a9..48ca539e 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -108,6 +108,7 @@ //#define RADIOLIB_EXCLUDE_MORSE //#define RADIOLIB_EXCLUDE_RTTY //#define RADIOLIB_EXCLUDE_SSTV + //#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE #else #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR)) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index bc188f43..e9e36700 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -890,6 +890,7 @@ int16_t CC1101::getChipVersion() { return(SPIgetRegValue(RADIOLIB_CC1101_REG_VERSION)); } +#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) void CC1101::setDirectAction(void (*func)(void)) { setGdo0Action(func); } @@ -897,6 +898,7 @@ void CC1101::setDirectAction(void (*func)(void)) { void CC1101::readBit(RADIOLIB_PIN_TYPE pin) { updateDirectBuffer((uint8_t)digitalRead(pin)); } +#endif int16_t CC1101::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) { if (pin > 2) diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index fd8cb621..a661107f 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -920,6 +920,7 @@ class CC1101: public PhysicalLayer { */ int16_t getChipVersion(); + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Set interrupt service routine function to call when data bit is receveid in direct mode. @@ -933,6 +934,7 @@ class CC1101: public PhysicalLayer { \param pin Pin on which to read. */ void readBit(RADIOLIB_PIN_TYPE pin); + #endif /*! \brief Configure DIO pin mapping to get a given signal on a DIO pin (if available). diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 82d47c18..9fc69ef2 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -895,6 +895,7 @@ uint8_t RF69::randomByte() { return(randByte); } +#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) void RF69::setDirectAction(void (*func)(void)) { setDio1Action(func); } @@ -902,15 +903,18 @@ void RF69::setDirectAction(void (*func)(void)) { void RF69::readBit(RADIOLIB_PIN_TYPE pin) { updateDirectBuffer((uint8_t)digitalRead(pin)); } +#endif int16_t RF69::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) { - if (pin > 5) - return RADIOLIB_ERR_INVALID_DIO_PIN; + if(pin > 5) { + return(RADIOLIB_ERR_INVALID_DIO_PIN); + } - if (pin < 4) + if(pin < 4) { return(_mod->SPIsetRegValue(RADIOLIB_RF69_REG_DIO_MAPPING_1, value, 7 - 2 * pin, 6 - 2 * pin)); - else - return(_mod->SPIsetRegValue(RADIOLIB_RF69_REG_DIO_MAPPING_2, value, 15 - 2 * pin, 14 - 2 * pin)); + } + + return(_mod->SPIsetRegValue(RADIOLIB_RF69_REG_DIO_MAPPING_2, value, 15 - 2 * pin, 14 - 2 * pin)); } int16_t RF69::getChipVersion() { diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index e7652e51..ef9969e2 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -985,6 +985,7 @@ class RF69: public PhysicalLayer { */ int16_t getChipVersion(); + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Set interrupt service routine function to call when data bit is receveid in direct mode. @@ -998,6 +999,7 @@ class RF69: public PhysicalLayer { \param pin Pin on which to read. */ void readBit(RADIOLIB_PIN_TYPE pin); + #endif /*! \brief Configure DIO pin mapping to get a given signal on a DIO pin (if available). diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 64161ea3..14868dd1 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1233,6 +1233,7 @@ uint8_t SX126x::randomByte() { return(randByte); } +#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) void SX126x::setDirectAction(void (*func)(void)) { // SX126x is unable to perform direct mode reception // this method is implemented only for PhysicalLayer compatibility @@ -1244,6 +1245,7 @@ void SX126x::readBit(RADIOLIB_PIN_TYPE pin) { // this method is implemented only for PhysicalLayer compatibility (void)pin; } +#endif int16_t SX126x::setTCXO(float voltage, uint32_t delay) { // set mode to standby diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index df2d2952..0c426566 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -928,6 +928,7 @@ class SX126x: public PhysicalLayer { */ uint8_t randomByte(); + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Dummy method, to ensure PhysicalLayer compatibility. @@ -941,6 +942,8 @@ class SX126x: public PhysicalLayer { \param pin Ignored. */ void readBit(RADIOLIB_PIN_TYPE pin); + #endif + #if !defined(RADIOLIB_GODMODE) protected: diff --git a/src/modules/SX127x/SX127x.cpp b/src/modules/SX127x/SX127x.cpp index 31396428..29980071 100644 --- a/src/modules/SX127x/SX127x.cpp +++ b/src/modules/SX127x/SX127x.cpp @@ -1493,6 +1493,7 @@ int16_t SX127x::invertIQ(bool invertIQ) { return(state); } +#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) void SX127x::setDirectAction(void (*func)(void)) { setDio1Action(func); } @@ -1500,6 +1501,7 @@ void SX127x::setDirectAction(void (*func)(void)) { void SX127x::readBit(RADIOLIB_PIN_TYPE pin) { updateDirectBuffer((uint8_t)digitalRead(pin)); } +#endif int16_t SX127x::setFHSSHoppingPeriod(uint8_t freqHoppingPeriod) { return(_mod->SPIsetRegValue(RADIOLIB_SX127X_REG_HOP_PERIOD, freqHoppingPeriod)); diff --git a/src/modules/SX127x/SX127x.h b/src/modules/SX127x/SX127x.h index 505abd6c..996776c9 100644 --- a/src/modules/SX127x/SX127x.h +++ b/src/modules/SX127x/SX127x.h @@ -557,8 +557,8 @@ #define RADIOLIB_SX127X_DIO5_PACK_PLL_LOCK 0b00010000 // 5 4 #define RADIOLIB_SX127X_DIO5_PACK_DATA 0b00100000 // 5 4 #define RADIOLIB_SX127X_DIO5_PACK_MODE_READY 0b00110000 // 5 4 -#define RADIOLIB_SX127X_DIO_MAP_PREAMBLE_DETECT 0b00000001 // 0 0 -#define RADIOLIB_SX127X_DIO_MAP_RSSI 0b00000000 // 0 0 +#define RADIOLIB_SX127X_DIO_MAP_PREAMBLE_DETECT 0b00000001 // 0 0 +#define RADIOLIB_SX127X_DIO_MAP_RSSI 0b00000000 // 0 0 // SX1272_REG_PLL_HOP + SX1278_REG_PLL_HOP #define RADIOLIB_SX127X_FAST_HOP_OFF 0b00000000 // 7 7 carrier frequency validated when FRF registers are written @@ -1163,6 +1163,7 @@ class SX127x: public PhysicalLayer { */ int16_t invertIQ(bool invertIQ); + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Set interrupt service routine function to call when data bit is receveid in direct mode. @@ -1176,6 +1177,7 @@ class SX127x: public PhysicalLayer { \param pin Pin on which to read. */ void readBit(RADIOLIB_PIN_TYPE pin); + #endif /*! \brief Sets the hopping period and enables FHSS diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index cf09f0bb..d61ce930 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -1243,6 +1243,7 @@ uint8_t SX128x::randomByte() { return(0); } +#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) void SX128x::setDirectAction(void (*func)(void)) { // SX128x is unable to perform direct mode reception // this method is implemented only for PhysicalLayer compatibility @@ -1254,6 +1255,7 @@ void SX128x::readBit(RADIOLIB_PIN_TYPE pin) { // this method is implemented only for PhysicalLayer compatibility (void)pin; } +#endif uint8_t SX128x::getStatus() { uint8_t data = 0; diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index f9df39e3..6e1a7894 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -812,6 +812,7 @@ class SX128x: public PhysicalLayer { */ uint8_t randomByte(); + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Dummy method, to ensure PhysicalLayer compatibility. @@ -825,6 +826,7 @@ class SX128x: public PhysicalLayer { \param pin Ignored. */ void readBit(RADIOLIB_PIN_TYPE pin); + #endif #if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) protected: diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index f033d0ec..fcd41876 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -589,6 +589,7 @@ int16_t Si443x::getChipVersion() { return(_mod->SPIgetRegValue(RADIOLIB_SI443X_REG_DEVICE_VERSION)); } +#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) void Si443x::setDirectAction(void (*func)(void)) { setIrqAction(func); } @@ -596,6 +597,7 @@ void Si443x::setDirectAction(void (*func)(void)) { void Si443x::readBit(RADIOLIB_PIN_TYPE pin) { updateDirectBuffer((uint8_t)digitalRead(pin)); } +#endif int16_t Si443x::fixedPacketLengthMode(uint8_t len) { return(Si443x::setPacketMode(RADIOLIB_SI443X_FIXED_PACKET_LENGTH_ON, len)); diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index 40feceef..2175be7c 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -802,6 +802,7 @@ class Si443x: public PhysicalLayer { */ int16_t getChipVersion(); + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Set interrupt service routine function to call when data bit is receveid in direct mode. @@ -815,6 +816,7 @@ class Si443x: public PhysicalLayer { \param pin Pin on which to read. */ void readBit(RADIOLIB_PIN_TYPE pin); + #endif /*! \brief Set modem in fixed packet length mode. diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index d767dbd3..3b90ba70 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -516,6 +516,7 @@ uint8_t nRF24::randomByte() { return(0); } +#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) void nRF24::setDirectAction(void (*func)(void)) { // nRF24 is unable to perform direct mode actions // this method is implemented only for PhysicalLayer compatibility @@ -527,6 +528,7 @@ void nRF24::readBit(RADIOLIB_PIN_TYPE pin) { // this method is implemented only for PhysicalLayer compatibility (void)pin; } +#endif void nRF24::clearIRQ() { // clear status bits diff --git a/src/modules/nRF24/nRF24.h b/src/modules/nRF24/nRF24.h index fead3bf1..8b6226dc 100644 --- a/src/modules/nRF24/nRF24.h +++ b/src/modules/nRF24/nRF24.h @@ -473,6 +473,7 @@ class nRF24: public PhysicalLayer { */ uint8_t randomByte(); + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Dummy method, to ensure PhysicalLayer compatibility. @@ -486,6 +487,7 @@ class nRF24: public PhysicalLayer { \param pin Ignored. */ void readBit(RADIOLIB_PIN_TYPE pin); + #endif #if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL) protected: diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.cpp b/src/protocols/PhysicalLayer/PhysicalLayer.cpp index f0e62cd0..71185909 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.cpp +++ b/src/protocols/PhysicalLayer/PhysicalLayer.cpp @@ -3,8 +3,10 @@ PhysicalLayer::PhysicalLayer(float freqStep, size_t maxPacketLength) { _freqStep = freqStep; _maxPacketLength = maxPacketLength; + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) _bufferBitPos = 0; _bufferWritePos = 0; + #endif } int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) { @@ -188,6 +190,7 @@ int16_t PhysicalLayer::startDirect() { return(state); } +#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) int16_t PhysicalLayer::available() { return(_bufferWritePos); } @@ -246,6 +249,7 @@ void PhysicalLayer::updateDirectBuffer(uint8_t bit) { } } } +#endif int16_t PhysicalLayer::setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value) { return(RADIOLIB_ERR_UNSUPPORTED); diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.h b/src/protocols/PhysicalLayer/PhysicalLayer.h index e67dd1e8..efee97fb 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.h +++ b/src/protocols/PhysicalLayer/PhysicalLayer.h @@ -261,6 +261,7 @@ class PhysicalLayer { */ int16_t startDirect(); + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) /*! \brief Set sync word to be used to determine start of packet in direct reception mode. @@ -299,6 +300,7 @@ class PhysicalLayer { \returns Byte from direct mode buffer. */ uint8_t read(); + #endif /*! \brief Configure DIO pin mapping to get a given signal on a DIO pin (if available). @@ -311,8 +313,10 @@ class PhysicalLayer { */ virtual int16_t setDIOMapping(RADIOLIB_PIN_TYPE pin, uint8_t value); +#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) protected: void updateDirectBuffer(uint8_t bit); +#endif #if !defined(RADIOLIB_GODMODE) private: @@ -320,6 +324,7 @@ class PhysicalLayer { float _freqStep; size_t _maxPacketLength; + #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) uint8_t _bufferBitPos; uint8_t _bufferWritePos; uint8_t _bufferReadPos; @@ -329,6 +334,7 @@ class PhysicalLayer { uint8_t _directSyncWordLen; uint32_t _directSyncWordMask; bool _gotSync; + #endif virtual Module* getMod() = 0;