Refactor lib RadioLib fixing ESP8266 panic

This commit is contained in:
Theo Arends 2024-03-28 14:04:17 +01:00
parent 7c52906a2e
commit ae7bed5acf
4 changed files with 21 additions and 24 deletions

View File

@ -189,7 +189,8 @@ void inline ArduinoHal::noTone(uint32_t pin) {
void inline ArduinoHal::yield() {
#if !defined(RADIOLIB_YIELD_UNSUPPORTED)
::yield();
// ::yield();
::delay(0);
#endif
}

View File

@ -289,8 +289,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
} else {
uint32_t start = this->hal->millis();
while(this->hal->digitalRead(this->gpioPin)) {
// this->hal->yield();
this->hal->delay(0);
this->hal->yield();
if(this->hal->millis() - start >= timeout) {
RADIOLIB_DEBUG_BASIC_PRINTLN("GPIO pre-transfer timeout, is it connected?");
#if !RADIOLIB_STATIC_ONLY
@ -317,8 +316,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
this->hal->delayMicroseconds(1);
uint32_t start = this->hal->millis();
while(this->hal->digitalRead(this->gpioPin)) {
// this->hal->yield();
this->hal->delay(0);
this->hal->yield();
if(this->hal->millis() - start >= timeout) {
RADIOLIB_DEBUG_BASIC_PRINTLN("GPIO post-transfer timeout, is it connected?");
#if !RADIOLIB_STATIC_ONLY
@ -391,13 +389,11 @@ void Module::waitForMicroseconds(uint32_t start, uint32_t len) {
}
this->TimerFlag = false;
while(!this->TimerFlag) {
// this->hal->yield();
this->hal->delay(0);
this->hal->yield();
}
#else
while(this->hal->micros() - start < len) {
// this->hal->yield();
this->hal->delay(0);
this->hal->yield();
}
#endif
}

View File

@ -256,8 +256,7 @@ int16_t SX126x::transmit(uint8_t* data, size_t len, uint8_t addr) {
// wait for packet transmission or timeout
uint32_t start = this->mod->hal->micros();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
// this->mod->hal->yield();
this->mod->hal->delay(0);
this->mod->hal->yield();
if(this->mod->hal->micros() - start > timeout) {
finishTransmit();
return(RADIOLIB_ERR_TX_TIMEOUT);
@ -308,8 +307,7 @@ int16_t SX126x::receive(uint8_t* data, size_t len) {
bool softTimeout = false;
uint32_t start = this->mod->hal->micros();
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
// this->mod->hal->yield();
this->mod->hal->delay(0);
this->mod->hal->yield();
// safety check, the timeout should be done by the radio
if(this->mod->hal->micros() - start > timeout) {
softTimeout = true;
@ -442,8 +440,7 @@ int16_t SX126x::scanChannel(uint8_t symbolNum, uint8_t detPeak, uint8_t detMin)
// wait for channel activity detected or timeout
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
// this->mod->hal->yield();
this->mod->hal->delay(0);
this->mod->hal->yield();
}
// check CAD result
@ -571,8 +568,7 @@ int16_t SX126x::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
// wait for BUSY to go low (= PA ramp up done)
while(this->mod->hal->digitalRead(this->mod->getGpio())) {
// this->mod->hal->yield();
this->mod->hal->delay(0);
this->mod->hal->yield();
}
return(state);
@ -2119,8 +2115,7 @@ int16_t SX126x::config(uint8_t modem) {
// wait for calibration completion
this->mod->hal->delay(5);
while(this->mod->hal->digitalRead(this->mod->getGpio())) {
// this->mod->hal->yield();
this->mod->hal->delay(0);
this->mod->hal->yield();
}
// check calibration result

View File

@ -4,8 +4,13 @@ Action to take in case of new release of RadioLib
20240327
1 - Remove folder `RadioLib\examples\NonArduino` (Fixes Github vulnerability alerts)
2 - Change in file `RadioLib\src\modules\SX126x\SX126x.cpp` all occurences of ``this->mod->hal->yield();`` into ``this->mod->hal->delay(0);`` (Fixes ESP8266 Panic core_esp8266_main.cpp:133 __yield)
3 - Change in file `RadioLib\src\Module.cpp` all occurences of ``this->hal->yield();`` into ``this->hal->delay(0);`` (Fixes ESP8266 Panic core_esp8266_main.cpp:133 __yield)
1 - Remove folder `\lib\lib_rfRadioLib\examples\NonArduino` (Fixes Github vulnerability alerts)
2 - Change in file `\lib\lib_rf\RadioLib\src\ArduinoHal.cpp` below function (Fixes ESP8266 Panic core_esp8266_main.cpp:133 __yield)
```
void inline ArduinoHal::yield() {
#if !defined(RADIOLIB_YIELD_UNSUPPORTED)
// ::yield();
::delay(0);
#endif
}
```