mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 00:51:42 +01:00 
			
		
		
		
	Merge branch 'feature/mcpwm_support_c5' into 'master'
feat(mcpwm): add driver support on esp32c5 Closes IDF-8709 and IDF-9101 See merge request espressif/esp-idf!29876
This commit is contained in:
		@@ -101,7 +101,7 @@ static inline void mcpwm_ll_reset_register(int group_id)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Enable MCPWM module clock
 | 
			
		||||
 * @brief Enable MCPWM function clock
 | 
			
		||||
 *
 | 
			
		||||
 * @param group_id Group ID
 | 
			
		||||
 * @param en true to enable, false to disable
 | 
			
		||||
@@ -115,12 +115,12 @@ static inline void mcpwm_ll_group_enable_clock(int group_id, bool en)
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Set the clock source for MCPWM
 | 
			
		||||
 *
 | 
			
		||||
 * @param mcpwm Peripheral instance address
 | 
			
		||||
 * @param group_id Group ID
 | 
			
		||||
 * @param clk_src Clock source for the MCPWM peripheral
 | 
			
		||||
 */
 | 
			
		||||
static inline void mcpwm_ll_group_set_clock_source(mcpwm_dev_t *mcpwm, soc_module_clk_t clk_src)
 | 
			
		||||
static inline void mcpwm_ll_group_set_clock_source(int group_id, soc_module_clk_t clk_src)
 | 
			
		||||
{
 | 
			
		||||
    (void)mcpwm; // only one MCPWM instance
 | 
			
		||||
    (void)group_id;
 | 
			
		||||
    switch (clk_src) {
 | 
			
		||||
    case SOC_MOD_CLK_PLL_F160M:
 | 
			
		||||
        PCR.pwm_clk_conf.pwm_clkm_sel = 1;
 | 
			
		||||
@@ -137,12 +137,12 @@ static inline void mcpwm_ll_group_set_clock_source(mcpwm_dev_t *mcpwm, soc_modul
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Set the MCPWM group clock prescale
 | 
			
		||||
 *
 | 
			
		||||
 * @param mcpwm Peripheral instance address
 | 
			
		||||
 * @param group_id Group ID
 | 
			
		||||
 * @param prescale Prescale value
 | 
			
		||||
 */
 | 
			
		||||
static inline void mcpwm_ll_group_set_clock_prescale(mcpwm_dev_t *mcpwm, int prescale)
 | 
			
		||||
static inline void mcpwm_ll_group_set_clock_prescale(int group_id, int prescale)
 | 
			
		||||
{
 | 
			
		||||
    (void)mcpwm; // only one MCPWM instance
 | 
			
		||||
    (void)group_id;
 | 
			
		||||
    // group clock: PWM_clk = source_clock / (prescale)
 | 
			
		||||
    HAL_ASSERT(prescale <= 256 && prescale > 0);
 | 
			
		||||
    HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.pwm_clk_conf, pwm_div_num, prescale - 1);
 | 
			
		||||
@@ -218,7 +218,7 @@ static inline uint32_t mcpwm_ll_intr_get_status(mcpwm_dev_t *mcpwm)
 | 
			
		||||
 * @brief Clear MCPWM interrupt status by mask
 | 
			
		||||
 *
 | 
			
		||||
 * @param mcpwm Peripheral instance address
 | 
			
		||||
 * @param mask Interupt status mask
 | 
			
		||||
 * @param mask Interrupt status mask
 | 
			
		||||
 */
 | 
			
		||||
__attribute__((always_inline))
 | 
			
		||||
static inline void mcpwm_ll_intr_clear_status(mcpwm_dev_t *mcpwm, uint32_t mask)
 | 
			
		||||
@@ -1649,19 +1649,6 @@ static inline void mcpwm_ll_etm_enable_comparator_event(mcpwm_dev_t *mcpwm, int
 | 
			
		||||
/////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)//////////////////////////////
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
static inline uint32_t mcpwm_ll_group_get_clock_prescale(mcpwm_dev_t *mcpwm)
 | 
			
		||||
{
 | 
			
		||||
    (void)mcpwm; // only one MCPWM instance
 | 
			
		||||
    return HAL_FORCE_READ_U32_REG_FIELD(PCR.pwm_clk_conf, pwm_div_num) + 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline uint32_t mcpwm_ll_timer_get_clock_prescale(mcpwm_dev_t *mcpwm, int timer_id)
 | 
			
		||||
{
 | 
			
		||||
    mcpwm_timer_cfg0_reg_t cfg0;
 | 
			
		||||
    cfg0.val = mcpwm->timer[timer_id].timer_cfg0.val;
 | 
			
		||||
    return cfg0.timer_prescale + 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline uint32_t mcpwm_ll_timer_get_peak(mcpwm_dev_t *mcpwm, int timer_id, bool symmetric)
 | 
			
		||||
{
 | 
			
		||||
    return HAL_FORCE_READ_U32_REG_FIELD(mcpwm->timer[timer_id].timer_cfg0, timer_period) + (symmetric ? 0 : 1);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user