From 08de38ae62aee8814e7a5b4746bfe5fc856ef98a Mon Sep 17 00:00:00 2001 From: wanckl Date: Wed, 22 Oct 2025 17:36:59 +0800 Subject: [PATCH] refactor(driver_twai): remove errata config selection 2 --- components/driver/twai/Kconfig.twai | 17 ++++------------- components/hal/esp32/include/hal/twai_ll.h | 4 ++++ components/hal/twai_hal_v1.c | 3 ++- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/components/driver/twai/Kconfig.twai b/components/driver/twai/Kconfig.twai index 64e60d7c61..b6de8caa44 100644 --- a/components/driver/twai/Kconfig.twai +++ b/components/driver/twai/Kconfig.twai @@ -7,12 +7,6 @@ menu "Legacy TWAI Driver Configurations" help Place the TWAI ISR in to IRAM to reduce latency and increase performance - config TWAI_SKIP_LEGACY_CONFLICT_CHECK - bool "Skip legacy driver conflict check" - default n - help - This configuration option used to bypass the conflict check mechanism with legacy code. - config TWAI_SUPPRESS_DEPRECATE_WARN bool "Suppress legacy driver deprecated warning" default n @@ -21,14 +15,11 @@ menu "Legacy TWAI Driver Configurations" (driver/twai.h). If you want to continue using the legacy driver, and don't want to see related deprecation warnings, you can enable this option. - config TWAI_ERRATA_FIX_TX_INTR_LOST - bool "Add SW workaround for TX interrupt lost errata" - depends on IDF_TARGET_ESP32 - default y + config TWAI_SKIP_LEGACY_CONFLICT_CHECK + bool "Skip legacy driver conflict check" + default n help - On the ESP32, when a transmit interrupt occurs, and interrupt register is read on the same APB clock - cycle, the transmit interrupt could be lost. Enabling this option will add a workaround that checks the - transmit buffer status bit to recover any lost transmit interrupt. + This configuration option used to bypass the conflict check mechanism with legacy code. config TWAI_ERRATA_FIX_RX_FRAME_INVALID bool "Add SW workaround for invalid RX frame errata" diff --git a/components/hal/esp32/include/hal/twai_ll.h b/components/hal/esp32/include/hal/twai_ll.h index d38a5049ec..ba5e6556d1 100644 --- a/components/hal/esp32/include/hal/twai_ll.h +++ b/components/hal/esp32/include/hal/twai_ll.h @@ -36,6 +36,10 @@ // condition is that both TEC and REC become 0. #define TWAI_LL_HAS_BUSOFF_REC_ISSUE 1 +// On the ESP32, when a transmit interrupt occurs, and interrupt register is read on the same APB clock +// cycle, the transmit interrupt could be lost. +#define TWAI_LL_HAS_INTR_LOST_ISSUE 1 + #ifdef __cplusplus extern "C" { #endif diff --git a/components/hal/twai_hal_v1.c b/components/hal/twai_hal_v1.c index c8f8a73163..8f677fb99a 100644 --- a/components/hal/twai_hal_v1.c +++ b/components/hal/twai_hal_v1.c @@ -231,7 +231,8 @@ static inline uint32_t twai_hal_decode_interrupt(twai_hal_context_t *hal_ctx) TWAI_HAL_SET_BITS(events, TWAI_HAL_EVENT_RX_BUFF_FRAME); } //Transmit interrupt set whenever TX buffer becomes free -#ifdef CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST +#if TWAI_LL_HAS_INTR_LOST_ISSUE + // Errata workaround: Check the transmit buffer status bit to recover any lost transmit interrupt. if ((interrupts & TWAI_LL_INTR_TI || hal_ctx->state_flags & TWAI_HAL_STATE_FLAG_TX_BUFF_OCCUPIED) && status & TWAI_LL_STATUS_TBS) { #else if (interrupts & TWAI_LL_INTR_TI) {