Merge branch 'feat/s31_support_mcpwm' into 'master'

feat(mcpwm): support mcpwm on esp32s31

Closes IDF-14756 and IDF-14757

See merge request espressif/esp-idf!45803
This commit is contained in:
Chen Chen
2026-03-09 09:27:30 +08:00
37 changed files with 2593 additions and 551 deletions
+4 -4
View File
@@ -48,7 +48,7 @@ Description of the MCPWM functionality is divided into the following sections:
- :ref:`mcpwm-generator-force-actions` - describes how to control the generator output level asynchronously in a forceful way.
- :ref:`mcpwm-synchronization` - describes how to synchronize the MCPWM timers and get a fixed phase difference between the generated PWM signals.
- :ref:`mcpwm-capture` - describes how to use the MCPWM capture module to measure the pulse width of a signal.
:SOC_MCPWM_SUPPORT_ETM: - :ref:`mcpwm-etm-event-and-task` - describes what the events and tasks can be connected to the ETM channel.
:SOC_MCPWM_SUPPORT_ETM and SOC_ETM_SUPPORTED: - :ref:`mcpwm-etm-event-and-task` - describes what the events and tasks can be connected to the ETM channel.
- :ref:`mcpwm-power-management` - describes how different source clocks affects power consumption.
- :ref:`mcpwm-resolution-config` - describes the resolution configuration rules for the MCPWM submodule.
- :ref:`mcpwm-iram-safe` - describes tips on how to make the RMT interrupt work better along with a disabled cache.
@@ -121,7 +121,7 @@ The :cpp:func:`mcpwm_new_comparator` will return a pointer to the allocated comp
On the contrary, calling the :cpp:func:`mcpwm_del_comparator` function will free the allocated comparator object.
.. only:: SOC_MCPWM_SUPPORT_EVENT_COMPARATOR and SOC_MCPWM_SUPPORT_ETM
.. only:: SOC_MCPWM_SUPPORT_EVENT_COMPARATOR and SOC_MCPWM_SUPPORT_ETM and SOC_ETM_SUPPORTED
There's another kind of comparator called "Event Comparator", which **can not** control the final PWM directly but only generates the ETM events at a configurable time stamp. You can allocate an event comparator by calling the :cpp:func:`mcpwm_new_event_comparator` function. This function will return the same handle type as :cpp:func:`mcpwm_new_comparator`, but with a different configuration structure :cpp:type:`mcpwm_event_comparator_config_t`. For more information, please refer to :ref:`mcpwm-etm-event-and-task`.
@@ -953,7 +953,7 @@ 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
.. only:: SOC_MCPWM_SUPPORT_ETM and SOC_ETM_SUPPORTED
.. _mcpwm-etm-event-and-task:
@@ -966,7 +966,7 @@ If you don't want to process the captured value in the capture event callback fu
.. _mcpwm-power-management:
.. only:: not SOC_MCPWM_SUPPORT_ETM
.. only:: not (SOC_MCPWM_SUPPORT_ETM and SOC_ETM_SUPPORTED)
.. _mcpwm-power-management:
@@ -48,7 +48,7 @@ MCPWM 外设是一个多功能 PWM 生成器,集成多个子模块,在电力
- :ref:`mcpwm-generator-force-actions` - 介绍如何强制异步控制生成器的输出水平。
- :ref:`mcpwm-synchronization` - 介绍如何同步 MCPWM 定时器,并确保生成的最终输出 PWM 信号具有固定的相位差。
- :ref:`mcpwm-capture` - 介绍如何使用 MCPWM 捕获模块测量信号脉宽。
:SOC_MCPWM_SUPPORT_ETM: - :ref:`mcpwm-etm-event-and-task` - MCPWM 提供了哪些事件和任务可以连接到 ETM 通道上。
:SOC_MCPWM_SUPPORT_ETM and SOC_ETM_SUPPORTED: - :ref:`mcpwm-etm-event-and-task` - MCPWM 提供了哪些事件和任务可以连接到 ETM 通道上。
- :ref:`mcpwm-power-management` - 介绍不同的时钟源对功耗的影响。
- :ref:`mcpwm-resolution-config` - 介绍 MCPWM 子模块的分辨率配置规则。
- :ref:`mcpwm-iram-safe` - 介绍如何协调 RMT 中断与禁用缓存。
@@ -121,7 +121,7 @@ MCPWM 比较器
反之,调用 :cpp:func:`mcpwm_del_comparator` 函数将释放已分配的比较器。
.. only:: SOC_MCPWM_SUPPORT_EVENT_COMPARATOR and SOC_MCPWM_SUPPORT_ETM
.. only:: SOC_MCPWM_SUPPORT_EVENT_COMPARATOR and SOC_MCPWM_SUPPORT_ETM and SOC_ETM_SUPPORTED
MCPWM 中还有另外一种比较器 —— “事件比较器”,它不能直接控制 PWM 的输出,只能用来产生 EMT 子系统中使用到的事件。事件比较器能够设置的阈值也是可配的。调用 :cpp:func:`mcpwm_new_event_comparator` 函数可以申请一个事件比较器,该函数返回的句柄类型和 :cpp:func:`mcpwm_new_comparator` 函数一样,但是需要的配置结构体是不同的。事件比较器的配置位于 :cpp:type:`mcpwm_event_comparator_config_t`。更多相关内容请参阅 :ref:`mcpwm-etm-event-and-task`
@@ -953,7 +953,7 @@ MCPWM 捕获通道支持在信号上检测到有效边沿时发送通知。须
如果不想在捕获事件回调函数中处理捕获值,而是想在其他地方处理,可以调用 :cpp:func:`mcpwm_capture_get_latched_value` 获得上一次锁存的捕获值。
.. only:: SOC_MCPWM_SUPPORT_ETM
.. only:: SOC_MCPWM_SUPPORT_ETM and SOC_ETM_SUPPORTED
.. _mcpwm-etm-event-and-task:
@@ -962,11 +962,12 @@ MCPWM 捕获通道支持在信号上检测到有效边沿时发送通知。须
MCPWM 的定时器和比较器可以产生事件,这些事件可以连接到 :doc:`ETM </api-reference/peripherals/etm>` 模块。:cpp:type:`mcpwm_timer_etm_event_type_t`:cpp:type:`mcpwm_comparator_etm_event_type_t` 中分别列出了 MCPWM 定时器和比较器能够产生的事件类型。用户可以通过调用 :cpp:func:`mcpwm_timer_new_etm_event`:cpp:func:`mcpwm_comparator_new_etm_event` 来获得相应事件的 ETM event 句柄。
关于如何将 MCPWM 事件连接到 ETM 通道中,请参阅 :doc:`ETM </api-reference/peripherals/etm>` 文档。
.. _mcpwm-power-management:
.. only:: not SOC_MCPWM_SUPPORT_ETM
.. only:: not (SOC_MCPWM_SUPPORT_ETM and SOC_ETM_SUPPORTED)
.. _mcpwm-power-management: