mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-01 22:38:30 +00:00
etm: added etm channel allocator
This commit is contained in:
@@ -56,6 +56,8 @@ static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph)
|
||||
return PCR_GDMA_CLK_EN;
|
||||
case PERIPH_MCPWM0_MODULE:
|
||||
return PCR_PWM_CLK_EN;
|
||||
case PERIPH_ETM_MODULE:
|
||||
return PCR_ETM_CLK_EN;
|
||||
case PERIPH_AES_MODULE:
|
||||
return PCR_AES_CLK_EN;
|
||||
case PERIPH_SHA_MODULE:
|
||||
@@ -128,6 +130,8 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
|
||||
return PCR_GDMA_RST_EN;
|
||||
case PERIPH_MCPWM0_MODULE:
|
||||
return PCR_PWM_RST_EN;
|
||||
case PERIPH_ETM_MODULE:
|
||||
return PCR_ETM_RST_EN;
|
||||
case PERIPH_ECC_MODULE:
|
||||
return PCR_ECC_RST_EN;
|
||||
case PERIPH_TEMPSENSOR_MODULE:
|
||||
@@ -224,6 +228,8 @@ static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph)
|
||||
return PCR_GDMA_CONF_REG;
|
||||
case PERIPH_MCPWM0_MODULE:
|
||||
return PCR_PWM_CONF_REG;
|
||||
case PERIPH_ETM_MODULE:
|
||||
return PCR_ETM_CONF_REG;
|
||||
case PERIPH_AES_MODULE:
|
||||
return PCR_AES_CONF_REG;
|
||||
case PERIPH_SHA_MODULE:
|
||||
@@ -282,6 +288,8 @@ static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph)
|
||||
return PCR_GDMA_CONF_REG;
|
||||
case PERIPH_MCPWM0_MODULE:
|
||||
return PCR_PWM_CONF_REG;
|
||||
case PERIPH_ETM_MODULE:
|
||||
return PCR_ETM_CONF_REG;
|
||||
case PERIPH_AES_MODULE:
|
||||
return PCR_AES_CONF_REG;
|
||||
case PERIPH_SHA_MODULE:
|
||||
|
103
components/hal/esp32c6/include/hal/etm_ll.h
Normal file
103
components/hal/esp32c6/include/hal/etm_ll.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
// Note that most of the register operations in this layer are non-atomic operations.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
#include "soc/soc_etm_struct.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable the clock for ETM module
|
||||
*
|
||||
* @param hw ETM register base address
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
static inline void etm_ll_enable_clock(soc_etm_dev_t *hw, bool enable)
|
||||
{
|
||||
hw->clk_en.clk_en = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable ETM channel
|
||||
*
|
||||
* @param hw ETM register base address
|
||||
* @param chan Channel ID
|
||||
*/
|
||||
static inline void etm_ll_enable_channel(soc_etm_dev_t *hw, uint32_t chan)
|
||||
{
|
||||
if (chan < 32) {
|
||||
hw->ch_ena_ad0_set.val = 1 << chan;
|
||||
} else {
|
||||
hw->ch_ena_ad1_set.val = 1 << (chan - 32);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable ETM channel
|
||||
*
|
||||
* @param hw ETM register base address
|
||||
* @param chan Channel ID
|
||||
*/
|
||||
static inline void etm_ll_disable_channel(soc_etm_dev_t *hw, uint32_t chan)
|
||||
{
|
||||
if (chan < 32) {
|
||||
hw->ch_ena_ad0_clr.val = 1 << chan;
|
||||
} else {
|
||||
hw->ch_ena_ad1_clr.val = 1 << (chan - 32);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check whether the ETM channel is enabled or not
|
||||
*
|
||||
* @param hw ETM register base address
|
||||
* @param chan Channel ID
|
||||
* @return true if the channel is enabled, false otherwise
|
||||
*/
|
||||
static inline bool etm_ll_is_channel_enabled(soc_etm_dev_t *hw, uint32_t chan)
|
||||
{
|
||||
if (chan < 32) {
|
||||
return hw->ch_ena_ad0.val & (1 << chan);
|
||||
} else {
|
||||
return hw->ch_ena_ad1.val & (1 << (chan - 32));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the input event for the ETM channel
|
||||
*
|
||||
* @param hw ETM register base address
|
||||
* @param chan Channel ID
|
||||
* @param event Event ID
|
||||
*/
|
||||
static inline void etm_ll_channel_set_event(soc_etm_dev_t *hw, uint32_t chan, uint32_t event)
|
||||
{
|
||||
hw->channel[chan].evt_id.evt_id = event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the output task for the ETM channel
|
||||
*
|
||||
* @param hw ETM register base address
|
||||
* @param chan Channel ID
|
||||
* @param task Task ID
|
||||
*/
|
||||
static inline void etm_ll_channel_set_task(soc_etm_dev_t *hw, uint32_t chan, uint32_t task)
|
||||
{
|
||||
hw->channel[chan].task_id.task_id = task;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user