fix(mcpwm): reset GPIO used by generator after delete

Closes https://github.com/espressif/esp-idf/issues/12980
This commit is contained in:
morris 2024-01-31 16:07:51 +08:00
parent d749575648
commit 99fce2fdcb
4 changed files with 19 additions and 15 deletions

View File

@ -1,6 +1,8 @@
menu "Driver Configurations" menu "Driver Configurations"
menu "Legacy ADC Configuration" orsource "./twai/Kconfig.twai"
menu "Legacy ADC Driver Configuration"
config ADC_DISABLE_DAC config ADC_DISABLE_DAC
depends on SOC_DAC_SUPPORTED 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 If you want to continue using the legacy driver, and don't want to see related
deprecation warnings, you can enable this option. deprecation warnings, you can enable this option.
endmenu endmenu # Legacy ADC Calibration Configuration
endmenu # Legacy ADC Driver Configuration
endmenu # ADC Configuration menu "Legacy MCPWM Driver Configurations"
depends on SOC_MCPWM_SUPPORTED
orsource "./twai/Kconfig.twai" 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 endmenu # Driver configurations

View File

@ -27,7 +27,7 @@
#warning "This set of I2S APIs has been deprecated, \ #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. \ 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, \ 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 #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -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. 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. 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 config MCPWM_ENABLE_DEBUG_LOG
bool "Enable debug log" bool "Enable debug log"
default n default n

View File

@ -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 * 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; mcpwm_group_t *group = oper->group;
ESP_LOGD(TAG, "del generator (%d,%d,%d)", group->group_id, oper->oper_id, gen->gen_id); 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 // recycle memory resource
ESP_RETURN_ON_ERROR(mcpwm_generator_destroy(gen), TAG, "destroy generator failed"); ESP_RETURN_ON_ERROR(mcpwm_generator_destroy(gen), TAG, "destroy generator failed");
return ESP_OK; return ESP_OK;