ci(ana_cmpr): enable the ana_cmpr target tests on P4

This commit is contained in:
laokaiyao 2024-07-19 16:06:53 +08:00
parent b6273e1f36
commit 3a6b665b90
6 changed files with 21 additions and 16 deletions

View File

@ -3,10 +3,6 @@
components/esp_driver_ana_cmpr/test_apps/analog_comparator: components/esp_driver_ana_cmpr/test_apps/analog_comparator:
disable: disable:
- if: SOC_ANA_CMPR_SUPPORTED != 1 - if: SOC_ANA_CMPR_SUPPORTED != 1
disable_test:
- if: IDF_TARGET == "esp32p4"
temporary: true
reason: not supported yet
depends_components: depends_components:
- esp_driver_gpio - esp_driver_gpio
- esp_driver_ana_cmpr - esp_driver_ana_cmpr

View File

@ -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 * 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]") 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; uint32_t cnt = 0;
ana_cmpr_handle_t cmpr = NULL; ana_cmpr_handle_t cmpr = NULL;
ana_cmpr_config_t config = { ana_cmpr_config_t config = {
.unit = 0, .unit = TEST_ANA_CMPR_UNIT_ID,
.clk_src = ANA_CMPR_CLK_SRC_DEFAULT, .clk_src = ANA_CMPR_CLK_SRC_DEFAULT,
.ref_src = ANA_CMPR_REF_SRC_INTERNAL, .ref_src = ANA_CMPR_REF_SRC_INTERNAL,
.cross_type = ANA_CMPR_CROSS_ANY, .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_register_event_callbacks(cmpr, &cbs, &cnt));
TEST_ESP_OK(ana_cmpr_enable(cmpr)); TEST_ESP_OK(ana_cmpr_enable(cmpr));
cnt = 0; 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); test_simulate_src_signal(src_chan, i % 2);
esp_rom_delay_us(100); 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_disable(cmpr));
TEST_ESP_OK(ana_cmpr_del_unit(cmpr)); TEST_ESP_OK(ana_cmpr_del_unit(cmpr));

View File

@ -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 * SPDX-License-Identifier: Apache-2.0
*/ */
#pragma once
#include <stdio.h> #include <stdio.h>
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_attr.h" #include "esp_attr.h"
@ -14,6 +16,13 @@
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "driver/ana_cmpr.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 * @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 * @return
* - int Source channel GPIO number * - 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 * @brief Simulate source channel signal

View File

@ -16,10 +16,10 @@ bool IRAM_ATTR test_ana_cmpr_on_cross_callback(ana_cmpr_handle_t cmpr, const ana
return false; return false;
} }
int test_init_src_chan_gpio(void) int test_init_src_chan_gpio(int unit_id)
{ {
int src_chan_num = -1; 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); TEST_ASSERT(src_chan_num > 0);
gpio_config_t io_conf = { gpio_config_t io_conf = {
.intr_type = GPIO_INTR_DISABLE, .intr_type = GPIO_INTR_DISABLE,

View File

@ -40,11 +40,11 @@ TEST_CASE("ana_cmpr_internal_reference_iram_safe", "[ana_cmpr]")
.count = 0, .count = 0,
.src_chan = -1, .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_handle_t cmpr = NULL;
ana_cmpr_config_t config = { ana_cmpr_config_t config = {
.unit = 0, .unit = TEST_ANA_CMPR_UNIT_ID,
.clk_src = ANA_CMPR_CLK_SRC_DEFAULT, .clk_src = ANA_CMPR_CLK_SRC_DEFAULT,
.ref_src = ANA_CMPR_REF_SRC_INTERNAL, .ref_src = ANA_CMPR_REF_SRC_INTERNAL,
.cross_type = ANA_CMPR_CROSS_ANY, .cross_type = ANA_CMPR_CROSS_ANY,

View File

@ -1,11 +1,11 @@
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD # SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0 # SPDX-License-Identifier: CC0-1.0
import pytest import pytest
from pytest_embedded import Dut from pytest_embedded import Dut
@pytest.mark.esp32h2 @pytest.mark.esp32h2
@pytest.mark.esp32p4
@pytest.mark.generic @pytest.mark.generic
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', 'config',