[esp8266] Inline arch_get_cpu_cycle_count() and arch_get_cpu_freq_hz()

Both bodies are one-liners:

  arch_get_cpu_cycle_count()  -> esp_get_cycle_count()
  arch_get_cpu_freq_hz()       -> F_CPU

Move them inline in core/hal/hal_esp8266.h:
- esp_get_cycle_count() comes from <core_esp8266_features.h> (now
  pulled into hal_esp8266.h, small ESP8266-only header).
- F_CPU is a -DF_CPU=80000000L compiler flag from the ESP8266 Arduino
  board defs, available without any include.

Drop the cross-platform arch_get_cpu_freq_hz() declaration from the
dispatcher hal.h and add bare decls to hal_esp32.h / hal_libretiny.h /
hal_rp2040.h / hal_host.h / hal_zephyr.h so subsequent per-platform
follow-ups only touch their own platform header.
This commit is contained in:
J. Nick Koston
2026-04-29 05:59:38 -05:00
parent c0e2d443f0
commit bb76ee76ec
8 changed files with 13 additions and 8 deletions
-3
View File
@@ -97,9 +97,6 @@ void arch_restart() {
}
}
uint32_t IRAM_ATTR HOT arch_get_cpu_cycle_count() { return esp_get_cycle_count(); }
uint32_t arch_get_cpu_freq_hz() { return F_CPU; }
} // namespace esphome
// Linker wrap: redirect all ::millis() calls (Arduino libs, ISRs) to our accumulator.
+3 -3
View File
@@ -31,10 +31,10 @@
namespace esphome {
// Cross-platform declarations. delayMicroseconds(), arch_feed_wdt(),
// arch_get_cpu_cycle_count(), arch_init() vary per platform (some inline,
// some out-of-line) so they live in hal/hal_<platform>.h.
// arch_get_cpu_cycle_count(), arch_init(), arch_get_cpu_freq_hz() vary
// per platform (some inline, some out-of-line) so they live in
// hal/hal_<platform>.h.
void __attribute__((noreturn)) arch_restart();
uint32_t arch_get_cpu_freq_hz();
#ifndef USE_ESP8266
// All non-ESP8266 platforms: PROGMEM is a no-op, so these are direct dereferences.
+1
View File
@@ -43,6 +43,7 @@ __attribute__((always_inline)) inline void arch_feed_wdt() { esp_task_wdt_reset(
__attribute__((always_inline)) inline uint32_t arch_get_cpu_cycle_count() { return esp_cpu_get_cycle_count(); }
void arch_init();
uint32_t arch_get_cpu_freq_hz();
} // namespace esphome
+5 -2
View File
@@ -3,6 +3,7 @@
#ifdef USE_ESP8266
#include <c_types.h>
#include <core_esp8266_features.h>
#include <cstdint>
#include <pgmspace.h>
@@ -59,8 +60,10 @@ __attribute__((always_inline)) inline uint16_t progmem_read_uint16(const uint16_
__attribute__((always_inline)) inline void delayMicroseconds(uint32_t us) { delay_microseconds_safe(us); }
__attribute__((always_inline)) inline void arch_feed_wdt() { system_soft_wdt_feed(); }
__attribute__((always_inline)) inline void arch_init() {}
uint32_t arch_get_cpu_cycle_count();
// esp_get_cycle_count() declared in <core_esp8266_features.h>; F_CPU is a
// compiler-driven macro from the ESP8266 Arduino board defs (-DF_CPU=...).
__attribute__((always_inline)) inline uint32_t arch_get_cpu_cycle_count() { return esp_get_cycle_count(); }
__attribute__((always_inline)) inline uint32_t arch_get_cpu_freq_hz() { return F_CPU; }
} // namespace esphome
+1
View File
@@ -23,6 +23,7 @@ void delayMicroseconds(uint32_t us); // NOLINT(readability-identifier-naming)
void arch_feed_wdt();
uint32_t arch_get_cpu_cycle_count();
void arch_init();
uint32_t arch_get_cpu_freq_hz();
} // namespace esphome
+1
View File
@@ -92,6 +92,7 @@ void delayMicroseconds(uint32_t us); // NOLINT(readability-identifier-naming)
void arch_feed_wdt();
uint32_t arch_get_cpu_cycle_count();
void arch_init();
uint32_t arch_get_cpu_freq_hz();
} // namespace esphome
+1
View File
@@ -39,6 +39,7 @@ void delayMicroseconds(uint32_t us); // NOLINT(readability-identifier-naming)
void arch_feed_wdt();
uint32_t arch_get_cpu_cycle_count();
void arch_init();
uint32_t arch_get_cpu_freq_hz();
} // namespace esphome
+1
View File
@@ -23,6 +23,7 @@ void delayMicroseconds(uint32_t us); // NOLINT(readability-identifier-naming)
void arch_feed_wdt();
uint32_t arch_get_cpu_cycle_count();
void arch_init();
uint32_t arch_get_cpu_freq_hz();
} // namespace esphome