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
Use defines for register CPU2X instead of hex value
Prepare PolledTimeout for dynamic CPU frequency - would fail to compile if F_CPU is not defined, helps as marker that something needs to be done.
  • Loading branch information
dok-net committed Apr 11, 2020
commit 9968a629f88b1beef0d980c73d26b3eee6e16156
2 changes: 1 addition & 1 deletion cores/esp8266/PolledTimeout.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct TimeSourceCycles

using timeType = decltype(ESP.getCycleCount());
static timeType time() {return ESP.getCycleCount();}
static constexpr timeType ticksPerSecond = F_CPU; // 80'000'000 or 160'000'000 Hz
static constexpr timeType ticksPerSecond = ESP.getCpuFreqMHz() * 1000000UL; // 80'000'000 or 160'000'000 Hz
static constexpr timeType ticksPerSecondMax = 160000000; // 160MHz
};

Expand Down
6 changes: 4 additions & 2 deletions cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ void initVariant() {
extern "C" void __preloop_update_frequency() {
#if defined(F_CPU) && (F_CPU == 160000000L)
ets_update_cpu_frequency(160);
REG_SET_BIT(0x3ff00014, BIT(0));
CPU2X |= 1;
#elif !defined(F_CPU)
if (system_get_cpu_freq() == 160) REG_SET_BIT(0x3ff00014, BIT(0));
if (system_get_cpu_freq() == 160) {
CPU2X |= 1;
}
#endif
}

Expand Down
0