mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-30 22:05:21 +00:00
feat(mcpwm): support update timer period dynamically
Implement the requirement asked in https://www.esp32.com/viewtopic.php?f=13&t=35919
This commit is contained in:
@@ -218,13 +218,12 @@ static inline void mcpwm_ll_timer_set_clock_prescale(mcpwm_dev_t *mcpwm, int tim
|
||||
* @param peak Peak value
|
||||
* @param symmetric True to set symmetric peak value, False to set asymmetric peak value
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
static inline void mcpwm_ll_timer_set_peak(mcpwm_dev_t *mcpwm, int timer_id, uint32_t peak, bool symmetric)
|
||||
{
|
||||
if (!symmetric) { // in asymmetric mode, period = [0,peak-1]
|
||||
HAL_ASSERT(peak > 0 && peak <= MCPWM_LL_MAX_COUNT_VALUE);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->timer[timer_id].timer_cfg0, timer_period, peak - 1);
|
||||
} else { // in symmetric mode, period = [0,peak-1] + [peak,1]
|
||||
HAL_ASSERT(peak < MCPWM_LL_MAX_COUNT_VALUE);
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(mcpwm->timer[timer_id].timer_cfg0, timer_period, peak);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user