Skip to content

Commit d968435

Browse files
dok-netearlephilhower
authored andcommitted
Make delay() as overridable as yield() already is, and add overridable loop_end() (#6306)
* Make delay() overridable "weak" * Add pluggable loop_end() * Release tag 5.2.3 for SoftwareSerial
1 parent 2130f3e commit d968435

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

cores/esp8266/core_esp8266_main.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ extern "C" void optimistic_yield(uint32_t interval_us) {
121121
}
122122
}
123123

124+
extern "C" void __loop_end (void)
125+
{
126+
run_scheduled_functions();
127+
run_scheduled_recurrent_functions();
128+
}
129+
130+
extern "C" void loop_end (void) __attribute__ ((weak, alias("__loop_end")));
131+
124132
static void loop_wrapper() {
125133
static bool setup_done = false;
126134
preloop_update_frequency();
@@ -129,8 +137,7 @@ static void loop_wrapper() {
129137
setup_done = true;
130138
}
131139
loop();
132-
run_scheduled_functions();
133-
run_scheduled_recurrent_functions();
140+
loop_end();
134141
esp_schedule();
135142
}
136143

cores/esp8266/core_esp8266_wiring.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void delay_end(void* arg) {
4343
esp_schedule();
4444
}
4545

46-
void delay(unsigned long ms) {
46+
void __delay(unsigned long ms) {
4747
if(ms) {
4848
os_timer_setfn(&delay_timer, (os_timer_func_t*) &delay_end, 0);
4949
os_timer_arm(&delay_timer, ms, ONCE);
@@ -56,6 +56,8 @@ void delay(unsigned long ms) {
5656
}
5757
}
5858

59+
void delay(unsigned long ms) __attribute__ ((weak, alias("__delay")));
60+
5961
void micros_overflow_tick(void* arg) {
6062
(void) arg;
6163
uint32_t m = system_get_time();

0 commit comments

Comments
 (0)