Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4df7186
delay0isyield squash commit.
dok-net Jan 1, 2021
b64622d
_notifyPWM may be called indirectly from ISR, cannot yield() from ISR…
dok-net Jan 10, 2021
9bb4894
Fix for 656a33e6f8
dok-net Mar 15, 2021
97d59ae
Consolidate renaming of identifiers to clarify strict meaning of susp…
dok-net Apr 8, 2021
08ed7d0
Non-recurring scheduled functions may yield, therefore run_scheduled_…
dok-net Apr 10, 2021
397408f
Add HAVE_ESP_SUSPEND define to allow 3rd party libraries to detect AP…
dok-net Apr 8, 2021
0bb470c
Merge branch 'esp_yield_mt' into delay0isyield
dok-net Apr 9, 2021
971ad28
Make detectBaudrate safe from SYS context, for what it's worth.
dok-net Apr 19, 2021
99ed6fc
Add comment about how optimistic_yield() is safe for SYS, like in cal…
dok-net Apr 19, 2021
cd8d2d3
Adapt logic to feed scheduled recurrent functions in hostByName from …
dok-net Jul 20, 2021
070eb48
Add clarifying comments to esp_suspend and esp_delay overloads.
dok-net Oct 6, 2021
d11be8b
Refactoring as seen in PR #8317
dok-net Oct 6, 2021
4b92d28
Removed redundant duplicate type definition.
dok-net Oct 7, 2021
208c4a3
Use function template syntax to save using std::function objects.
dok-net Oct 9, 2021
3720ac0
Fix uninitialized status for immediately expired timeout.
dok-net Oct 9, 2021
3be70a4
Specification for try_esp_delay added as code comment.
dok-net Oct 9, 2021
67ced12
Apply suggestions from code review
dok-net Oct 13, 2021
62af940
By review feedback, maintain esp_ as prefix.
dok-net Oct 13, 2021
863c482
Code cleanup as per review feedback.
dok-net Oct 13, 2021
679ecb1
Enable the startWaveform functions for calling from SYS context. Remo…
dok-net Oct 14, 2021
6199eb9
Adopt same code for host-test version of `esp_try_delay`.
dok-net Oct 14, 2021
7cfaeea
Merge branch 'master' into delay0isyield
dok-net Oct 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adopt same code for host-test version of esp_try_delay.
Fix in-source specification for the main `esp_try_delay`.
  • Loading branch information
dok-net committed Oct 14, 2021
commit 6199eb922c5265666a6ab108fe0bffc47dece0a0
9 changes: 5 additions & 4 deletions cores/esp8266/coredecls.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ inline void esp_suspend(T&& blocked) {
} while (blocked());
}

// Try to delay for timeout_ms relative to start_ms. Returns false if the delayed task
// is asynchronously resumed before the timeout is reached.
// Also returns false if intvl_ms have expired during the active call.
// Otherwise return true to indicate the timeout_ms have completely expired.
// Try to delay until timeout_ms has expired since start_ms.
// Returns true if timeout_ms has completely expired on entry.
// Otherwise returns false after delaying for the relative
// remainder of timeout_ms, or an absolute intvl_ms, whichever is shorter.
// The delay may be asynchronously cancelled, before that timeout is reached.
bool esp_try_delay(const uint32_t start_ms, const uint32_t timeout_ms, const uint32_t intvl_ms);

// This overload of esp_delay() delays for a duration of at most timeout_ms milliseconds.
Expand Down
8 changes: 3 additions & 5 deletions tests/host/common/Arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ extern "C" void esp_delay (unsigned long ms)
}

bool esp_try_delay(const uint32_t start_ms, const uint32_t timeout_ms, const uint32_t intvl_ms) {
decltype(millis()) expired;

if ((expired = millis() - start_ms) >= timeout_ms) {
uint32_t expired = millis() - start_ms;
if (expired >= timeout_ms) {
return true;
}
const auto remaining = timeout_ms - expired;
esp_delay(remaining <= intvl_ms ? remaining : intvl_ms);
esp_delay(std::min((timeout_ms - expired), intvl_ms));
return false;
}

Expand Down