[MOD] Added option to use SX126x without GPIO
This commit is contained in:
parent
efbec6b9d1
commit
6d54ea65db
1 changed files with 21 additions and 13 deletions
|
@ -246,12 +246,16 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ensure GPIO is low
|
// ensure GPIO is low
|
||||||
uint32_t start = this->hal->millis();
|
if(this->gpioPin == RADIOLIB_NC) {
|
||||||
while(this->hal->digitalRead(this->gpioPin)) {
|
this->hal->delay(1);
|
||||||
this->hal->yield();
|
} else {
|
||||||
if(this->hal->millis() - start >= timeout) {
|
uint32_t start = this->hal->millis();
|
||||||
RADIOLIB_DEBUG_PRINTLN("Timed out waiting for GPIO pin, is it connected?");
|
while(this->hal->digitalRead(this->gpioPin)) {
|
||||||
return(RADIOLIB_ERR_SPI_CMD_TIMEOUT);
|
this->hal->yield();
|
||||||
|
if(this->hal->millis() - start >= timeout) {
|
||||||
|
RADIOLIB_DEBUG_PRINTLN("Timed out waiting for GPIO pin, is it connected?");
|
||||||
|
return(RADIOLIB_ERR_SPI_CMD_TIMEOUT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,13 +316,17 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
|
||||||
|
|
||||||
// wait for GPIO to go high and then low
|
// wait for GPIO to go high and then low
|
||||||
if(waitForGpio) {
|
if(waitForGpio) {
|
||||||
this->hal->delayMicroseconds(1);
|
if(this->gpioPin == RADIOLIB_NC) {
|
||||||
uint32_t start = this->hal->millis();
|
this->hal->delay(1);
|
||||||
while(this->hal->digitalRead(this->gpioPin)) {
|
} else {
|
||||||
this->hal->yield();
|
this->hal->delayMicroseconds(1);
|
||||||
if(this->hal->millis() - start >= timeout) {
|
uint32_t start = this->hal->millis();
|
||||||
state = RADIOLIB_ERR_SPI_CMD_TIMEOUT;
|
while(this->hal->digitalRead(this->gpioPin)) {
|
||||||
break;
|
this->hal->yield();
|
||||||
|
if(this->hal->millis() - start >= timeout) {
|
||||||
|
state = RADIOLIB_ERR_SPI_CMD_TIMEOUT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue