8000 Use F_CPU if (?) CPU frequency switch is compile-time only by dok-net · Pull Request #6833 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Use F_CPU if (?) CPU frequency switch is compile-time only #6833

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 10 commits into from
Apr 15, 2020
Merged
Prev Previous commit
Next Next commit
Prepare for runtime CPU clock rate selection
  • Loading branch information
dok-net committed Apr 11, 2020
commit 689187fc31122022243483f7613f47ab1f531e7f
4 changes: 4 additions & 0 deletions cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ class EspClass {

uint8_t EspClass::getCpuFreqMHz()
{
#if defined(F_CPU)
return clockCyclesPerMicrosecond();
#elif !defined(F_CPU)
return system_get_cpu_freq();
#endif
}

uint32_t EspClass::getCycleCount()
Expand Down
9 changes: 6 additions & 3 deletions cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,17 @@ void initVariant() __attribute__((weak));
void initVariant() {
}

void preloop_update_frequency() __attribute__((weak));
void preloop_update_frequency() {
extern "C" void __preloop_update_frequency() {
#if defined(F_CPU) && (F_CPU == 160000000L)
REG_SET_BIT(0x3ff00014, BIT(0));
ets_update_cpu_frequency(160);
REG_SET_BIT(0x3ff00014, BIT(0));
#elif !defined(F_CPU)
if (system_get_cpu_freq() == 160) REG_SET_BIT(0x3ff00014, BIT(0));
#endif
}

extern "C" void preloop_update_frequency() __attribute__((weak, alias("__preloop_update_frequency")));

extern "C" bool can_yield() {
return cont_can_yield( 42BD g_pcont);
}
Expand Down
0