diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index b47c522e..8ddf23b1 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -18,8 +18,8 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe reset(); // check version register - uint8_t version = _mod->SPIreadRegister(RF69_REG_VERSION); - if(version == 0x24) { + int16_t version = getChipVersion(); + if(version == RF69_CHIP_VERSION) { flagFound = true; } else { #ifdef RADIOLIB_DEBUG @@ -783,6 +783,10 @@ uint8_t RF69::random() { return(randByte); } +int16_t RF69::getChipVersion() { + return(_mod->SPIgetRegValue(RF69_REG_VERSION)); +} + int16_t RF69::config() { int16_t state = ERR_NONE; diff --git a/src/modules/RF69/RF69.h b/src/modules/RF69/RF69.h index 0c2294a2..e2c1d0a1 100644 --- a/src/modules/RF69/RF69.h +++ b/src/modules/RF69/RF69.h @@ -162,6 +162,9 @@ // RF69_REG_LISTEN_3 #define RF69_LISTEN_COEF_RX 0x20 // 7 0 duration of Rx phase in Listen mode +// RF69_REG_VERSION +#define RF69_CHIP_VERSION 0x24 // 7 0 + // RF69_REG_PA_LEVEL #define RF69_PA0_OFF 0b00000000 // 7 7 PA0 disabled #define RF69_PA0_ON 0b10000000 // 7 7 PA0 enabled (default) @@ -827,6 +830,13 @@ class RF69: public PhysicalLayer { */ uint8_t random(); + /*! + \brief Read version SPI register. Should return RF69_CHIP_VERSION (0x24) if SX127x is connected and working. + + \returns Version register contents or \ref status_codes + */ + int16_t getChipVersion(); + #ifndef RADIOLIB_GODMODE protected: #endif