mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(mcpwm): ETM support mcpwm timer TEZ/TEP events
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <stdio.h>
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/mcpwm_struct.h"
|
||||
#include "soc/mcpwm_reg.h"
|
||||
#include "soc/clk_tree_defs.h"
|
||||
#include "soc/hp_sys_clkrst_struct.h"
|
||||
#include "hal/mcpwm_types.h"
|
||||
@@ -61,6 +62,18 @@ extern "C" {
|
||||
#define MCPWM_LL_GEN_ACTION_TO_REG_CAL(action) ((uint8_t[]) {0, 1, 2, 3}[(action)])
|
||||
#define MCPWM_LL_BRAKE_MODE_TO_REG_VAL(mode) ((uint8_t[]) {0, 1}[(mode)])
|
||||
|
||||
#define MCPWM_LL_TIMER_ETM_EVENT_TABLE(group, timer_id, event) \
|
||||
(uint32_t[2][MCPWM_TIMER_ETM_EVENT_MAX]){ \
|
||||
{ \
|
||||
[MCPWM_TIMER_ETM_EVENT_TEZ] = MCPWM0_EVT_TIMER0_TEZ + timer_id, \
|
||||
[MCPWM_TIMER_ETM_EVENT_TEP] = MCPWM0_EVT_TIMER0_TEP + timer_id, \
|
||||
}, \
|
||||
{ \
|
||||
[MCPWM_TIMER_ETM_EVENT_TEZ] = MCPWM1_EVT_TIMER0_TEZ + timer_id, \
|
||||
[MCPWM_TIMER_ETM_EVENT_TEP] = MCPWM1_EVT_TIMER0_TEP + timer_id, \
|
||||
}, \
|
||||
}[group][event]
|
||||
|
||||
// MCPWM ETM comparator event table
|
||||
#define MCPWM_LL_ETM_COMPARATOR_EVENT_TABLE(group, oper_id, cmpr_id, event) \
|
||||
(uint32_t[2][MCPWM_CMPR_ETM_EVENT_MAX]){ \
|
||||
@@ -1733,6 +1746,29 @@ static inline void mcpwm_ll_etm_enable_evt_comparator_event(mcpwm_dev_t *mcpwm,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable timer ETM event
|
||||
*
|
||||
* @param mcpwm Peripheral instance address
|
||||
* @param timer_id Timer ID, index from 0 to 2
|
||||
* @param event_type Timer ETM event type (TEZ or TEP)
|
||||
* @param en True: enable ETM module, False: disable ETM module
|
||||
*/
|
||||
static inline void mcpwm_ll_etm_enable_timer_event(mcpwm_dev_t *mcpwm, int timer_id, mcpwm_timer_etm_event_type_t event_type, bool en)
|
||||
{
|
||||
uint32_t bit_offset;
|
||||
if (event_type == MCPWM_TIMER_ETM_EVENT_TEZ) {
|
||||
bit_offset = timer_id + MCPWM_EVT_TIMER0_TEZ_EN_S; // TEZ events start at bit 3
|
||||
} else { // MCPWM_TIMER_ETM_EVENT_TEP
|
||||
bit_offset = timer_id + MCPWM_EVT_TIMER0_TEP_EN_S; // TEP events start at bit 6
|
||||
}
|
||||
if (en) {
|
||||
mcpwm->evt_en.val |= 1 << bit_offset;
|
||||
} else {
|
||||
mcpwm->evt_en.val &= ~(1 << bit_offset);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////Deprecated Functions//////////////////////////////////////////////////////////
|
||||
/////////////////////////////The following functions are only used by the legacy driver/////////////////////////////////
|
||||
/////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)//////////////////////////////
|
||||
@@ -1774,7 +1810,6 @@ static inline void mcpwm_ll_intr_clear_capture_status(mcpwm_dev_t *mcpwm, uint32
|
||||
{
|
||||
mcpwm->int_clr.val = (capture_mask & 0x07) << 27;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user