diff --git a/components/driver/twai/Kconfig.twai b/components/driver/twai/Kconfig.twai index b6de8caa44..6e98a87ef4 100644 --- a/components/driver/twai/Kconfig.twai +++ b/components/driver/twai/Kconfig.twai @@ -42,15 +42,4 @@ menu "Legacy TWAI Driver Configurations" on detection of this errata condition. Note that if a frame is being sent on the bus during the reset bus during the reset, the message will be lost. - config TWAI_ERRATA_FIX_LISTEN_ONLY_DOM - bool "Add SW workaround for listen only transmits dominant bit errata" - depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 - default y - help - When in the listen only mode, the TWAI controller must not influence the TWAI bus (i.e., must not send - any dominant bits). However, while in listen only mode on the ESP32/ESP32-S2/ESP32-S3/ESP32-C3, the - TWAI controller will still transmit dominant bits when it detects an error (i.e., as part of an active - error frame). Enabling this option will add a workaround that forces the TWAI controller into an error - passive state on initialization, thus preventing any dominant bits from being sent. - endmenu # TWAI Configuration diff --git a/components/hal/esp32/include/hal/twai_ll.h b/components/hal/esp32/include/hal/twai_ll.h index ba5e6556d1..2f8d0a75cb 100644 --- a/components/hal/esp32/include/hal/twai_ll.h +++ b/components/hal/esp32/include/hal/twai_ll.h @@ -40,6 +40,11 @@ // cycle, the transmit interrupt could be lost. #define TWAI_LL_HAS_INTR_LOST_ISSUE 1 +// When in the listen only mode, the TWAI controller must not influence the TWAI bus (i.e., must not send +// any dominant bits). However, while in listen only mode, the TWAI controller will still transmit dominant +// bits when it detects an error (i.e., as part of an active error frame). +#define TWAI_LL_HAS_LOM_DOM_ISSUE 1 + #ifdef __cplusplus extern "C" { #endif diff --git a/components/hal/esp32c3/include/hal/twai_ll.h b/components/hal/esp32c3/include/hal/twai_ll.h index a1a7c3d059..c1a19c68c2 100644 --- a/components/hal/esp32c3/include/hal/twai_ll.h +++ b/components/hal/esp32c3/include/hal/twai_ll.h @@ -27,6 +27,11 @@ #define TWAI_LL_GET_HW(controller_id) ((controller_id == 0) ? (&TWAI) : NULL) +// When in the listen only mode, the TWAI controller must not influence the TWAI bus (i.e., must not send +// any dominant bits). However, while in listen only mode, the TWAI controller will still transmit dominant +// bits when it detects an error (i.e., as part of an active error frame). +#define TWAI_LL_HAS_LOM_DOM_ISSUE 1 + #ifdef __cplusplus extern "C" { #endif diff --git a/components/hal/esp32s2/include/hal/twai_ll.h b/components/hal/esp32s2/include/hal/twai_ll.h index a46717c2c5..a224b9523f 100644 --- a/components/hal/esp32s2/include/hal/twai_ll.h +++ b/components/hal/esp32s2/include/hal/twai_ll.h @@ -27,6 +27,11 @@ #define TWAI_LL_GET_HW(controller_id) ((controller_id == 0) ? (&TWAI) : NULL) +// When in the listen only mode, the TWAI controller must not influence the TWAI bus (i.e., must not send +// any dominant bits). However, while in listen only mode, the TWAI controller will still transmit dominant +// bits when it detects an error (i.e., as part of an active error frame). +#define TWAI_LL_HAS_LOM_DOM_ISSUE 1 + #ifdef __cplusplus extern "C" { #endif diff --git a/components/hal/esp32s3/include/hal/twai_ll.h b/components/hal/esp32s3/include/hal/twai_ll.h index 965f162859..538a40e129 100644 --- a/components/hal/esp32s3/include/hal/twai_ll.h +++ b/components/hal/esp32s3/include/hal/twai_ll.h @@ -27,6 +27,11 @@ #define TWAI_LL_GET_HW(controller_id) ((controller_id == 0) ? (&TWAI) : NULL) +// When in the listen only mode, the TWAI controller must not influence the TWAI bus (i.e., must not send +// any dominant bits). However, while in listen only mode, the TWAI controller will still transmit dominant +// bits when it detects an error (i.e., as part of an active error frame). +#define TWAI_LL_HAS_LOM_DOM_ISSUE 1 + #ifdef __cplusplus extern "C" { #endif diff --git a/components/hal/twai_hal_v1.c b/components/hal/twai_hal_v1.c index 8f677fb99a..3224c2d1bf 100644 --- a/components/hal/twai_hal_v1.c +++ b/components/hal/twai_hal_v1.c @@ -143,12 +143,10 @@ void twai_hal_start(twai_hal_context_t *hal_ctx) twai_ll_set_mode(hal_ctx->dev, hal_ctx->enable_listen_only, hal_ctx->enable_self_test, hal_ctx->enable_loopback); //Clear the TEC and REC twai_ll_set_tec(hal_ctx->dev, 0); -#ifdef CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM - /* - Errata workaround: Prevent transmission of dominant error frame while in listen only mode by setting REC to 128 - before exiting reset mode. This forces the controller to be error passive (thus only transmits recessive bits). - The TEC/REC remain frozen in listen only mode thus ensuring we remain error passive. - */ +#if TWAI_LL_HAS_LOM_DOM_ISSUE + // Errata workaround: Prevent transmission of dominant error frame while in listen only mode by setting REC to 128 + // before exiting reset mode. This forces the controller to be error passive (thus only transmits recessive bits). + // The TEC/REC remain frozen in listen only mode thus ensuring we remain error passive. if (hal_ctx->enable_listen_only) { twai_ll_set_rec(hal_ctx->dev, 128); } else