diff --git a/components/driver/Kconfig b/components/driver/Kconfig index 137973094b..c47a39804c 100644 --- a/components/driver/Kconfig +++ b/components/driver/Kconfig @@ -2,23 +2,6 @@ menu "Driver Configurations" 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 - Whether 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_SKIP_LEGACY_CONFLICT_CHECK - bool "Skip legacy conflict check" - default n - help - This configuration option allows the user to bypass the conflict check mechanism with legacy code. - endmenu # Legacy MCPWM Driver Configurations - menu "Legacy RMT Driver Configurations" depends on SOC_RMT_SUPPORTED config RMT_SUPPRESS_DEPRECATE_WARN @@ -45,23 +28,6 @@ menu "Driver Configurations" This configuration option allows the user to bypass the conflict check mechanism with legacy code. endmenu # Legacy I2C Driver Configurationss - menu "Legacy PCNT Driver Configurations" - depends on SOC_PCNT_SUPPORTED - config PCNT_SUPPRESS_DEPRECATE_WARN - bool "Suppress legacy driver deprecated warning" - default n - help - whether to suppress the deprecation warnings when using legacy PCNT driver (driver/pcnt.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 PCNT_SKIP_LEGACY_CONFLICT_CHECK - bool "Skip legacy conflict check" - default n - help - This configuration option allows the user to bypass the conflict check mechanism with legacy code. - endmenu # Legacy PCNT Driver Configurationss - menu "Legacy SDM Driver Configurations" depends on SOC_SDM_SUPPORTED config SDM_SUPPRESS_DEPRECATE_WARN diff --git a/components/esp_driver_mcpwm/include/driver/mcpwm_cap.h b/components/esp_driver_mcpwm/include/driver/mcpwm_cap.h index cea95622d8..13a34b4a8a 100644 --- a/components/esp_driver_mcpwm/include/driver/mcpwm_cap.h +++ b/components/esp_driver_mcpwm/include/driver/mcpwm_cap.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -242,6 +242,20 @@ esp_err_t mcpwm_capture_channel_register_event_callbacks(mcpwm_cap_channel_handl */ esp_err_t mcpwm_capture_channel_trigger_soft_catch(mcpwm_cap_channel_handle_t cap_channel); +/** + * @brief Get the last captured value of the MCPWM capture channel + * + * @note To convert the count value to a time, user can use `mcpwm_capture_timer_get_resolution` to get the resolution of the capture timer. + * + * @param[in] cap_channel MCPWM capture channel handle, allocated by `mcpwm_new_capture_channel()` + * @param[out] value Returned capture value + * @return + * - ESP_OK: Get capture value successfully + * - ESP_ERR_INVALID_ARG: Get capture value failed because of invalid argument + * - ESP_FAIL: Get capture value failed because of other error + */ +esp_err_t mcpwm_capture_get_latched_value(mcpwm_cap_channel_handle_t cap_channel, uint32_t *value); + #ifdef __cplusplus } #endif diff --git a/components/esp_driver_mcpwm/src/mcpwm_cap.c b/components/esp_driver_mcpwm/src/mcpwm_cap.c index c10f61f185..b75d8bb9fa 100644 --- a/components/esp_driver_mcpwm/src/mcpwm_cap.c +++ b/components/esp_driver_mcpwm/src/mcpwm_cap.c @@ -413,6 +413,13 @@ esp_err_t mcpwm_capture_channel_trigger_soft_catch(mcpwm_cap_channel_handle_t ca return ESP_OK; } +esp_err_t mcpwm_capture_get_latched_value(mcpwm_cap_channel_handle_t cap_channel, uint32_t *value) +{ + ESP_RETURN_ON_FALSE(cap_channel && value, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); + *value = mcpwm_ll_capture_get_value(cap_channel->cap_timer->group->hal.dev, cap_channel->cap_chan_id); + return ESP_OK; +} + esp_err_t mcpwm_capture_timer_set_phase_on_sync(mcpwm_cap_timer_handle_t cap_timer, const mcpwm_capture_timer_sync_phase_config_t *config) { ESP_RETURN_ON_FALSE(cap_timer, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); diff --git a/docs/en/api-reference/peripherals/mcpwm.rst b/docs/en/api-reference/peripherals/mcpwm.rst index 07fc304044..2255a0b756 100644 --- a/docs/en/api-reference/peripherals/mcpwm.rst +++ b/docs/en/api-reference/peripherals/mcpwm.rst @@ -960,6 +960,11 @@ Trigger a Software Capture Event Sometimes, the software also wants to trigger a "fake" capture event. The :cpp:func:`mcpwm_capture_channel_trigger_soft_catch` is provided for that purpose. Please note that, even though it is a "fake" capture event, it can still cause an interrupt, thus your capture event callback function gets invoked as well. +Get the Last Captured Value +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you don't want to process the captured value in the capture event callback function, but want to process it in other places, you can call :cpp:func:`mcpwm_capture_get_latched_value` to get the last captured value. + .. only:: SOC_MCPWM_SUPPORT_ETM .. _mcpwm-etm-event-and-task: diff --git a/docs/zh_CN/api-reference/peripherals/mcpwm.rst b/docs/zh_CN/api-reference/peripherals/mcpwm.rst index 7bb4bec77c..3bf8cd5fee 100644 --- a/docs/zh_CN/api-reference/peripherals/mcpwm.rst +++ b/docs/zh_CN/api-reference/peripherals/mcpwm.rst @@ -960,6 +960,11 @@ MCPWM 捕获通道支持在信号上检测到有效边沿时发送通知。须 某些场景下,可能存在需要软件触发“虚假”捕获事件的需求。此时,可以调用 :cpp:func:`mcpwm_capture_channel_trigger_soft_catch` 实现。需注意,此类“虚假”捕获事件仍然会触发中断,并从而调用捕获事件回调函数。 +获得上一次锁存的捕获值 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +如果不想在捕获事件回调函数中处理捕获值,而是想在其他地方处理,可以调用 :cpp:func:`mcpwm_capture_get_latched_value` 获得上一次锁存的捕获值。 + .. only:: SOC_MCPWM_SUPPORT_ETM .. _mcpwm-etm-event-and-task: