parent
4006129dce
commit
a5a4c6a503
|
@ -186,15 +186,12 @@ void rt_hw_board_init(void)
|
||||||
*/
|
*/
|
||||||
void rt_hw_us_delay(rt_uint32_t us)
|
void rt_hw_us_delay(rt_uint32_t us)
|
||||||
{
|
{
|
||||||
rt_uint32_t delta;
|
unsigned int start, now, delta, reload, us_tick;
|
||||||
us = us * (SysTick->LOAD / (1000000 / RT_TICK_PER_SECOND));
|
start = SysTick->VAL;
|
||||||
delta = SysTick->VAL;
|
reload = SysTick->LOAD;
|
||||||
if (delta < us)
|
us_tick = SystemCoreClock / 1000000UL;
|
||||||
{
|
do{
|
||||||
/* wait current OSTick left time gone */
|
now = SysTick->VAL;
|
||||||
while (SysTick->VAL < us);
|
delta = start > now ? start - now : reload + start - now;
|
||||||
us -= delta;
|
} while(delta < us_tick * us);
|
||||||
delta = SysTick->LOAD;
|
|
||||||
}
|
|
||||||
while (delta - SysTick->VAL < us);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue