Skip to content

Commit cb44d52

Browse files
committed
Two-level hook system for esp_yield to accommodate host test environment
1 parent 44714a9 commit cb44d52

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

cores/esp8266/core_esp8266_main.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,15 @@ void preloop_update_frequency() {
8888
#endif
8989
}
9090

91-
extern "C" void esp_yield() __attribute__((weak));
92-
extern "C" void esp_yield() {
91+
extern "C" void __esp_yield() __attribute__((weak));
92+
extern "C" void __esp_yield() {
9393
if (cont_can_yield(g_pcont)) {
9494
cont_yield(g_pcont);
9595
}
9696
}
9797

98+
extern "C" void esp_yield(void) __attribute__ ((weak, alias("__esp_yield")));
99+
98100
extern "C" void esp_schedule() {
99101
// always on CONT stack here
100102
ets_post(LOOP_TASK_PRIORITY, 0, 0);

libraries/Schedule/src/Schedule.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@
66
#include <interrupts.h>
77
#include <coredecls.h>
88

9-
extern "C" void esp_loop()
9+
extern "C"
1010
{
11-
loop();
12-
run_scheduled_functions();
13-
run_scheduled_recurrent_functions();}
11+
void esp_loop()
12+
{
13+
loop();
14+
run_scheduled_functions();
15+
run_scheduled_recurrent_functions();
16+
}
1417

15-
extern "C" void esp_yield()
16-
{
17-
if (cont_can_yield(g_pcont)) {
18-
cont_yield(g_pcont);
18+
void __esp_yield();
19+
20+
extern "C" void esp_yield()
21+
{
22+
__esp_yield();
23+
run_scheduled_recurrent_functions();
1924
}
20-
run_scheduled_recurrent_functions();
2125
}
2226

2327
typedef std::function<void(void)> mSchedFuncT;

tests/host/common/Arduino.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extern "C" void optimistic_yield (uint32_t interval_us)
4242
usleep(interval_us);
4343
}
4444

45-
extern "C" void esp_yield()
45+
extern "C" void __esp_yield()
4646
{
4747
}
4848

0 commit comments

Comments
 (0)