/** 函数名:rt_hw_us_delay
* 功能 :微秒延时
* 输入 :延时时间(微秒)
* 输出 :NULL
* 编写人:ZJ
*/
void rt_hw_us_delay(uint32_t us)
{
uint32_t start, now, delta, reload, us_tick;
start = SysTick->VAL;
reload = SysTick->LOAD;
us_tick = SystemCoreClock / 1000000UL;
do {
now = SysTick->VAL;
delta = start > now ? start - now : reload + start - now;
} while(delta < us_tick * us);
}
/** 函数名:rt_hw_ms_delay
* 功能 :毫秒延时
* 输入 :延时时间(毫秒)
* 输出 :NULL
* 编写人:ZJ
*/
void rt_hw_ms_delay(uint32_t ms)
{
do {
rt_hw_us_delay(1000);
}while(ms--);
}
Comments | NOTHING