feat(twai): graduate the hal drivers into esp_hal_twai component

This commit is contained in:
morris
2025-12-10 13:56:47 +08:00
parent b9db95731f
commit 37c614d626
74 changed files with 1025 additions and 784 deletions
@@ -15,10 +15,18 @@ check_register_rw_half_word(SOC_MODULES "twai*" "pcr" "hp_sys_clkrst"
HAL_MODULES "twai*")
if(CONFIG_COMPILER_DUMP_RTL_FILES)
# Collect RTL directories in a variable for readability. Join them
# with commas so they are passed as a single --rtl-dirs argument to the script.
set(TWAI_RTL_DIRS
${CMAKE_BINARY_DIR}/esp-idf/esp_driver_twai
${CMAKE_BINARY_DIR}/esp-idf/hal
${CMAKE_BINARY_DIR}/esp-idf/esp_hal_twai
)
string(JOIN "," TWAI_RTL_DIRS_JOINED ${TWAI_RTL_DIRS})
add_custom_target(
check_test_app_sections ALL
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_twai/,${CMAKE_BINARY_DIR}/esp-idf/hal/
--rtl-dirs ${TWAI_RTL_DIRS_JOINED}
--elf-file ${CMAKE_BINARY_DIR}/test_twai.elf
find-refs
--from-sections=.iram0.text
@@ -4,7 +4,7 @@ if(CONFIG_SOC_TWAI_SUPPORTED)
list(APPEND srcs "test_twai_common.cpp" "test_twai_network.cpp")
endif()
if(CONFIG_SOC_TWAI_SUPPORT_FD)
if(CONFIG_SOC_TWAI_FD_SUPPORTED)
list(APPEND srcs "test_twai_fd.cpp")
endif()
@@ -17,7 +17,7 @@
#include "freertos/FreeRTOS.h"
#include "esp_twai.h"
#include "esp_twai_onchip.h"
#include "soc/twai_periph.h"
#include "hal/twai_periph.h"
#include "esp_private/gpio.h"
#include "driver/uart.h" // for baudrate detection
@@ -340,7 +340,7 @@ TEST_CASE("twai mask filter (loopback)", "[twai]")
}
//------------------ Dual Filter Test -------------------//
#if !SOC_TWAI_SUPPORT_FD
#if !SOC_HAS(TWAI_FD)
static IRAM_ATTR bool test_dual_filter_rx_done_cb(twai_node_handle_t handle, const twai_rx_done_event_data_t *edata, void *user_ctx)
{
uint8_t *test_ctrl = (uint8_t *)user_ctx;
@@ -547,7 +547,7 @@ TEST_CASE("twai bus off recovery (loopback)", "[twai]")
}
// recover node
#if SOC_TWAI_SUPPORT_FD
#if SOC_HAS(TWAI_FD)
TEST_ASSERT_GREATER_THAN(200, node_status.tx_error_count);
#else
TEST_ASSERT_EQUAL(128, node_status.tx_error_count); // TEC become 128 when bus off on legacy chips