Skip to content

Commit 9968a62

Browse files
committed
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.
1 parent 426884e commit 9968a62

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: cores/esp8266/PolledTimeout.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct TimeSourceCycles
7676

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

Diff for: cores/esp8266/core_esp8266_main.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ void initVariant() {
8484
extern "C" void __preloop_update_frequency() {
8585
#if defined(F_CPU) && (F_CPU == 160000000L)
8686
ets_update_cpu_frequency(160);
87-
REG_SET_BIT(0x3ff00014, BIT(0));
87+
CPU2X |= 1;
8888
#elif !defined(F_CPU)
89-
if (system_get_cpu_freq() == 160) REG_SET_BIT(0x3ff00014, BIT(0));
89+
if (system_get_cpu_freq() == 160) {
90+
CPU2X |= 1;
91+
}
9092
#endif
9193
}
9294

0 commit comments

Comments
 (0)