From 9cff70de2e3c1d738c501963df169f4dffa87366 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 22 Apr 2026 07:41:37 +0200 Subject: [PATCH] Address Copilot review: add BK72xx static_assert, clarify ISR dispatch comment --- esphome/components/libretiny/core.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/esphome/components/libretiny/core.cpp b/esphome/components/libretiny/core.cpp index 1d7cb6ff600..eb749a828cb 100644 --- a/esphome/components/libretiny/core.cpp +++ b/esphome/components/libretiny/core.cpp @@ -19,8 +19,9 @@ void HOT yield() { ::yield(); } // Skip the Arduino core's ::millis() wrapper so the public esphome::millis() is // inlinable at its call sites and matches MillisInternal::get()'s fast path. // IRAM_ATTR is kept because components (e.g. rotary_encoder) call millis() from -// ISR handlers; xTaskGetTickCountFromISR() is used in ISR context to satisfy the -// FreeRTOS API contract. +// ISR handlers. On RTL87xx / LN882x, millis() dispatches to xTaskGetTickCountFromISR() +// in ISR context to satisfy the FreeRTOS API contract; on BK72xx it intentionally +// matches the Arduino core's wiring.c and always uses xTaskGetTickCount(). // // RTL87xx and LN882x run FreeRTOS at 1 kHz, so xTaskGetTickCount() is already in // milliseconds. BK72xx runs at 500 Hz — multiply by portTICK_PERIOD_MS (== 2) to @@ -32,7 +33,7 @@ uint32_t IRAM_ATTR HOT millis() { } #elif defined(USE_BK72XX) uint32_t IRAM_ATTR HOT millis() { - // BK72xx's Arduino millis() does not dispatch on ISR context; match that. + static_assert(configTICK_RATE_HZ == 500, "BK72xx millis() fast path assumes 500 Hz FreeRTOS tick"); return xTaskGetTickCount() * portTICK_PERIOD_MS; } #else