From 99fce2fdcb32db57ada5866e3a9944f413772974 Mon Sep 17 00:00:00 2001 From: morris Date: Wed, 31 Jan 2024 16:07:51 +0800 Subject: [PATCH] fix(mcpwm): reset GPIO used by generator after delete Closes https://github.com/espressif/esp-idf/issues/12980 --- components/driver/Kconfig | 20 +++++++++++++++----- components/driver/deprecated/driver/i2s.h | 2 +- components/esp_driver_mcpwm/Kconfig | 8 -------- components/esp_driver_mcpwm/src/mcpwm_gen.c | 4 +++- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/components/driver/Kconfig b/components/driver/Kconfig index 6a1dc91704..ad75325615 100644 --- a/components/driver/Kconfig +++ b/components/driver/Kconfig @@ -1,6 +1,8 @@ menu "Driver Configurations" - menu "Legacy ADC Configuration" + orsource "./twai/Kconfig.twai" + + menu "Legacy ADC Driver Configuration" config ADC_DISABLE_DAC depends on SOC_DAC_SUPPORTED @@ -58,10 +60,18 @@ menu "Driver Configurations" If you want to continue using the legacy driver, and don't want to see related deprecation warnings, you can enable this option. - endmenu + endmenu # Legacy ADC Calibration Configuration + endmenu # Legacy ADC Driver Configuration - endmenu # ADC Configuration - - orsource "./twai/Kconfig.twai" + menu "Legacy MCPWM Driver Configurations" + depends on SOC_MCPWM_SUPPORTED + config MCPWM_SUPPRESS_DEPRECATE_WARN + bool "Suppress legacy driver deprecated warning" + default n + help + Wether to suppress the deprecation warnings when using legacy MCPWM driver (driver/mcpwm.h). + If you want to continue using the legacy driver, and don't want to see related deprecation warnings, + you can enable this option. + endmenu # Legacy MCPWM Driver Configurations endmenu # Driver configurations diff --git a/components/driver/deprecated/driver/i2s.h b/components/driver/deprecated/driver/i2s.h index 07893c3e66..377c49eddd 100644 --- a/components/driver/deprecated/driver/i2s.h +++ b/components/driver/deprecated/driver/i2s.h @@ -27,7 +27,7 @@ #warning "This set of I2S APIs has been deprecated, \ please include 'driver/i2s_std.h', 'driver/i2s_pdm.h' or 'driver/i2s_tdm.h' instead. \ if you want to keep using the old APIs and ignore this warning, \ -you can enable 'Suppress leagcy driver deprecated warning' option under 'I2S Configuration' menu in Kconfig" +you can enable 'Suppress legacy driver deprecated warning' option under 'I2S Configuration' menu in Kconfig" #endif #ifdef __cplusplus diff --git a/components/esp_driver_mcpwm/Kconfig b/components/esp_driver_mcpwm/Kconfig index 0b5bb37bdd..2989a838d7 100644 --- a/components/esp_driver_mcpwm/Kconfig +++ b/components/esp_driver_mcpwm/Kconfig @@ -16,14 +16,6 @@ menu "ESP-Driver:MCPWM Configurations" so that these functions can be IRAM-safe and able to be called in the other IRAM interrupt context. Enabling this option can improve driver performance as well. - config MCPWM_SUPPRESS_DEPRECATE_WARN - bool "Suppress leagcy driver deprecated warning" - default n - help - Wether to suppress the deprecation warnings when using legacy MCPWM driver (driver/mcpwm.h). - If you want to continue using the legacy driver, and don't want to see related deprecation warnings, - you can enable this option. - config MCPWM_ENABLE_DEBUG_LOG bool "Enable debug log" default n diff --git a/components/esp_driver_mcpwm/src/mcpwm_gen.c b/components/esp_driver_mcpwm/src/mcpwm_gen.c index f4ae459745..a203913eb2 100644 --- a/components/esp_driver_mcpwm/src/mcpwm_gen.c +++ b/components/esp_driver_mcpwm/src/mcpwm_gen.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -118,6 +118,8 @@ esp_err_t mcpwm_del_generator(mcpwm_gen_handle_t gen) mcpwm_group_t *group = oper->group; ESP_LOGD(TAG, "del generator (%d,%d,%d)", group->group_id, oper->oper_id, gen->gen_id); + // reset GPIO + gpio_reset_pin(gen->gen_gpio_num); // recycle memory resource ESP_RETURN_ON_ERROR(mcpwm_generator_destroy(gen), TAG, "destroy generator failed"); return ESP_OK;