diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index dfe67bc2..b5499504 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -16,7 +16,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po uint8_t i = 0; bool flagFound = false; while((i < 10) && !flagFound) { - uint8_t version = SPIreadRegister(CC1101_REG_VERSION); + int16_t version = getChipVersion(); if((version == CC1101_VERSION_CURRENT) || (version == CC1101_VERSION_LEGACY)) { flagFound = true; } else { @@ -28,7 +28,7 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po char buffHex[7]; sprintf(buffHex, "0x%04X", version); RADIOLIB_DEBUG_PRINT(buffHex); - RADIOLIB_DEBUG_PRINT(F(", expected 0x0014")); + RADIOLIB_DEBUG_PRINT(F(", expected 0x0004/0x0014")); RADIOLIB_DEBUG_PRINTLN(); #endif Module::delay(10); @@ -751,6 +751,11 @@ uint8_t CC1101::random() { return(randByte); } + +int16_t CC1101::getChipVersion() { + return(_mod->SPIgetRegValue(CC1101_REG_VERSION)); +} + int16_t CC1101::config() { // Reset the radio. Registers may be dirty from previous usage. SPIsendCommand(CC1101_CMD_RESET); diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 850df7ac..51432c1a 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -882,6 +882,13 @@ class CC1101: public PhysicalLayer { */ uint8_t random(); + /*! + \brief Read version SPI register. Should return CC1101_VERSION_LEGACY (0x04) or CC1101_VERSION_CURRENT (0x14) if CC1101 is connected and working. + + \returns Version register contents or \ref status_codes + */ + int16_t getChipVersion(); + #ifndef RADIOLIB_GODMODE private: #endif