Use F_CPU if (?) CPU frequency switch is compile-time only by dok-net · Pull Request #6833 · esp8266/Arduino (original) (raw)

Then ESP.getCpuFreqMHz() can be optimized to use F_CPU and be constexpr.
polledTimeout using F_CPU instead of the dynamic system_get_cpu_freq() anyway, I see no issue.

On review, please consider this, in core_esp8266_main.cpp:

void preloop_update_frequency() __attribute__((weak));
void preloop_update_frequency() {
#if defined(F_CPU) && (F_CPU == 160000000L)
    REG_SET_BIT(0x3ff00014, BIT(0));
    ets_update_cpu_frequency(160);
#endif

Could this be turned into dynamic frequency switching?