[stm32][drv_tim.c] enable timer clock

This commit is contained in:
Meco Man 2023-03-15 17:58:10 -04:00 committed by Man, Jianting (Meco)
parent f80e61d6ff
commit de963feef4
1 changed files with 7 additions and 15 deletions

View File

@ -366,23 +366,15 @@ static void timer_init(struct rt_hwtimer_device *timer, rt_uint32_t state)
LOG_E("%s init failed", tim_device->name); LOG_E("%s init failed", tim_device->name);
return; return;
} }
else
{
/* set the TIMx priority */
HAL_NVIC_SetPriority(tim_device->tim_irqn, 3, 0);
/* enable the TIMx global Interrupt */
HAL_NVIC_EnableIRQ(tim_device->tim_irqn);
/* clear update flag */
__HAL_TIM_CLEAR_FLAG(tim, TIM_FLAG_UPDATE);
/* enable update request source */
__HAL_TIM_URS_ENABLE(tim);
stm32_tim_enable_clock(tim);
HAL_NVIC_SetPriority(tim_device->tim_irqn, 3, 0); /* set the TIMx priority */
HAL_NVIC_EnableIRQ(tim_device->tim_irqn); /* enable the TIMx global Interrupt */
__HAL_TIM_CLEAR_FLAG(tim, TIM_FLAG_UPDATE); /* clear update flag */
__HAL_TIM_URS_ENABLE(tim); /* enable update request source */
LOG_D("%s init success", tim_device->name); LOG_D("%s init success", tim_device->name);
} }
} }
}
static rt_err_t timer_start(rt_hwtimer_t *timer, rt_uint32_t t, rt_hwtimer_mode_t opmode) static rt_err_t timer_start(rt_hwtimer_t *timer, rt_uint32_t t, rt_hwtimer_mode_t opmode)
{ {