Skip to content

Commit

Permalink
Merge branch 'fix/p4_twai_enable_test_v5.3' into 'release/v5.3'
Browse files Browse the repository at this point in the history
test(twai): p4 twai enable ci test (v5.3)

See merge request espressif/esp-idf!34178
  • Loading branch information
suda-morris committed Oct 18, 2024
2 parents 888b6f5 + ee198eb commit 3e6ae73
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
4 changes: 0 additions & 4 deletions components/driver/test_apps/.build-test-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,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:
Expand Down
11 changes: 7 additions & 4 deletions components/driver/test_apps/twai/main/test_twai_interactive.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand All @@ -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)
{
Expand All @@ -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
Expand Down Expand Up @@ -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));
Expand Down
10 changes: 6 additions & 4 deletions components/driver/test_apps/twai/main/test_twai_loop_back.c
Original file line number Diff line number Diff line change
@@ -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
*/
Expand Down Expand Up @@ -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]);
}
Expand Down
7 changes: 5 additions & 2 deletions components/driver/test_apps/twai/pytest_twai.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -16,6 +16,7 @@
@pytest.mark.esp32h2
@pytest.mark.esp32s2
@pytest.mark.esp32s3
@pytest.mark.esp32p4
@pytest.mark.generic
@pytest.mark.parametrize(
'config',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 3e6ae73

Please # to comment.