__weak uint16_t HAL_GetTick_us(void)
{
return __HAL_TIM_GetCounter (&htim6 );//获取定时器6计数器的值
}
__weak void HAL_Delay_us(uint16_t Delay)
{
uint16_t tickstart = HAL_GetTick_us();//计数器初始值
uint16_t wait = Delay;//需要延时的值
HAL_TIM_Base_Start (&htim6); //打开定时器
while ((HAL_GetTick_us() - tickstart) < wait)//等待
{
}
HAL_TIM_Base_Stop(&htim6); //关闭定时器
__HAL_TIM_SetCounter (&htim6,0 );//定时器计数器清零,往往可以省略,会自动清零
}
blog.csdn.net/m0_65565606/article/details/122883740 |