Skip to content

Commit

Permalink
[Si443x] Added method to read version register
Browse files Browse the repository at this point in the history
  • Loading branch information
jgromes committed Nov 20, 2020
1 parent 3c83217 commit 36afff8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/modules/Si443x/Si443x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ uint8_t Si443x::random() {
return(randByte);
}

int16_t Si443x::getChipVersion() {
return(_mod->SPIgetRegValue(SI443X_REG_DEVICE_VERSION));
}

int16_t Si443x::setFrequencyRaw(float newFreq) {
// set mode to standby
int16_t state = standby();
Expand Down Expand Up @@ -605,7 +609,7 @@ bool Si443x::findChip() {
reset();

// check version register
uint8_t version = _mod->SPIreadRegister(SI443X_REG_DEVICE_VERSION);
int16_t version = getChipVersion();
if(version == SI443X_DEVICE_VERSION) {
flagFound = true;
} else {
Expand All @@ -614,8 +618,8 @@ bool Si443x::findChip() {
RADIOLIB_DEBUG_PRINT(i + 1);
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SI443X_REG_DEVICE_VERSION == "));

char buffHex[5];
sprintf(buffHex, "0x%02X", version);
char buffHex[12];
sprintf(buffHex, "0x%04X", version);
RADIOLIB_DEBUG_PRINT(buffHex);
RADIOLIB_DEBUG_PRINT(F(", expected 0x00"));
RADIOLIB_DEBUG_PRINTLN(SI443X_DEVICE_VERSION, HEX);
Expand Down
7 changes: 7 additions & 0 deletions src/modules/Si443x/Si443x.h
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,13 @@ class Si443x: public PhysicalLayer {
*/
uint8_t random();

/*!
\brief Read version SPI register. Should return SI443X_DEVICE_VERSION (0x06) if Si443x is connected and working.
\returns Version register contents or \ref status_codes
*/
int16_t getChipVersion();

#ifndef RADIOLIB_GODMODE
protected:
#endif
Expand Down

0 comments on commit 36afff8

Please sign in to comment.