Skip to content

Commit bf9d01b

Browse files
committed
test(twai): p4 twai enable ci test
1 parent 3415ff2 commit bf9d01b

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

components/driver/test_apps/.build-test-rules.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ components/driver/test_apps/touch_sensor_v2:
8686
components/driver/test_apps/twai:
8787
disable:
8888
- if: SOC_TWAI_SUPPORTED != 1
89-
disable_test:
90-
- if: IDF_TARGET == "esp32p4"
91-
temporary: true
92-
reason: test not pass, should be re-enable # TODO: IDF-8966
9389
depends_filepatterns:
9490
- components/driver/twai/**/*
9591
depends_components:

components/driver/test_apps/twai/main/test_twai_interactive.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -16,6 +16,9 @@
1616
#include "soc/soc_caps.h"
1717
#include "esp_log.h"
1818

19+
#define TEST_TWAI_TX_PIN 4
20+
#define TEST_TWAI_RX_PIN 5
21+
1922
#if CONFIG_TWAI_ISR_IN_IRAM
2023
static void IRAM_ATTR test_delay_post_cache_disable(void *args)
2124
{
@@ -27,7 +30,7 @@ TEST_CASE("twai_listen_only", "[twai]")
2730
{
2831
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
2932
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
30-
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(4, 5, TWAI_MODE_LISTEN_ONLY);
33+
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TEST_TWAI_TX_PIN, TEST_TWAI_RX_PIN, TWAI_MODE_LISTEN_ONLY);
3134
#if CONFIG_TWAI_ISR_IN_IRAM
3235
g_config.intr_flags |= ESP_INTR_FLAG_IRAM;
3336
#endif
@@ -60,8 +63,8 @@ TEST_CASE("twai_remote_request", "[twai]")
6063
twai_handle_t bus_handle;
6164
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
6265
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
63-
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(4, 5, TWAI_MODE_NORMAL);
64-
#if CONFIG_IDF_TARGET_ESP32C6
66+
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TEST_TWAI_TX_PIN, TEST_TWAI_RX_PIN, TWAI_MODE_NORMAL);
67+
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32P4
6568
g_config.controller_id = 1;
6669
#endif
6770
TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &bus_handle));

components/driver/test_apps/twai/main/test_twai_loop_back.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -99,25 +99,27 @@ TEST_CASE("twai_mode_ext_no_ack_250kbps", "[twai-loop-back]")
9999
.extd = true, // Extended Frame Format (29bit ID)
100100
};
101101

102-
printf("install twai driver\r\n");
103102
for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) {
104103
g_config.controller_id = i;
105104
g_config.tx_io = i;
106105
g_config.rx_io = i;
106+
printf("install twai driver %d\r\n", g_config.controller_id);
107107
TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &twai_buses[i]));
108108
TEST_ESP_OK(twai_start_v2(twai_buses[i]));
109109
}
110110

111-
printf("transmit message\r\n");
112111
for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) {
112+
printf("transmit message from %d\r\n", i);
113+
tx_msg.data[5] = SOC_TWAI_CONTROLLER_NUM - i;
113114
TEST_ESP_OK(twai_transmit_v2(twai_buses[i], &tx_msg, pdMS_TO_TICKS(1000)));
114115
}
115116

116-
printf("receive message\r\n");
117117
twai_message_t rx_msg;
118118
for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) {
119+
printf("receive message from %d\r\n", i);
119120
TEST_ESP_OK(twai_receive_v2(twai_buses[i], &rx_msg, pdMS_TO_TICKS(1000)));
120121
TEST_ASSERT_TRUE(rx_msg.data_length_code == 6);
122+
tx_msg.data[5] = SOC_TWAI_CONTROLLER_NUM - i;
121123
for (int i = 0; i < 6; i++) {
122124
TEST_ASSERT_EQUAL(tx_msg.data[i], rx_msg.data[i]);
123125
}

components/driver/test_apps/twai/pytest_twai.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
22
# SPDX-License-Identifier: CC0-1.0
3-
43
import logging
54
import subprocess
65
from time import sleep
76

87
import pytest
9-
from can import Bus, Message
8+
from can import Bus
9+
from can import Message
1010
from pytest_embedded import Dut
1111

1212

@@ -16,6 +16,7 @@
1616
@pytest.mark.esp32h2
1717
@pytest.mark.esp32s2
1818
@pytest.mark.esp32s3
19+
@pytest.mark.esp32p4
1920
@pytest.mark.generic
2021
@pytest.mark.parametrize(
2122
'config',
@@ -46,6 +47,7 @@ def fixture_create_socket_can() -> Bus:
4647
@pytest.mark.esp32h2
4748
@pytest.mark.esp32s2
4849
@pytest.mark.esp32s3
50+
@pytest.mark.esp32p4
4951
@pytest.mark.twai_std
5052
@pytest.mark.parametrize(
5153
'config',
@@ -79,6 +81,7 @@ def test_twai_listen_only(dut: Dut, socket_can: Bus) -> None:
7981
@pytest.mark.esp32h2
8082
@pytest.mark.esp32s2
8183
@pytest.mark.esp32s3
84+
@pytest.mark.esp32p4
8285
@pytest.mark.twai_std
8386
@pytest.mark.parametrize(
8487
'config',

0 commit comments

Comments
 (0)