From 54eb152a969402d73b89e391c6035894ce3e8e05 Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Fri, 16 Apr 2021 18:36:18 +0800 Subject: [PATCH] TWAI: Simply caps and remove unused caps --- components/driver/twai.c | 4 ---- components/soc/esp32/include/soc/soc_caps.h | 22 +++++++-------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/components/driver/twai.c b/components/driver/twai.c index 0e02127f51..1a3582d717 100644 --- a/components/driver/twai.c +++ b/components/driver/twai.c @@ -412,11 +412,7 @@ esp_err_t twai_driver_install(const twai_general_config_t *g_config, const twai_ TWAI_CHECK(g_config->rx_queue_len > 0, ESP_ERR_INVALID_ARG); TWAI_CHECK(g_config->tx_io >= 0 && g_config->tx_io < GPIO_NUM_MAX, ESP_ERR_INVALID_ARG); TWAI_CHECK(g_config->rx_io >= 0 && g_config->rx_io < GPIO_NUM_MAX, ESP_ERR_INVALID_ARG); -#if (CONFIG_ESP32_REV_MIN >= 2) - TWAI_CHECK(t_config->brp >= SOC_TWAI_BRP_MIN && t_config->brp <= SOC_TWAI_BRP_MAX_ECO, ESP_ERR_INVALID_ARG); -#else TWAI_CHECK(t_config->brp >= SOC_TWAI_BRP_MIN && t_config->brp <= SOC_TWAI_BRP_MAX, ESP_ERR_INVALID_ARG); -#endif #ifndef CONFIG_TWAI_ISR_IN_IRAM TWAI_CHECK(!(g_config->intr_flags & ESP_INTR_FLAG_IRAM), ESP_ERR_INVALID_ARG); #endif diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index 488acd8382..8f2a29c3c9 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -224,25 +224,14 @@ /*-------------------------- TWAI CAPS ---------------------------------------*/ #define SOC_TWAI_BRP_MIN 2 -#define SOC_TWAI_SUPPORT_MULTI_ADDRESS_LAYOUT 1 - -#define SOC_TWAI_BRP_MAX_ECO0 128 -//Any even number from 2 to 128 -#define SOC_TWAI_BRP_IS_VALID_ECO0(brp) ((brp) >= 2 && (brp) <= 128 && ((brp) & 0x1) == 0) - -#define SOC_TWAI_BRP_MAX_ECO 256 -//Any even number from 2 to 128, or multiples of 4 from 132 to 256 -#define SOC_TWAI_BRP_IS_VALID_ECO(brp) (((brp) >= 2 && (brp) <= 128 && ((brp) & 0x1) == 0) || ((brp) >= 132 && (brp) <= 256 && ((brp) & 0x3) == 0)) - #if SOC_CAPS_ECO_VER >= 2 +# define SOC_TWAI_BRP_MAX 256 # define SOC_TWAI_BRP_DIV_SUPPORTED 1 # define SOC_TWAI_BRP_DIV_THRESH 128 -# define SOC_TWAI_BRP_IS_VALID SOC_TWAI_BRP_IS_VALID_ECO -# define SOC_TWAI_BRP_MAX SOC_TWAI_BRP_MAX_ECO #else -# define SOC_TWAI_BRP_IS_VALID SOC_TWAI_BRP_IS_VALID_ECO0 -# define SOC_TWAI_BRP_MAX SOC_TWAI_BRP_MAX_ECO0 +# define SOC_TWAI_BRP_MAX 128 #endif +#define SOC_TWAI_SUPPORT_MULTI_ADDRESS_LAYOUT 1 /*-------------------------- UART CAPS ---------------------------------------*/ // ESP32 have 3 UART. @@ -285,5 +274,8 @@ #define SOC_CAN_SUPPORTED SOC_TWAI_SUPPORTED #define CAN_BRP_MIN SOC_TWAI_BRP_MIN #define CAN_BRP_MAX SOC_TWAI_BRP_MAX -#define CAN_BRP_DIV_THRESH SOC_TWAI_BRP_DIV_THRESH #define CAN_SUPPORT_MULTI_ADDRESS_LAYOUT SOC_TWAI_SUPPORT_MULTI_ADDRESS_LAYOUT +#if SOC_CAPS_ECO_VER >= 2 +# define CAN_BRP_DIV_SUPPORTED SOC_TWAI_BRP_DIV_SUPPORTED +# define CAN_BRP_DIV_THRESH SOC_TWAI_BRP_DIV_THRESH +#endif