Skip to content

Add wait loop at the end of mode, refactor can_yield #6721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ void preloop_update_frequency() {
#endif
}

extern "C" bool can_yield() {
return cont_can_yield(g_pcont);
}

static inline void esp_yield_within_cont() __attribute__((always_inline));
static void esp_yield_within_cont() {
Expand All @@ -98,7 +101,7 @@ static void esp_yield_within_cont() {
}

extern "C" void esp_yield() {
if (cont_can_yield(g_pcont)) {
if (can_yield()) {
esp_yield_within_cont();
}
}
Expand All @@ -109,7 +112,7 @@ extern "C" void esp_schedule() {
}

extern "C" void __yield() {
if (cont_can_yield(g_pcont)) {
if (can_yield()) {
esp_schedule();
esp_yield_within_cont();
}
Expand All @@ -121,7 +124,7 @@ extern "C" void __yield() {
extern "C" void yield(void) __attribute__ ((weak, alias("__yield")));

extern "C" void optimistic_yield(uint32_t interval_us) {
if (cont_can_yield(g_pcont) &&
if (can_yield() &&
(system_get_time() - s_micros_at_task_start) > interval_us)
{
yield();
Expand Down
1 change: 1 addition & 0 deletions cores/esp8266/coredecls.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern "C" {

extern bool timeshift64_is_set;

bool can_yield();
void esp_yield();
void esp_schedule();
void tune_timeshift64 (uint64_t now_us);
Expand Down
Loading