From bf9d01bf2a107d64fef8584e71d590d908511514 Mon Sep 17 00:00:00 2001 From: wanckl Date: Tue, 10 Sep 2024 15:20:25 +0800 Subject: [PATCH] test(twai): p4 twai enable ci test --- components/driver/test_apps/.build-test-rules.yml | 4 ---- .../test_apps/twai/main/test_twai_interactive.c | 11 +++++++---- .../driver/test_apps/twai/main/test_twai_loop_back.c | 10 ++++++---- components/driver/test_apps/twai/pytest_twai.py | 7 +++++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/components/driver/test_apps/.build-test-rules.yml b/components/driver/test_apps/.build-test-rules.yml index 7ddcb71239..f78fff4f30 100644 --- a/components/driver/test_apps/.build-test-rules.yml +++ b/components/driver/test_apps/.build-test-rules.yml @@ -86,10 +86,6 @@ components/driver/test_apps/touch_sensor_v2: components/driver/test_apps/twai: disable: - if: SOC_TWAI_SUPPORTED != 1 - disable_test: - - if: IDF_TARGET == "esp32p4" - temporary: true - reason: test not pass, should be re-enable # TODO: IDF-8966 depends_filepatterns: - components/driver/twai/**/* depends_components: diff --git a/components/driver/test_apps/twai/main/test_twai_interactive.c b/components/driver/test_apps/twai/main/test_twai_interactive.c index 78ee660555..b7f7e52bb2 100644 --- a/components/driver/test_apps/twai/main/test_twai_interactive.c +++ b/components/driver/test_apps/twai/main/test_twai_interactive.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,6 +16,9 @@ #include "soc/soc_caps.h" #include "esp_log.h" +#define TEST_TWAI_TX_PIN 4 +#define TEST_TWAI_RX_PIN 5 + #if CONFIG_TWAI_ISR_IN_IRAM static void IRAM_ATTR test_delay_post_cache_disable(void *args) { @@ -27,7 +30,7 @@ TEST_CASE("twai_listen_only", "[twai]") { twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS(); twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); - twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(4, 5, TWAI_MODE_LISTEN_ONLY); + twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TEST_TWAI_TX_PIN, TEST_TWAI_RX_PIN, TWAI_MODE_LISTEN_ONLY); #if CONFIG_TWAI_ISR_IN_IRAM g_config.intr_flags |= ESP_INTR_FLAG_IRAM; #endif @@ -60,8 +63,8 @@ TEST_CASE("twai_remote_request", "[twai]") twai_handle_t bus_handle; twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS(); twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); - twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(4, 5, TWAI_MODE_NORMAL); -#if CONFIG_IDF_TARGET_ESP32C6 + twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TEST_TWAI_TX_PIN, TEST_TWAI_RX_PIN, TWAI_MODE_NORMAL); +#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32P4 g_config.controller_id = 1; #endif TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &bus_handle)); diff --git a/components/driver/test_apps/twai/main/test_twai_loop_back.c b/components/driver/test_apps/twai/main/test_twai_loop_back.c index 3fa664dc0f..7fea86000b 100644 --- a/components/driver/test_apps/twai/main/test_twai_loop_back.c +++ b/components/driver/test_apps/twai/main/test_twai_loop_back.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -99,25 +99,27 @@ TEST_CASE("twai_mode_ext_no_ack_250kbps", "[twai-loop-back]") .extd = true, // Extended Frame Format (29bit ID) }; - printf("install twai driver\r\n"); for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) { g_config.controller_id = i; g_config.tx_io = i; g_config.rx_io = i; + printf("install twai driver %d\r\n", g_config.controller_id); TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &twai_buses[i])); TEST_ESP_OK(twai_start_v2(twai_buses[i])); } - printf("transmit message\r\n"); for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) { + printf("transmit message from %d\r\n", i); + tx_msg.data[5] = SOC_TWAI_CONTROLLER_NUM - i; TEST_ESP_OK(twai_transmit_v2(twai_buses[i], &tx_msg, pdMS_TO_TICKS(1000))); } - printf("receive message\r\n"); twai_message_t rx_msg; for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) { + printf("receive message from %d\r\n", i); TEST_ESP_OK(twai_receive_v2(twai_buses[i], &rx_msg, pdMS_TO_TICKS(1000))); TEST_ASSERT_TRUE(rx_msg.data_length_code == 6); + tx_msg.data[5] = SOC_TWAI_CONTROLLER_NUM - i; for (int i = 0; i < 6; i++) { TEST_ASSERT_EQUAL(tx_msg.data[i], rx_msg.data[i]); } diff --git a/components/driver/test_apps/twai/pytest_twai.py b/components/driver/test_apps/twai/pytest_twai.py index 5b05e08fb3..9113bb1a6e 100644 --- a/components/driver/test_apps/twai/pytest_twai.py +++ b/components/driver/test_apps/twai/pytest_twai.py @@ -1,12 +1,12 @@ # SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 - import logging import subprocess from time import sleep import pytest -from can import Bus, Message +from can import Bus +from can import Message from pytest_embedded import Dut @@ -16,6 +16,7 @@ from pytest_embedded import Dut @pytest.mark.esp32h2 @pytest.mark.esp32s2 @pytest.mark.esp32s3 +@pytest.mark.esp32p4 @pytest.mark.generic @pytest.mark.parametrize( 'config', @@ -46,6 +47,7 @@ def fixture_create_socket_can() -> Bus: @pytest.mark.esp32h2 @pytest.mark.esp32s2 @pytest.mark.esp32s3 +@pytest.mark.esp32p4 @pytest.mark.twai_std @pytest.mark.parametrize( 'config', @@ -79,6 +81,7 @@ def test_twai_listen_only(dut: Dut, socket_can: Bus) -> None: @pytest.mark.esp32h2 @pytest.mark.esp32s2 @pytest.mark.esp32s3 +@pytest.mark.esp32p4 @pytest.mark.twai_std @pytest.mark.parametrize( 'config',