feat(mcpwm): ETM support mcpwm timer TEZ/TEP events

This commit is contained in:
Chen Chen
2026-02-12 15:00:43 +08:00
parent ffba8f4295
commit e9a62f9a2b
11 changed files with 340 additions and 24 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -23,6 +23,13 @@ typedef struct {
mcpwm_comparator_etm_event_type_t event_type; /*!< MCPWM comparator ETM event type */
} mcpwm_cmpr_etm_event_config_t;
/**
* @brief MCPWM timer ETM event configuration
*/
typedef struct {
mcpwm_timer_etm_event_type_t event_type; /*!< MCPWM timer ETM event type */
} mcpwm_timer_etm_event_config_t;
/**
* @brief Get the ETM event for MCPWM comparator
*
@@ -38,6 +45,21 @@ typedef struct {
*/
esp_err_t mcpwm_comparator_new_etm_event(mcpwm_cmpr_handle_t cmpr, const mcpwm_cmpr_etm_event_config_t *config, esp_etm_event_handle_t *out_event);
/**
* @brief Get the ETM event for MCPWM timer
*
* @note The created ETM event object can be deleted later by calling `esp_etm_del_event`
*
* @param[in] timer MCPWM timer, allocated by `mcpwm_new_timer()`
* @param[in] config MCPWM ETM timer event configuration
* @param[out] out_event Returned ETM event handle
* @return
* - ESP_OK: Get ETM event successfully
* - ESP_ERR_INVALID_ARG: Get ETM event failed because of invalid argument
* - ESP_FAIL: Get ETM event failed because of other error
*/
esp_err_t mcpwm_timer_new_etm_event(mcpwm_timer_handle_t timer, const mcpwm_timer_etm_event_config_t *config, esp_etm_event_handle_t *out_event);
#ifdef __cplusplus
}
#endif
@@ -34,7 +34,7 @@ typedef struct {
uint32_t resolution_hz; /*!< Counter resolution in Hz
The step size of each count tick equals to (1 / resolution_hz) seconds */
mcpwm_timer_count_mode_t count_mode; /*!< Count mode */
uint32_t period_ticks; /*!< Number of count ticks within a period */
uint32_t period_ticks; /*!< Number of count ticks within a period. For up-down mode, the timer peak value is half of the period_ticks */
int intr_priority; /*!< MCPWM timer interrupt priority,
if set to 0, the driver will try to allocate an interrupt with a relative low priority (1,2,3) */
struct {