From 3a6b665b908f439ee2eeb43ae34c89e01c5ec754 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Fri, 19 Jul 2024 16:06:53 +0800 Subject: [PATCH] ci(ana_cmpr): enable the ana_cmpr target tests on P4 --- .../test_apps/.build-test-rules.yml | 4 ---- .../analog_comparator/main/test_ana_cmpr.c | 10 +++++----- .../analog_comparator/main/test_ana_cmpr.h | 13 +++++++++++-- .../analog_comparator/main/test_ana_cmpr_common.c | 4 ++-- .../analog_comparator/main/test_ana_cmpr_iram.c | 4 ++-- .../test_apps/analog_comparator/pytest_ana_cmpr.py | 2 +- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/components/esp_driver_ana_cmpr/test_apps/.build-test-rules.yml b/components/esp_driver_ana_cmpr/test_apps/.build-test-rules.yml index cbcb9d16bc..39fb87a34c 100644 --- a/components/esp_driver_ana_cmpr/test_apps/.build-test-rules.yml +++ b/components/esp_driver_ana_cmpr/test_apps/.build-test-rules.yml @@ -3,10 +3,6 @@ components/esp_driver_ana_cmpr/test_apps/analog_comparator: disable: - if: SOC_ANA_CMPR_SUPPORTED != 1 - disable_test: - - if: IDF_TARGET == "esp32p4" - temporary: true - reason: not supported yet depends_components: - esp_driver_gpio - esp_driver_ana_cmpr diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.c b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.c index b24776e455..21154fed14 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.c +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -50,12 +50,12 @@ TEST_CASE("ana_cmpr_unit_install_uninstall", "[ana_cmpr]") TEST_CASE("ana_cmpr_internal_reference", "[ana_cmpr]") { - int src_chan = test_init_src_chan_gpio(); + int src_chan = test_init_src_chan_gpio(TEST_ANA_CMPR_UNIT_ID); uint32_t cnt = 0; ana_cmpr_handle_t cmpr = NULL; ana_cmpr_config_t config = { - .unit = 0, + .unit = TEST_ANA_CMPR_UNIT_ID, .clk_src = ANA_CMPR_CLK_SRC_DEFAULT, .ref_src = ANA_CMPR_REF_SRC_INTERNAL, .cross_type = ANA_CMPR_CROSS_ANY, @@ -77,10 +77,10 @@ TEST_CASE("ana_cmpr_internal_reference", "[ana_cmpr]") TEST_ESP_OK(ana_cmpr_register_event_callbacks(cmpr, &cbs, &cnt)); TEST_ESP_OK(ana_cmpr_enable(cmpr)); cnt = 0; - for (int i = 1; i <= 10; i++) { + for (uint32_t i = 1; i <= 10; i++) { test_simulate_src_signal(src_chan, i % 2); esp_rom_delay_us(100); - TEST_ASSERT(cnt == i); + TEST_ASSERT_EQUAL_UINT32(i, cnt); } TEST_ESP_OK(ana_cmpr_disable(cmpr)); TEST_ESP_OK(ana_cmpr_del_unit(cmpr)); diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.h b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.h index 13566bfc84..16ace49358 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.h +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr.h @@ -1,9 +1,11 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ +#pragma once + #include #include "sdkconfig.h" #include "esp_attr.h" @@ -14,6 +16,13 @@ #include "soc/soc_caps.h" #include "driver/ana_cmpr.h" +#if CONFIG_IDF_TARGET_ESP32P4 +// The pin of unit 0 is used for other purpose on P4 runner, use unit 1 instead +#define TEST_ANA_CMPR_UNIT_ID 1 +#else +#define TEST_ANA_CMPR_UNIT_ID 0 +#endif + /** * @brief Test default on cross callback * @@ -32,7 +41,7 @@ bool test_ana_cmpr_on_cross_callback(ana_cmpr_handle_t cmpr, const ana_cmpr_cros * @return * - int Source channel GPIO number */ -int test_init_src_chan_gpio(void); +int test_init_src_chan_gpio(int unit_id); /** * @brief Simulate source channel signal diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr_common.c b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr_common.c index 0feb218ea6..7f5c3e0889 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr_common.c +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr_common.c @@ -16,10 +16,10 @@ bool IRAM_ATTR test_ana_cmpr_on_cross_callback(ana_cmpr_handle_t cmpr, const ana return false; } -int test_init_src_chan_gpio(void) +int test_init_src_chan_gpio(int unit_id) { int src_chan_num = -1; - TEST_ESP_OK(ana_cmpr_get_gpio(0, ANA_CMPR_SOURCE_CHAN, &src_chan_num)); + TEST_ESP_OK(ana_cmpr_get_gpio(unit_id, ANA_CMPR_SOURCE_CHAN, &src_chan_num)); TEST_ASSERT(src_chan_num > 0); gpio_config_t io_conf = { .intr_type = GPIO_INTR_DISABLE, diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr_iram.c b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr_iram.c index 44da8afacd..957bd39980 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr_iram.c +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/main/test_ana_cmpr_iram.c @@ -40,11 +40,11 @@ TEST_CASE("ana_cmpr_internal_reference_iram_safe", "[ana_cmpr]") .count = 0, .src_chan = -1, }; - test_data.src_chan = test_init_src_chan_gpio(); + test_data.src_chan = test_init_src_chan_gpio(TEST_ANA_CMPR_UNIT_ID); ana_cmpr_handle_t cmpr = NULL; ana_cmpr_config_t config = { - .unit = 0, + .unit = TEST_ANA_CMPR_UNIT_ID, .clk_src = ANA_CMPR_CLK_SRC_DEFAULT, .ref_src = ANA_CMPR_REF_SRC_INTERNAL, .cross_type = ANA_CMPR_CROSS_ANY, diff --git a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/pytest_ana_cmpr.py b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/pytest_ana_cmpr.py index 1cc5cf4971..020ff3713e 100644 --- a/components/esp_driver_ana_cmpr/test_apps/analog_comparator/pytest_ana_cmpr.py +++ b/components/esp_driver_ana_cmpr/test_apps/analog_comparator/pytest_ana_cmpr.py @@ -1,11 +1,11 @@ # SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: CC0-1.0 - import pytest from pytest_embedded import Dut @pytest.mark.esp32h2 +@pytest.mark.esp32p4 @pytest.mark.generic @pytest.mark.parametrize( 'config',