diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index a7e5ca23b..dbde309fb 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -212,16 +212,11 @@ extern "C" uint8 system_get_cpu_freq(void); void __optimistic_yield(uint32_t intvl_cycles); -void inline optimistic_yield(uint32_t interval_us) __attribute__((always_inline)); -void inline optimistic_yield(uint32_t interval_us) { - __optimistic_yield(interval_us * #if defined(F_CPU) - clockCyclesPerMicrosecond() +#define optimistic_yield(interval_us) (__optimistic_yield(interval_us * clockCyclesPerMicrosecond())) #else - getCpuFreqMHz() +#define optimistic_yield(interval_us) (__optimistic_yield(interval_us * getCpuFreqMHz())) #endif - ); -} #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 48a20dd1f..2037d2535 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -133,6 +133,17 @@ 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)