Skip to content

Make delay() as overridable as yield() already is, and add overridable loop_end() #6306

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 4 commits into from
Jul 18, 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
11 changes: 9 additions & 2 deletions cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ extern "C" void optimistic_yield(uint32_t interval_us) {
}
}

extern "C" void __loop_end (void)
{
run_scheduled_functions();
run_scheduled_recurrent_functions();
}

extern "C" void loop_end (void) __attribute__ ((weak, alias("__loop_end")));

static void loop_wrapper() {
static bool setup_done = false;
preloop_update_frequency();
Expand All @@ -129,8 +137,7 @@ static void loop_wrapper() {
setup_done = true;
}
loop();
run_scheduled_functions();
run_scheduled_recurrent_functions();
loop_end();
esp_schedule();
}

Expand Down
4 changes: 3 additions & 1 deletion cores/esp8266/core_esp8266_wiring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void delay_end(void* arg) {
esp_schedule();
}

void delay(unsigned long ms) {
void __delay(unsigned long ms) {
if(ms) {
os_timer_setfn(&delay_timer, (os_timer_func_t*) &delay_end, 0);
os_timer_arm(&delay_timer, ms, ONCE);
Expand All @@ -56,6 +56,8 @@ void delay(unsigned long ms) {
}
}

void delay(unsigned long ms) __attribute__ ((weak, alias("__delay")));

void micros_overflow_tick(void* arg) {
(void) arg;
uint32_t m = system_get_time();
Expand Down