mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Merge pull request #6869 from dok-net/refactooptimisticyield
Minor yield() cleanup: optimistic_yield, proper polledTimeout use
This commit is contained in:
commit
d7d03f9a41
@ -146,7 +146,6 @@ unsigned long HardwareSerial::detectBaudrate(time_t timeoutMillis)
|
|||||||
if ((detectedBaudrate = testBaudrate())) {
|
if ((detectedBaudrate = testBaudrate())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
yield();
|
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
return detectedBaudrate;
|
return detectedBaudrate;
|
||||||
|
@ -54,7 +54,7 @@ void hexdump(const void *mem, uint32_t len, uint8_t cols)
|
|||||||
}
|
}
|
||||||
src += linesize;
|
src += linesize;
|
||||||
len -= linesize;
|
len -= linesize;
|
||||||
yield();
|
optimistic_yield(10000);
|
||||||
}
|
}
|
||||||
os_printf("\n");
|
os_printf("\n");
|
||||||
}
|
}
|
||||||
|
@ -431,10 +431,10 @@ int8_t ESP8266WiFiSTAClass::waitForConnectResult(unsigned long timeoutLength) {
|
|||||||
if((wifi_get_opmode() & 1) == 0) {
|
if((wifi_get_opmode() & 1) == 0) {
|
||||||
return WL_DISCONNECTED;
|
return WL_DISCONNECTED;
|
||||||
}
|
}
|
||||||
using esp8266::polledTimeout::oneShot;
|
// if probing doesn't trip, this yields
|
||||||
oneShot timeout(timeoutLength); // number of milliseconds to wait before returning timeout error
|
using oneShotYieldMs = esp8266::polledTimeout::timeoutTemplate<false, esp8266::polledTimeout::YieldPolicy::YieldOrSkip>;
|
||||||
|
oneShotYieldMs timeout(timeoutLength); // number of milliseconds to wait before returning timeout error
|
||||||
while(!timeout) {
|
while(!timeout) {
|
||||||
yield();
|
|
||||||
if(status() != WL_DISCONNECTED) {
|
if(status() != WL_DISCONNECTED) {
|
||||||
return status();
|
return status();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user