From aa3cc6ac170beaa412b5d07afd5cfe78d91c8722 Mon Sep 17 00:00:00 2001 From: Armando Date: Tue, 28 Feb 2023 11:22:01 +0800 Subject: [PATCH] esp_adc: fix continuous mode pm lock release fail issue and add tests Closes https://github.com/espressif/esp-idf/issues/10853 --- components/esp_adc/adc_continuous.c | 12 ------------ components/esp_adc/test_apps/adc/pytest_adc.py | 2 ++ .../esp_adc/test_apps/adc/sdkconfig.ci.pm_enable | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 components/esp_adc/test_apps/adc/sdkconfig.ci.pm_enable diff --git a/components/esp_adc/adc_continuous.c b/components/esp_adc/adc_continuous.c index efd42cc7ec..8c091172da 100644 --- a/components/esp_adc/adc_continuous.c +++ b/components/esp_adc/adc_continuous.c @@ -84,11 +84,6 @@ typedef struct adc_continuous_ctx_t { esp_pm_lock_handle_t pm_lock; //For power management } adc_continuous_ctx_t; -#ifdef CONFIG_PM_ENABLE -//Only for deprecated API -extern esp_pm_lock_handle_t adc_digi_arbiter_lock; -#endif //CONFIG_PM_ENABLE - /*--------------------------------------------------------------- ADC Continuous Read Mode (via DMA) ---------------------------------------------------------------*/ @@ -427,11 +422,6 @@ esp_err_t adc_continuous_stop(adc_continuous_handle_t handle) adc_hal_digi_stop(&handle->hal); adc_hal_digi_deinit(&handle->hal); -#if CONFIG_PM_ENABLE - if (handle->pm_lock) { - esp_pm_lock_release(handle->pm_lock); - } -#endif //CONFIG_PM_ENABLE if (handle->use_adc2) { adc_lock_release(ADC_UNIT_2); @@ -492,11 +482,9 @@ esp_err_t adc_continuous_deinit(adc_continuous_handle_t handle) free(handle->ringbuf_struct); } -#if CONFIG_PM_ENABLE if (handle->pm_lock) { esp_pm_lock_delete(handle->pm_lock); } -#endif //CONFIG_PM_ENABLE free(handle->rx_dma_buf); free(handle->hal.rx_desc); diff --git a/components/esp_adc/test_apps/adc/pytest_adc.py b/components/esp_adc/test_apps/adc/pytest_adc.py index abc701f9e7..e9b3d0fb0f 100644 --- a/components/esp_adc/test_apps/adc/pytest_adc.py +++ b/components/esp_adc/test_apps/adc/pytest_adc.py @@ -13,6 +13,7 @@ from pytest_embedded import Dut @pytest.mark.parametrize('config', [ 'iram_safe', 'release', + 'pm_enable' ], indirect=True) def test_adc(dut: Dut) -> None: dut.expect_exact('Press ENTER to see the list of tests') @@ -21,6 +22,7 @@ def test_adc(dut: Dut) -> None: # All ESP32C2 ADC runners are 26m xtal +# No PM test, as C2 doesn't support ADC continuous mode @pytest.mark.esp32c2 @pytest.mark.adc @pytest.mark.parametrize( diff --git a/components/esp_adc/test_apps/adc/sdkconfig.ci.pm_enable b/components/esp_adc/test_apps/adc/sdkconfig.ci.pm_enable new file mode 100644 index 0000000000..23fc3750f7 --- /dev/null +++ b/components/esp_adc/test_apps/adc/sdkconfig.ci.pm_enable @@ -0,0 +1,14 @@ +CONFIG_COMPILER_DUMP_RTL_FILES=y +CONFIG_ADC_ONESHOT_CTRL_FUNC_IN_IRAM=y +CONFIG_GPTIMER_ISR_IRAM_SAFE=y +CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM=y +CONFIG_ADC_CONTINUOUS_ISR_IRAM_SAFE=y +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +# silent the error check, as the error string are stored in rodata, causing RTL check failure +CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y +CONFIG_HAL_ASSERTION_SILENT=y + +CONFIG_PM_ENABLE=y +CONFIG_FREERTOS_USE_TICKLESS_IDLE=y +CONFIG_PM_DFS_INIT_AUTO=y