From 5e2c83332f253d44ba0251bf650bb1860c3a0515 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Thu, 7 Mar 2024 15:34:35 +0800 Subject: [PATCH 1/2] fix(ana_cmpr): fix the crash of the etm example --- .../main/ana_cmpr_example_etm.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/examples/peripherals/analog_comparator/main/ana_cmpr_example_etm.c b/examples/peripherals/analog_comparator/main/ana_cmpr_example_etm.c index a8dbfce5b1..46c827610c 100644 --- a/examples/peripherals/analog_comparator/main/ana_cmpr_example_etm.c +++ b/examples/peripherals/analog_comparator/main/ana_cmpr_example_etm.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: Unlicense OR CC0-1.0 */ @@ -30,17 +30,13 @@ static void example_etm_bind_ana_cmpr_event_with_gpio_task(ana_cmpr_handle_t cmp ESP_ERROR_CHECK(ana_cmpr_new_etm_event(cmpr, &evt_cfg, &cmpr_neg_evt)); /* Allocate the GPIO set & clear tasks */ - esp_etm_task_handle_t gpio_pos_task = NULL; - esp_etm_task_handle_t gpio_neg_task = NULL; + esp_etm_task_handle_t gpio_toggle_task = NULL; gpio_etm_task_config_t task_cfg = { - .action = GPIO_ETM_TASK_ACTION_SET, + .action = GPIO_ETM_TASK_ACTION_TOG, }; - ESP_ERROR_CHECK(gpio_new_etm_task(&task_cfg, &gpio_pos_task)); - task_cfg.action = GPIO_ETM_TASK_ACTION_CLR; - ESP_ERROR_CHECK(gpio_new_etm_task(&task_cfg, &gpio_neg_task)); + ESP_ERROR_CHECK(gpio_new_etm_task(&task_cfg, &gpio_toggle_task)); /* Add task to the monitor GPIO */ - ESP_ERROR_CHECK(gpio_etm_task_add_gpio(gpio_pos_task, EXAMPLE_MONITOR_GPIO_NUM)); - ESP_ERROR_CHECK(gpio_etm_task_add_gpio(gpio_neg_task, EXAMPLE_MONITOR_GPIO_NUM)); + ESP_ERROR_CHECK(gpio_etm_task_add_gpio(gpio_toggle_task, EXAMPLE_MONITOR_GPIO_NUM)); /* Allocate the Event Task Matrix channels */ esp_etm_channel_handle_t etm_pos_handle; @@ -49,8 +45,8 @@ static void example_etm_bind_ana_cmpr_event_with_gpio_task(ana_cmpr_handle_t cmp ESP_ERROR_CHECK(esp_etm_new_channel(&etm_cfg, &etm_pos_handle)); ESP_ERROR_CHECK(esp_etm_new_channel(&etm_cfg, &etm_neg_handle)); /* Bind the events and tasks */ - ESP_ERROR_CHECK(esp_etm_channel_connect(etm_pos_handle, cmpr_pos_evt, gpio_pos_task)); - ESP_ERROR_CHECK(esp_etm_channel_connect(etm_neg_handle, cmpr_neg_evt, gpio_neg_task)); + ESP_ERROR_CHECK(esp_etm_channel_connect(etm_pos_handle, cmpr_pos_evt, gpio_toggle_task)); + ESP_ERROR_CHECK(esp_etm_channel_connect(etm_neg_handle, cmpr_neg_evt, gpio_toggle_task)); /* Enable the ETM channels */ ESP_ERROR_CHECK(esp_etm_channel_enable(etm_pos_handle)); ESP_ERROR_CHECK(esp_etm_channel_enable(etm_neg_handle)); From 9659a6f2c53c27644a8ac12b440017dccd97a770 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Thu, 7 Mar 2024 16:06:17 +0800 Subject: [PATCH 2/2] ci(ana_camr): enable example test on p4 --- examples/peripherals/.build-test-rules.yml | 4 ---- .../analog_comparator/main/ana_cmpr_example_main.h | 4 ++++ .../peripherals/analog_comparator/pytest_ana_cmpr_example.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/peripherals/.build-test-rules.yml b/examples/peripherals/.build-test-rules.yml index 6bbc715db6..845eaf50c8 100644 --- a/examples/peripherals/.build-test-rules.yml +++ b/examples/peripherals/.build-test-rules.yml @@ -20,10 +20,6 @@ examples/peripherals/adc/oneshot_read: examples/peripherals/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/examples/peripherals/analog_comparator/main/ana_cmpr_example_main.h b/examples/peripherals/analog_comparator/main/ana_cmpr_example_main.h index 48e872b3ae..4cb7310c98 100644 --- a/examples/peripherals/analog_comparator/main/ana_cmpr_example_main.h +++ b/examples/peripherals/analog_comparator/main/ana_cmpr_example_main.h @@ -18,7 +18,11 @@ extern "C" { #define EXAMPLE_WAIT_TIME_PROP (0.1) // The wait time proportion in one relative signal period #define EXAMPLE_WAITE_TIME_US(freq_approx) (uint32_t)(1000000 * EXAMPLE_WAIT_TIME_PROP / (freq_approx)) +#if CONFIG_IDF_TARGET_ESP32P4 +#define EXAMPLE_MONITOR_GPIO_NUM (32) // The gpio to monitor the on cross callback +#else #define EXAMPLE_MONITOR_GPIO_NUM (0) // The gpio to monitor the on cross callback +#endif void example_init_monitor_gpio(void); diff --git a/examples/peripherals/analog_comparator/pytest_ana_cmpr_example.py b/examples/peripherals/analog_comparator/pytest_ana_cmpr_example.py index edd9e49067..0c7b5c2b02 100644 --- a/examples/peripherals/analog_comparator/pytest_ana_cmpr_example.py +++ b/examples/peripherals/analog_comparator/pytest_ana_cmpr_example.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', @@ -17,7 +17,7 @@ from pytest_embedded import Dut ) def test_ana_cmpr_example(dut: Dut) -> None: sdkconfig = dut.app.sdkconfig - dut.expect('ana_cmpr_example: Analog Comparator source gpio 11, external reference gpio 10', timeout=10) + dut.expect(r'ana_cmpr_example: Analog Comparator source gpio ([0-9]+), external reference gpio ([0-9]+)', timeout=10) if sdkconfig['EXAMPLE_INTERNAL_REF']: dut.expect('ana_cmpr_example: Allocate Analog Comparator with internal reference', timeout=10) dut.expect(r'ana_cmpr_example: Analog comparator enabled, reference voltage: [0-9]+% \* VDD', timeout=10)