diff options
Diffstat (limited to 'esp8266/ets_alt_task.c')
-rw-r--r-- | esp8266/ets_alt_task.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/esp8266/ets_alt_task.c b/esp8266/ets_alt_task.c index 62872affb9..6434f23660 100644 --- a/esp8266/ets_alt_task.c +++ b/esp8266/ets_alt_task.c @@ -87,7 +87,7 @@ bool ets_post(uint8 prio, os_signal_t sig, os_param_t param) { if (emu_tasks[id].i_put == -1) { // queue is full printf("ets_post: task %d queue full\n", prio); - return false; + return 1; } q = &q[emu_tasks[id].i_put++]; q->sig = sig; @@ -104,16 +104,28 @@ bool ets_post(uint8 prio, os_signal_t sig, os_param_t param) { ets_intr_unlock(); - return true; + return 0; #endif } int ets_loop_iter_disable = 0; +// to implement a 64-bit wide microsecond counter +static uint32_t system_time_prev = 0; +uint32_t system_time_high_word = 0; + bool ets_loop_iter(void) { if (ets_loop_iter_disable) { return false; } + + // handle overflow of system microsecond counter + uint32_t system_time_cur = system_get_time(); + if (system_time_cur < system_time_prev) { + system_time_high_word += 1; // record overflow of low 32-bits + } + system_time_prev = system_time_cur; + //static unsigned cnt; bool progress = false; for (volatile struct task_entry *t = emu_tasks; t < &emu_tasks[MP_ARRAY_SIZE(emu_tasks)]; t++) { |