newPtz/drivers/delay.c

25 lines
506 B
C
Raw Normal View History

2025-09-26 10:17:39 +00:00
#include "delay.h"
/*
@ brief
@ param
@ return
@ note 2022-5-23
*/
void delay_us(int 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);
}
void delay_ms(int ms)//封装了,不能直接替换,不知道为什么
{
rt_thread_mdelay(ms);
}