未验证 提交 699bb320 编写于 作者: 杨连钊 提交者: GitHub

[stm32f10x-HAL] add function rt_hw_us_delay

实现rt_hw_us_delay函数
上级 e1a57f05
......@@ -113,3 +113,23 @@ void rt_hw_board_init(void)
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
}
/**
* This function will delay for some us.
*
* @param us the delay time of us
*/
void rt_hw_us_delay(rt_uint32_t us)
{
rt_uint32_t delta;
us = us * (SysTick->LOAD / (1000000 / RT_TICK_PER_SECOND));
delta = SysTick->VAL;
if (delta < us)
{
/* wait current OSTick left time gone */
while (SysTick->VAL < us);
us -= delta;
delta = SysTick->LOAD;
}
while (delta - SysTick->VAL < us);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册