Skip to content

Commit 50fab51

Browse files
committed
No need for preprocessor undefinition of optimistic_yield, after all.
1 parent 8d2eca5 commit 50fab51

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

cores/esp8266/Arduino.h

+1-12
Original file line numberDiff line numberDiff line change
@@ -205,18 +205,7 @@ void loop(void);
205205

206206
void yield(void);
207207

208-
#ifndef F_CPU
209-
// single function needed from SDK user_interface.h
210-
extern "C" uint8 system_get_cpu_freq(void);
211-
#endif
212-
213-
void __optimistic_yield(uint32_t intvl_cycles);
214-
215-
#if defined(F_CPU)
216-
#define optimistic_yield(interval_us) (__optimistic_yield(interval_us * clockCyclesPerMicrosecond()))
217-
#else
218-
#define optimistic_yield(interval_us) (__optimistic_yield(interval_us * getCpuFreqMHz()))
219-
#endif
208+
void optimistic_yield(uint32_t interval_us);
220209

221210
#define _PORT_GPIO16 1
222211
#define digitalPinToPort(pin) (((pin)==16)?(_PORT_GPIO16):(0))

cores/esp8266/core_esp8266_main.cpp

+7-12
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,20 @@ extern "C" void __yield() {
124124

125125
extern "C" void yield(void) __attribute__ ((weak, alias("__yield")));
126126

127-
extern "C" void __optimistic_yield(uint32_t intvl_cycles) {
127+
extern "C" void optimistic_yield(uint32_t interval_us) {
128+
const uint32_t intvl_cycles = interval_us *
129+
#if defined(F_CPU)
130+
clockCyclesPerMicrosecond();
131+
#else
132+
getCpuFreqMHz();
133+
#endif
128134
if ((ESP.getCycleCount() - s_cycles_since_yield_start) > intvl_cycles &&
129135
can_yield())
130136
{
131137
yield();
132138
}
133139
}
134140

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

0 commit comments

Comments
 (0)