diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index dbde309fb..f82b3aea9 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -205,18 +205,7 @@ void loop(void); void yield(void); -#ifndef F_CPU -// single function needed from SDK user_interface.h -extern "C" uint8 system_get_cpu_freq(void); -#endif - -void __optimistic_yield(uint32_t intvl_cycles); - -#if defined(F_CPU) -#define optimistic_yield(interval_us) (__optimistic_yield(interval_us * clockCyclesPerMicrosecond())) -#else -#define optimistic_yield(interval_us) (__optimistic_yield(interval_us * getCpuFreqMHz())) -#endif +void optimistic_yield(uint32_t interval_us); #define _PORT_GPIO16 1 #define digitalPinToPort(pin) (((pin)==16)?(_PORT_GPIO16):(0)) diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index c4be729fa..bbcfd29ef 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -124,7 +124,13 @@ extern "C" void __yield() { extern "C" void yield(void) __attribute__ ((weak, alias("__yield"))); -extern "C" void __optimistic_yield(uint32_t intvl_cycles) { +extern "C" void optimistic_yield(uint32_t interval_us) { + const uint32_t intvl_cycles = interval_us * +#if defined(F_CPU) + clockCyclesPerMicrosecond(); +#else + getCpuFreqMHz(); +#endif if ((ESP.getCycleCount() - s_cycles_since_yield_start) > intvl_cycles && can_yield()) { @@ -132,17 +138,6 @@ extern "C" void __optimistic_yield(uint32_t intvl_cycles) { } } -#undef optimistic_yield -extern "C" void optimistic_yield(uint32_t interval_us) { - __optimistic_yield(interval_us * -#if defined(F_CPU) - clockCyclesPerMicrosecond() -#else - getCpuFreqMHz() -#endif - ); -} - // Replace ets_intr_(un)lock with nestable versions extern "C" void IRAM_ATTR ets_intr_lock() { if (ets_intr_lock_stack_ptr < ETS_INTR_LOCK_NEST_MAX)