mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
refactor(mcpwm): add RCC related LL functions
This commit is contained in:
@@ -72,10 +72,6 @@ static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph)
|
||||
return HP_SYS_CLKRST_REG_I3C_MST_CLK_EN;
|
||||
case PERIPH_CAM_MODULE:
|
||||
return HP_SYS_CLKRST_REG_CAM_CLK_EN;
|
||||
case PERIPH_MCPWM0_MODULE:
|
||||
return HP_SYS_CLKRST_REG_MCPWM0_APB_CLK_EN;
|
||||
case PERIPH_MCPWM1_MODULE:
|
||||
return HP_SYS_CLKRST_REG_MCPWM1_APB_CLK_EN;
|
||||
case PERIPH_SYSTIMER_MODULE:
|
||||
return HP_SYS_CLKRST_REG_SYSTIMER_CLK_EN;
|
||||
case PERIPH_LEDC_MODULE:
|
||||
@@ -104,8 +100,6 @@ static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph)
|
||||
return HP_SYS_CLKRST_REG_CRYPTO_ECDSA_CLK_EN;
|
||||
case PERIPH_ISP_MODULE:
|
||||
return HP_SYS_CLKRST_REG_ISP_CLK_EN;
|
||||
case PERIPH_PCNT_MODULE:
|
||||
return HP_SYS_CLKRST_REG_PCNT_APB_CLK_EN;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -155,10 +149,6 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
|
||||
return HP_SYS_CLKRST_REG_RST_EN_I2C1;
|
||||
case PERIPH_RMT_MODULE:
|
||||
return HP_SYS_CLKRST_REG_RST_EN_RMT;
|
||||
case PERIPH_MCPWM0_MODULE:
|
||||
return HP_SYS_CLKRST_REG_RST_EN_PWM0;
|
||||
case PERIPH_MCPWM1_MODULE:
|
||||
return HP_SYS_CLKRST_REG_RST_EN_PWM1;
|
||||
case PERIPH_TWAI0_MODULE:
|
||||
return HP_SYS_CLKRST_REG_RST_EN_CAN0;
|
||||
case PERIPH_TWAI1_MODULE:
|
||||
@@ -167,8 +157,6 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
|
||||
return HP_SYS_CLKRST_REG_RST_EN_CAN2;
|
||||
case PERIPH_LEDC_MODULE:
|
||||
return HP_SYS_CLKRST_REG_RST_EN_LEDC;
|
||||
case PERIPH_PCNT_MODULE:
|
||||
return HP_SYS_CLKRST_REG_RST_EN_PCNT;
|
||||
case PERIPH_PARLIO_MODULE:
|
||||
return HP_SYS_CLKRST_REG_RST_EN_PARLIO | HP_SYS_CLKRST_REG_RST_EN_PARLIO_RX | HP_SYS_CLKRST_REG_RST_EN_PARLIO_TX;
|
||||
case PERIPH_I2S0_MODULE:
|
||||
@@ -263,10 +251,6 @@ static inline uint32_t periph_ll_get_clk_en_reg(periph_module_t periph)
|
||||
case PERIPH_I3C_MODULE:
|
||||
case PERIPH_CAM_MODULE:
|
||||
return HP_SYS_CLKRST_PERI_CLK_CTRL119_REG;
|
||||
case PERIPH_MCPWM0_MODULE:
|
||||
case PERIPH_MCPWM1_MODULE:
|
||||
case PERIPH_PCNT_MODULE:
|
||||
return HP_SYS_CLKRST_SOC_CLK_CTRL2_REG;
|
||||
case PERIPH_SYSTIMER_MODULE:
|
||||
case PERIPH_LEDC_MODULE:
|
||||
case PERIPH_RMT_MODULE:
|
||||
@@ -316,13 +300,10 @@ static inline uint32_t periph_ll_get_rst_en_reg(periph_module_t periph)
|
||||
case PERIPH_I2C1_MODULE:
|
||||
return HP_SYS_CLKRST_HP_RST_EN1_REG;
|
||||
case PERIPH_RMT_MODULE:
|
||||
case PERIPH_MCPWM0_MODULE:
|
||||
case PERIPH_MCPWM1_MODULE:
|
||||
case PERIPH_TWAI0_MODULE:
|
||||
case PERIPH_TWAI1_MODULE:
|
||||
case PERIPH_TWAI2_MODULE:
|
||||
case PERIPH_LEDC_MODULE:
|
||||
case PERIPH_PCNT_MODULE:
|
||||
case PERIPH_PARLIO_MODULE:
|
||||
case PERIPH_I2S0_MODULE:
|
||||
return HP_SYS_CLKRST_HP_RST_EN1_REG;
|
||||
|
@@ -93,6 +93,45 @@ typedef enum {
|
||||
|
||||
////////////////////////////////////////MCPWM Group Specific////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @brief Enable the bus clock for MCPWM module
|
||||
*
|
||||
* @param group_id Group ID
|
||||
* @param enable true to enable, false to disable
|
||||
*/
|
||||
static inline void mcpwm_ll_enable_bus_clock(int group_id, bool enable)
|
||||
{
|
||||
if (group_id == 0) {
|
||||
HP_SYS_CLKRST.soc_clk_ctrl2.reg_mcpwm0_apb_clk_en = enable;
|
||||
} else {
|
||||
HP_SYS_CLKRST.soc_clk_ctrl2.reg_mcpwm1_apb_clk_en = enable;
|
||||
}
|
||||
}
|
||||
|
||||
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||
#define mcpwm_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_enable_bus_clock(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Reset the MCPWM module
|
||||
*
|
||||
* @param group_id Group ID
|
||||
*/
|
||||
static inline void mcpwm_ll_reset_register(int group_id)
|
||||
{
|
||||
if (group_id == 0) {
|
||||
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_pwm0 = 1;
|
||||
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_pwm0 = 0;
|
||||
} else {
|
||||
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_pwm1 = 1;
|
||||
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_pwm1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||
#define mcpwm_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_reset_register(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Set the clock source for MCPWM
|
||||
*
|
||||
@@ -123,6 +162,10 @@ static inline void mcpwm_ll_group_set_clock_source(mcpwm_dev_t *mcpwm, soc_modul
|
||||
}
|
||||
}
|
||||
|
||||
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||
#define mcpwm_ll_group_set_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_group_set_clock_source(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Enable MCPWM module clock
|
||||
*
|
||||
@@ -138,6 +181,10 @@ static inline void mcpwm_ll_group_enable_clock(mcpwm_dev_t *mcpwm, bool en)
|
||||
}
|
||||
}
|
||||
|
||||
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||
#define mcpwm_ll_group_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_group_enable_clock(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Set the MCPWM group clock prescale
|
||||
*
|
||||
@@ -155,6 +202,10 @@ static inline void mcpwm_ll_group_set_clock_prescale(mcpwm_dev_t *mcpwm, int pre
|
||||
}
|
||||
}
|
||||
|
||||
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
|
||||
#define mcpwm_ll_group_set_clock_prescale(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_group_set_clock_prescale(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Enable update MCPWM active registers from shadow registers
|
||||
*
|
||||
|
Reference in New Issue
Block a user