[SX127x] Moved reset to chip detection loop
This commit is contained in:
parent
a4eeefada0
commit
cb5c8d6313
1 changed files with 10 additions and 4 deletions
|
@ -11,9 +11,6 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimi
|
||||||
Module::pinMode(_mod->getIrq(), INPUT);
|
Module::pinMode(_mod->getIrq(), INPUT);
|
||||||
Module::pinMode(_mod->getGpio(), INPUT);
|
Module::pinMode(_mod->getGpio(), INPUT);
|
||||||
|
|
||||||
// reset the module
|
|
||||||
reset();
|
|
||||||
|
|
||||||
// try to find the SX127x chip
|
// try to find the SX127x chip
|
||||||
if(!SX127x::findChip(chipVersion)) {
|
if(!SX127x::findChip(chipVersion)) {
|
||||||
RADIOLIB_DEBUG_PRINTLN(F("No SX127x found!"));
|
RADIOLIB_DEBUG_PRINTLN(F("No SX127x found!"));
|
||||||
|
@ -23,8 +20,13 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimi
|
||||||
RADIOLIB_DEBUG_PRINTLN(F("Found SX127x!"));
|
RADIOLIB_DEBUG_PRINTLN(F("Found SX127x!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set mode to standby
|
||||||
|
int16_t state = standby();
|
||||||
|
if(state != ERR_NONE) {
|
||||||
|
return(state);
|
||||||
|
}
|
||||||
|
|
||||||
// check active modem
|
// check active modem
|
||||||
int16_t state;
|
|
||||||
if(getActiveModem() != SX127X_LORA) {
|
if(getActiveModem() != SX127X_LORA) {
|
||||||
// set LoRa mode
|
// set LoRa mode
|
||||||
state = setActiveModem(SX127X_LORA);
|
state = setActiveModem(SX127X_LORA);
|
||||||
|
@ -1090,6 +1092,10 @@ bool SX127x::findChip(uint8_t ver) {
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
bool flagFound = false;
|
bool flagFound = false;
|
||||||
while((i < 10) && !flagFound) {
|
while((i < 10) && !flagFound) {
|
||||||
|
// reset the module
|
||||||
|
reset();
|
||||||
|
|
||||||
|
// check version register
|
||||||
uint8_t version = _mod->SPIreadRegister(SX127X_REG_VERSION);
|
uint8_t version = _mod->SPIreadRegister(SX127X_REG_VERSION);
|
||||||
if(version == ver) {
|
if(version == ver) {
|
||||||
flagFound = true;
|
flagFound = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue