From 195f6b99ad3374dce64d79e7b813a5d0021e8b9b Mon Sep 17 00:00:00 2001 From: morris Date: Wed, 15 Feb 2023 14:44:58 +0800 Subject: [PATCH] rmt: expose private API to get channel ID Closes https://github.com/espressif/esp-idf/issues/10596 --- components/driver/.build-test-rules.yml | 10 +----- components/driver/include/esp_private/rmt.h | 33 +++++++++++++++++++ components/driver/rmt/rmt_common.c | 7 ++++ .../driver/test_apps/mcpwm/pytest_mcpwm.py | 2 +- .../driver/test_apps/mcpwm/sdkconfig.defaults | 2 +- .../driver/test_apps/rmt/main/test_rmt_tx.c | 2 +- components/driver/test_apps/rmt/pytest_rmt.py | 2 +- .../esp_system/port/soc/esp32h2/Kconfig.cpu | 2 +- components/esp_system/test/test_delay.c | 2 -- examples/peripherals/.build-test-rules.yml | 9 ----- .../peripherals/rmt/stepper_motor/README.md | 4 +-- .../main/stepper_motor_example_main.c | 6 ++-- .../rmt/stepper_motor/pytest_stepper_motor.py | 2 +- .../gptimer/pytest_gptimer_example.py | 1 - 14 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 components/driver/include/esp_private/rmt.h diff --git a/components/driver/.build-test-rules.yml b/components/driver/.build-test-rules.yml index 90fc9794c3..162245a54e 100644 --- a/components/driver/.build-test-rules.yml +++ b/components/driver/.build-test-rules.yml @@ -53,7 +53,7 @@ components/driver/test_apps/legacy_mcpwm_driver: disable_test: - if: IDF_TARGET in ["esp32h2"] temporary: true - reason: cannot pass test, IDF-6812 + reason: default group resolution changed, IDF-6812 components/driver/test_apps/legacy_pcnt_driver: disable: @@ -78,10 +78,6 @@ components/driver/test_apps/legacy_timer_driver: components/driver/test_apps/mcpwm: disable: - if: SOC_MCPWM_SUPPORTED != 1 - disable_test: - - if: IDF_TARGET in ["esp32h2"] - temporary: true - reason: cannot pass test, IDF-6812 components/driver/test_apps/pulse_cnt: disable: @@ -90,10 +86,6 @@ components/driver/test_apps/pulse_cnt: components/driver/test_apps/rmt: disable: - if: SOC_RMT_SUPPORTED != 1 - disable_test: - - if: IDF_TARGET in ["esp32h2"] - temporary: true - reason: cannot pass test, IDF-6810 components/driver/test_apps/rs485: disable_test: diff --git a/components/driver/include/esp_private/rmt.h b/components/driver/include/esp_private/rmt.h new file mode 100644 index 0000000000..fa88b06f2a --- /dev/null +++ b/components/driver/include/esp_private/rmt.h @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +// DO NOT USE THESE APIS IN YOUR APPLICATIONS +// The following APIs are for internal test. + +#pragma once + +#include "esp_err.h" +#include "driver/rmt_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the unique ID of RMT channel + * + * @param[in] channel RMT generic channel that created by `rmt_new_tx_channel()` or `rmt_new_rx_channel()` + * @param[out] ret_id The unique ID of RMT channel + * @return + * - ESP_OK: Get RMT channel ID successfully + * - ESP_ERR_INVALID_ARG: Get RMT channel ID failed because of invalid argument + * - ESP_FAIL: Get RMT channel ID failed because of other reasons + */ +esp_err_t rmt_get_channel_id(rmt_channel_handle_t channel, int *ret_id); + +#ifdef __cplusplus +} +#endif diff --git a/components/driver/rmt/rmt_common.c b/components/driver/rmt/rmt_common.c index 5fcd75c67f..5283e019af 100644 --- a/components/driver/rmt/rmt_common.c +++ b/components/driver/rmt/rmt_common.c @@ -169,6 +169,13 @@ esp_err_t rmt_select_periph_clock(rmt_channel_handle_t chan, rmt_clock_source_t return ret; } +esp_err_t rmt_get_channel_id(rmt_channel_handle_t channel, int *ret_id) +{ + ESP_RETURN_ON_FALSE(channel && ret_id, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); + *ret_id = channel->channel_id; + return ESP_OK; +} + esp_err_t rmt_apply_carrier(rmt_channel_handle_t channel, const rmt_carrier_config_t *config) { // specially, we allow config to be NULL, means to disable the carrier submodule diff --git a/components/driver/test_apps/mcpwm/pytest_mcpwm.py b/components/driver/test_apps/mcpwm/pytest_mcpwm.py index b3cc185a27..e658c90ba1 100644 --- a/components/driver/test_apps/mcpwm/pytest_mcpwm.py +++ b/components/driver/test_apps/mcpwm/pytest_mcpwm.py @@ -8,7 +8,7 @@ from pytest_embedded import Dut @pytest.mark.esp32 @pytest.mark.esp32s3 @pytest.mark.esp32c6 -# @pytest.mark.esp32h2 # IDF-6812 +@pytest.mark.esp32h2 @pytest.mark.generic @pytest.mark.parametrize( 'config', diff --git a/components/driver/test_apps/mcpwm/sdkconfig.defaults b/components/driver/test_apps/mcpwm/sdkconfig.defaults index b308cb2ddd..8e326e32e1 100644 --- a/components/driver/test_apps/mcpwm/sdkconfig.defaults +++ b/components/driver/test_apps/mcpwm/sdkconfig.defaults @@ -1,2 +1,2 @@ CONFIG_FREERTOS_HZ=1000 -CONFIG_ESP_TASK_WDT=n +CONFIG_ESP_TASK_WDT_INIT=n diff --git a/components/driver/test_apps/rmt/main/test_rmt_tx.c b/components/driver/test_apps/rmt/main/test_rmt_tx.c index eb4df6bf5e..8696aaa8f4 100644 --- a/components/driver/test_apps/rmt/main/test_rmt_tx.c +++ b/components/driver/test_apps/rmt/main/test_rmt_tx.c @@ -465,7 +465,7 @@ static void test_rmt_multi_channels_trans(size_t channel0_mem_block_symbols, siz { #define TEST_RMT_CHANS 2 #define TEST_LED_NUM 1 -#define TEST_STOP_TIME_NO_SYNCHRO_DELTA 250 +#define TEST_STOP_TIME_NO_SYNCHRO_DELTA 300 #define TEST_STOP_TIME_SYNCHRO_DELTA 60 rmt_tx_channel_config_t tx_channel_cfg = { .clk_src = RMT_CLK_SRC_DEFAULT, diff --git a/components/driver/test_apps/rmt/pytest_rmt.py b/components/driver/test_apps/rmt/pytest_rmt.py index baef51f509..2170d5c9da 100644 --- a/components/driver/test_apps/rmt/pytest_rmt.py +++ b/components/driver/test_apps/rmt/pytest_rmt.py @@ -10,7 +10,7 @@ from pytest_embedded import Dut @pytest.mark.esp32s3 @pytest.mark.esp32c3 @pytest.mark.esp32c6 -# @pytest.mark.esp32h2 IDF-6810 +@pytest.mark.esp32h2 @pytest.mark.generic @pytest.mark.parametrize( 'config', diff --git a/components/esp_system/port/soc/esp32h2/Kconfig.cpu b/components/esp_system/port/soc/esp32h2/Kconfig.cpu index 8056348a4b..df727765d3 100644 --- a/components/esp_system/port/soc/esp32h2/Kconfig.cpu +++ b/components/esp_system/port/soc/esp32h2/Kconfig.cpu @@ -1,6 +1,6 @@ choice ESP_DEFAULT_CPU_FREQ_MHZ prompt "CPU frequency" - default ESP_DEFAULT_CPU_FREQ_MHZ_64 if IDF_ENV_FPGA + default ESP_DEFAULT_CPU_FREQ_MHZ_32 if IDF_ENV_FPGA default ESP_DEFAULT_CPU_FREQ_MHZ_96 help CPU frequency to be set on application startup. diff --git a/components/esp_system/test/test_delay.c b/components/esp_system/test/test_delay.c index da5f625f31..55ed27f5a2 100644 --- a/components/esp_system/test/test_delay.c +++ b/components/esp_system/test/test_delay.c @@ -38,7 +38,6 @@ static void test_delay_task(void *p) vTaskDelete(NULL); } -#if !CONFIG_IDF_TARGET_ESP32H2 // IDF-6783 TEST_CASE("esp_rom_delay_us produces correct delay on CPUs", "[delay]") { int delay_ms = 50; @@ -61,7 +60,6 @@ TEST_CASE("esp_rom_delay_us produces correct delay on CPUs", "[delay]") ref_clock_deinit(); vSemaphoreDelete(args.done); } -#endif TEST_CASE("vTaskDelay produces correct delay on CPUs", "[delay]") { diff --git a/examples/peripherals/.build-test-rules.yml b/examples/peripherals/.build-test-rules.yml index cc004ec9d8..e981a13a71 100644 --- a/examples/peripherals/.build-test-rules.yml +++ b/examples/peripherals/.build-test-rules.yml @@ -142,9 +142,6 @@ examples/peripherals/rmt/onewire_ds18b20: examples/peripherals/rmt/stepper_motor: disable: - if: SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP != 1 - - if: IDF_TARGET == "esp32h2" - temporary: true - reason: wrong GPIO on esp32h2 examples/peripherals/sdio/host: enable: @@ -213,12 +210,6 @@ examples/peripherals/timer_group: disable: - if: SOC_GPTIMER_SUPPORTED != 1 -examples/peripherals/timer_group/gptimer: - disable_test: - - if: IDF_TARGET in ["esp32h2"] - temporary: true - reason: cannot pass target test IDF-6846 - examples/peripherals/timer_group/gptimer_capture_hc_sr04: disable: - if: SOC_TIMER_SUPPORT_ETM != 1 diff --git a/examples/peripherals/rmt/stepper_motor/README.md b/examples/peripherals/rmt/stepper_motor/README.md index 6bb29a2579..772a888393 100644 --- a/examples/peripherals/rmt/stepper_motor/README.md +++ b/examples/peripherals/rmt/stepper_motor/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32-C6 | ESP32-S3 | -| ----------------- | -------- | -------- | +| Supported Targets | ESP32-C6 | ESP32-H2 | ESP32-S3 | +| ----------------- | -------- | -------- | -------- | # RMT Based Stepper Motor Smooth Controller diff --git a/examples/peripherals/rmt/stepper_motor/main/stepper_motor_example_main.c b/examples/peripherals/rmt/stepper_motor/main/stepper_motor_example_main.c index 0db125df37..cf3b8c0f4d 100644 --- a/examples/peripherals/rmt/stepper_motor/main/stepper_motor_example_main.c +++ b/examples/peripherals/rmt/stepper_motor/main/stepper_motor_example_main.c @@ -12,9 +12,9 @@ #include "stepper_motor_encoder.h" ///////////////////////////////Change the following configurations according to your board////////////////////////////// -#define STEP_MOTOR_GPIO_EN 19 -#define STEP_MOTOR_GPIO_DIR 20 -#define STEP_MOTOR_GPIO_STEP 18 +#define STEP_MOTOR_GPIO_EN 0 +#define STEP_MOTOR_GPIO_DIR 2 +#define STEP_MOTOR_GPIO_STEP 4 #define STEP_MOTOR_ENABLE_LEVEL 0 // DRV8825 is enabled on low level #define STEP_MOTOR_SPIN_DIR_CLOCKWISE 0 #define STEP_MOTOR_SPIN_DIR_COUNTERCLOCKWISE !STEP_MOTOR_SPIN_DIR_CLOCKWISE diff --git a/examples/peripherals/rmt/stepper_motor/pytest_stepper_motor.py b/examples/peripherals/rmt/stepper_motor/pytest_stepper_motor.py index 1219604706..f2fba2b8ce 100644 --- a/examples/peripherals/rmt/stepper_motor/pytest_stepper_motor.py +++ b/examples/peripherals/rmt/stepper_motor/pytest_stepper_motor.py @@ -7,7 +7,7 @@ from pytest_embedded import Dut @pytest.mark.esp32s3 @pytest.mark.esp32c6 -# @pytest.mark.esp32h2 IDF-6808 +@pytest.mark.esp32h2 @pytest.mark.generic def test_stepper_motor_example(dut: Dut) -> None: dut.expect_exact('example: Initialize EN + DIR GPIO') diff --git a/examples/peripherals/timer_group/gptimer/pytest_gptimer_example.py b/examples/peripherals/timer_group/gptimer/pytest_gptimer_example.py index b6d5ef7dc9..309beee822 100644 --- a/examples/peripherals/timer_group/gptimer/pytest_gptimer_example.py +++ b/examples/peripherals/timer_group/gptimer/pytest_gptimer_example.py @@ -6,7 +6,6 @@ from pytest_embedded import Dut @pytest.mark.supported_targets -@pytest.mark.temp_skip_ci(targets=['esp32h2'], reason='test failed') # IDF-6846 @pytest.mark.generic def test_gptimer_example(dut: Dut) -> None: dut.expect_exact('Create timer handle', timeout=5)