From 8ab2edda0081f0c616c759a369535b32c99981e2 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 | 2 +- components/driver/mcpwm/mcpwm_gen.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/driver/Kconfig b/components/driver/Kconfig index 056687f937..6e2fd5f245 100644 --- a/components/driver/Kconfig +++ b/components/driver/Kconfig @@ -397,7 +397,7 @@ menu "Driver Configurations" Enabling this option can improve driver performance as well. config MCPWM_SUPPRESS_DEPRECATE_WARN - bool "Suppress leagcy driver deprecated warning" + bool "Suppress legacy driver deprecated warning" default n help Wether to suppress the deprecation warnings when using legacy MCPWM driver (driver/mcpwm.h). diff --git a/components/driver/mcpwm/mcpwm_gen.c b/components/driver/mcpwm/mcpwm_gen.c index 47db3f176f..8acd8a5912 100644 --- a/components/driver/mcpwm/mcpwm_gen.c +++ b/components/driver/mcpwm/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;