From 9c5d1a7fed048e4d4be3171c92dffaab8d217fdc Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 29 Apr 2026 07:17:37 -0500 Subject: [PATCH] [libretiny] Inline delayMicroseconds() in hal_libretiny.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wrapper is a one-liner forwarding to Arduino's ::delayMicroseconds. Add the forward decl to the existing NOLINTBEGIN block (alongside yield, delay, micros, millis) and inline the body — same pattern as the other Arduino-flavored wrappers in this header. Drops the out-of-line copy from components/libretiny/hal.cpp. --- esphome/components/libretiny/hal.cpp | 7 +++---- esphome/core/hal/hal_libretiny.h | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/esphome/components/libretiny/hal.cpp b/esphome/components/libretiny/hal.cpp index 4e94d5242b..e6dbb7296c 100644 --- a/esphome/components/libretiny/hal.cpp +++ b/esphome/components/libretiny/hal.cpp @@ -14,10 +14,9 @@ namespace esphome::libretiny {} // namespace esphome::libretiny namespace esphome { -// yield(), delay(), micros(), millis(), millis_64(), arch_feed_wdt(), -// arch_get_cpu_cycle_count(), arch_get_cpu_freq_hz() inlined in -// core/hal/hal_libretiny.h. -void IRAM_ATTR HOT delayMicroseconds(uint32_t us) { ::delayMicroseconds(us); } +// yield(), delay(), micros(), millis(), millis_64(), delayMicroseconds(), +// arch_feed_wdt(), arch_get_cpu_cycle_count(), arch_get_cpu_freq_hz() +// inlined in core/hal/hal_libretiny.h. void arch_init() { libretiny::setup_preferences(); diff --git a/esphome/core/hal/hal_libretiny.h b/esphome/core/hal/hal_libretiny.h index e519698ce0..db0fc11bfb 100644 --- a/esphome/core/hal/hal_libretiny.h +++ b/esphome/core/hal/hal_libretiny.h @@ -51,6 +51,7 @@ extern "C" void yield(void); extern "C" void delay(unsigned long ms); extern "C" unsigned long micros(void); extern "C" unsigned long millis(void); +extern "C" void delayMicroseconds(unsigned int us); // NOLINTEND(google-runtime-int,readability-identifier-naming,readability-redundant-declaration) // Forward decls from libretiny's family for the inline arch_* @@ -95,11 +96,12 @@ __attribute__((always_inline)) inline uint32_t millis() { return static_cast