mirror of
https://github.com/esphome/esphome.git
synced 2026-09-13 16:18:41 +00:00
Drop vestigial IRAM_ATTR from BK72xx millis(); SDK masks IRQ during flash ops
This commit is contained in:
@@ -18,21 +18,24 @@ namespace esphome {
|
||||
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. 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
|
||||
// convert ticks to milliseconds, matching the Arduino core's wiring.c.
|
||||
// milliseconds. IRAM_ATTR is kept on those families because components (e.g.
|
||||
// rotary_encoder) call millis() from ISR handlers, and in ISR context millis()
|
||||
// dispatches to xTaskGetTickCountFromISR() to satisfy the FreeRTOS API contract.
|
||||
//
|
||||
// BK72xx runs FreeRTOS at 500 Hz — multiply by portTICK_PERIOD_MS (== 2) to convert
|
||||
// ticks to milliseconds, matching the Arduino core's wiring.c. IRAM_ATTR is a no-op
|
||||
// on BK72xx (see hal.h): the SDK masks FIQ + IRQ at the CPU around every flash
|
||||
// operation, so no ISR runs while flash is stalled and IRAM placement is unnecessary.
|
||||
// BK72xx therefore also skips the ISR dispatch, matching the Arduino core.
|
||||
#if defined(USE_RTL87XX) || defined(USE_LN882X)
|
||||
uint32_t IRAM_ATTR HOT millis() {
|
||||
static_assert(configTICK_RATE_HZ == 1000, "millis() fast path requires 1 kHz FreeRTOS tick");
|
||||
return in_isr_context() ? xTaskGetTickCountFromISR() : xTaskGetTickCount();
|
||||
}
|
||||
#elif defined(USE_BK72XX)
|
||||
uint32_t IRAM_ATTR HOT millis() {
|
||||
uint32_t HOT millis() {
|
||||
static_assert(configTICK_RATE_HZ == 500, "BK72xx millis() fast path assumes 500 Hz FreeRTOS tick");
|
||||
return xTaskGetTickCount() * portTICK_PERIOD_MS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user