[Si443x] Added method to read version register
This commit is contained in:
parent
3c832171f0
commit
36afff855d
2 changed files with 14 additions and 3 deletions
|
@ -572,6 +572,10 @@ uint8_t Si443x::random() {
|
||||||
return(randByte);
|
return(randByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t Si443x::getChipVersion() {
|
||||||
|
return(_mod->SPIgetRegValue(SI443X_REG_DEVICE_VERSION));
|
||||||
|
}
|
||||||
|
|
||||||
int16_t Si443x::setFrequencyRaw(float newFreq) {
|
int16_t Si443x::setFrequencyRaw(float newFreq) {
|
||||||
// set mode to standby
|
// set mode to standby
|
||||||
int16_t state = standby();
|
int16_t state = standby();
|
||||||
|
@ -605,7 +609,7 @@ bool Si443x::findChip() {
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
// check version register
|
// check version register
|
||||||
uint8_t version = _mod->SPIreadRegister(SI443X_REG_DEVICE_VERSION);
|
int16_t version = getChipVersion();
|
||||||
if(version == SI443X_DEVICE_VERSION) {
|
if(version == SI443X_DEVICE_VERSION) {
|
||||||
flagFound = true;
|
flagFound = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -614,8 +618,8 @@ bool Si443x::findChip() {
|
||||||
RADIOLIB_DEBUG_PRINT(i + 1);
|
RADIOLIB_DEBUG_PRINT(i + 1);
|
||||||
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SI443X_REG_DEVICE_VERSION == "));
|
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) SI443X_REG_DEVICE_VERSION == "));
|
||||||
|
|
||||||
char buffHex[5];
|
char buffHex[12];
|
||||||
sprintf(buffHex, "0x%02X", version);
|
sprintf(buffHex, "0x%04X", version);
|
||||||
RADIOLIB_DEBUG_PRINT(buffHex);
|
RADIOLIB_DEBUG_PRINT(buffHex);
|
||||||
RADIOLIB_DEBUG_PRINT(F(", expected 0x00"));
|
RADIOLIB_DEBUG_PRINT(F(", expected 0x00"));
|
||||||
RADIOLIB_DEBUG_PRINTLN(SI443X_DEVICE_VERSION, HEX);
|
RADIOLIB_DEBUG_PRINTLN(SI443X_DEVICE_VERSION, HEX);
|
||||||
|
|
|
@ -792,6 +792,13 @@ class Si443x: public PhysicalLayer {
|
||||||
*/
|
*/
|
||||||
uint8_t random();
|
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
|
#ifndef RADIOLIB_GODMODE
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue