8000 Fix optimistic_yield to not yield on each call after x µs by dok-net · Pull Request #6804 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Fix optimistic_yield to not yield on each call after x µs #6804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 20, 2020
Merged
Prev Previous commit
Next Next commit
Due to 3rd party use of symbol optimistic_yield without #include <Ard…
…uino>, have to resort to preprocessor definition for inlining.
  • Loading branch information
dok-net committed Feb 5, 2020
commit 554435780b3db892d0002cec5e707ea3ec984532
9 changes: 2 additions & 7 deletions cores/esp8266/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 11 additions & 0 deletions cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
0