From c6e452a8712e29b5bc08119202de48ebebcbac33 Mon Sep 17 00:00:00 2001 From: morris Date: Wed, 21 Dec 2022 18:38:07 +0800 Subject: [PATCH] mcpwm: enable test on esp32c6 --- components/driver/.build-test-rules.yml | 8 -------- .../legacy_mcpwm_driver/pytest_legacy_mcpwm.py | 1 + .../driver/test_apps/mcpwm/main/test_mcpwm_cap.c | 14 ++++++++------ .../driver/test_apps/mcpwm/main/test_mcpwm_iram.c | 7 ++++--- components/driver/test_apps/mcpwm/pytest_mcpwm.py | 1 + 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/components/driver/.build-test-rules.yml b/components/driver/.build-test-rules.yml index a8f73d50de..82493a7a79 100644 --- a/components/driver/.build-test-rules.yml +++ b/components/driver/.build-test-rules.yml @@ -43,10 +43,6 @@ components/driver/test_apps/legacy_adc_driver: components/driver/test_apps/legacy_mcpwm_driver: disable: - if: SOC_MCPWM_SUPPORTED != 1 - disable_test: - - if: IDF_TARGET == "esp32c6" - temporary: true - reason: target esp32c6 is not supported yet components/driver/test_apps/legacy_pcnt_driver: disable: @@ -69,10 +65,6 @@ components/driver/test_apps/legacy_timer_driver: components/driver/test_apps/mcpwm: disable: - if: SOC_MCPWM_SUPPORTED != 1 - disable_test: - - if: IDF_TARGET == "esp32c6" - temporary: true - reason: target esp32c6 is not supported yet components/driver/test_apps/pulse_cnt: disable: diff --git a/components/driver/test_apps/legacy_mcpwm_driver/pytest_legacy_mcpwm.py b/components/driver/test_apps/legacy_mcpwm_driver/pytest_legacy_mcpwm.py index 25da5646d2..e2ed1b1d4b 100644 --- a/components/driver/test_apps/legacy_mcpwm_driver/pytest_legacy_mcpwm.py +++ b/components/driver/test_apps/legacy_mcpwm_driver/pytest_legacy_mcpwm.py @@ -7,6 +7,7 @@ from pytest_embedded import Dut @pytest.mark.esp32 @pytest.mark.esp32s3 +@pytest.mark.esp32c6 @pytest.mark.generic @pytest.mark.parametrize( 'config', diff --git a/components/driver/test_apps/mcpwm/main/test_mcpwm_cap.c b/components/driver/test_apps/mcpwm/main/test_mcpwm_cap.c index 7da9603480..a0db1abde7 100644 --- a/components/driver/test_apps/mcpwm/main/test_mcpwm_cap.c +++ b/components/driver/test_apps/mcpwm/main/test_mcpwm_cap.c @@ -111,13 +111,14 @@ TEST_CASE("mcpwm_capture_ext_gpio", "[mcpwm]") printf("simulate GPIO capture signal\r\n"); gpio_set_level(cap_gpio, 1); - vTaskDelay(pdMS_TO_TICKS(100)); + vTaskDelay(pdMS_TO_TICKS(10)); gpio_set_level(cap_gpio, 0); - vTaskDelay(pdMS_TO_TICKS(100)); + vTaskDelay(pdMS_TO_TICKS(10)); printf("capture value: Pos=%"PRIu32", Neg=%"PRIu32"\r\n", cap_value[0], cap_value[1]); uint32_t clk_src_res; - mcpwm_capture_timer_get_resolution(cap_timer, &clk_src_res); - TEST_ASSERT_UINT_WITHIN(100000, clk_src_res / 10, cap_value[1] - cap_value[0]); + TEST_ESP_OK(mcpwm_capture_timer_get_resolution(cap_timer, &clk_src_res)); + clk_src_res /= 1000; // convert to kHz + TEST_ASSERT_UINT_WITHIN(1000, 10000, (cap_value[1] - cap_value[0]) * 1000 / clk_src_res); printf("uninstall capture channel and timer\r\n"); TEST_ESP_OK(mcpwm_capture_channel_disable(pps_channel)); @@ -184,8 +185,9 @@ TEST_CASE("mcpwm_capture_software_catch", "[mcpwm]") uint32_t delta = test_callback_data.cap_data[1] - test_callback_data.cap_data[0]; esp_rom_printf("duration=%u ticks\r\n", delta); uint32_t clk_src_res; - mcpwm_capture_timer_get_resolution(cap_timer, &clk_src_res); - TEST_ASSERT_UINT_WITHIN(80000, clk_src_res / 100, delta); + TEST_ESP_OK(mcpwm_capture_timer_get_resolution(cap_timer, &clk_src_res)); + clk_src_res /= 1000; // convert to kHz + TEST_ASSERT_UINT_WITHIN(1000, 10000, delta * 1000 / clk_src_res); printf("uninstall capture channel and timer\r\n"); TEST_ESP_OK(mcpwm_capture_channel_disable(cap_channel)); diff --git a/components/driver/test_apps/mcpwm/main/test_mcpwm_iram.c b/components/driver/test_apps/mcpwm/main/test_mcpwm_iram.c index 0e6057eb65..bd554a1631 100644 --- a/components/driver/test_apps/mcpwm/main/test_mcpwm_iram.c +++ b/components/driver/test_apps/mcpwm/main/test_mcpwm_iram.c @@ -79,9 +79,10 @@ TEST_CASE("mcpwm_capture_iram_safe", "[mcpwm]") unity_utils_run_cache_disable_stub(test_simulate_input_post_cache_disable, (void *)cap_gpio); printf("capture value: Pos=%"PRIu32", Neg=%"PRIu32"\r\n", cap_value[0], cap_value[1]); - // Capture timer is clocked from APB by default - uint32_t clk_src_res = esp_clk_apb_freq(); - TEST_ASSERT_UINT_WITHIN(2000, clk_src_res / 1000, cap_value[1] - cap_value[0]); + uint32_t clk_src_res; + TEST_ESP_OK(mcpwm_capture_timer_get_resolution(cap_timer, &clk_src_res)); + clk_src_res /= 1000; // convert to kHz + TEST_ASSERT_UINT_WITHIN(100, 1000, (cap_value[1] - cap_value[0]) * 1000 / clk_src_res); printf("uninstall capture channel and timer\r\n"); TEST_ESP_OK(mcpwm_capture_channel_disable(pps_channel)); diff --git a/components/driver/test_apps/mcpwm/pytest_mcpwm.py b/components/driver/test_apps/mcpwm/pytest_mcpwm.py index 6def6d2cf4..427d6d062c 100644 --- a/components/driver/test_apps/mcpwm/pytest_mcpwm.py +++ b/components/driver/test_apps/mcpwm/pytest_mcpwm.py @@ -7,6 +7,7 @@ from pytest_embedded import Dut @pytest.mark.esp32 @pytest.mark.esp32s3 +@pytest.mark.esp32c6 @pytest.mark.generic @pytest.mark.parametrize( 'config',