Skip to content

Commit 5544357

Browse files
committed
Due to 3rd party use of symbol optimistic_yield without #include <Arduino>, have to resort to preprocessor definition for inlining.
1 parent 3767791 commit 5544357

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

cores/esp8266/Arduino.h

+2-7
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,11 @@ extern "C" uint8 system_get_cpu_freq(void);
212212

213213
void __optimistic_yield(uint32_t intvl_cycles);
214214

215-
void inline optimistic_yield(uint32_t interval_us) __attribute__((always_inline));
216-
void inline optimistic_yield(uint32_t interval_us) {
217-
__optimistic_yield(interval_us *
218215
#if defined(F_CPU)
219-
clockCyclesPerMicrosecond()
216+
#define optimistic_yield(interval_us) (__optimistic_yield(interval_us * clockCyclesPerMicrosecond()))
220217
#else
221-
getCpuFreqMHz()
218+
#define optimistic_yield(interval_us) (__optimistic_yield(interval_us * getCpuFreqMHz()))
222219
#endif
223-
);
224-
}
225220

226221
#define _PORT_GPIO16 1
227222
#define digitalPinToPort(pin) (((pin)==16)?(_PORT_GPIO16):(0))

cores/esp8266/core_esp8266_main.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ extern "C" void __optimistic_yield(uint32_t intvl_cycles) {
133133
}
134134
}
135135

136+
#undef optimistic_yield
137+
extern "C" void optimistic_yield(uint32_t interval_us) {
138+
__optimistic_yield(interval_us *
139+
#if defined(F_CPU)
140+
clockCyclesPerMicrosecond()
141+
#else
142+
getCpuFreqMHz()
143+
#endif
144+
);
145+
}
146+
136147
// Replace ets_intr_(un)lock with nestable versions
137148
extern "C" void IRAM_ATTR ets_intr_lock() {
138149
if (ets_intr_lock_stack_ptr < ETS_INTR_LOCK_NEST_MAX)

0 commit comments

Comments
 (0)