refactor(driver_twai): remove errata config selection 3

This commit is contained in:
wanckl
2025-10-22 17:51:02 +08:00
committed by morris
parent 66f56f9ed1
commit cd483606c9
6 changed files with 24 additions and 17 deletions
-11
View File
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
+4 -6
View File
@@ -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