4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-01 01:30:26 +08:00

[STM32][common]更新rt_hw_us_delay函数,以支持设置更高延时

* 未判断设置延时数是否会溢出
This commit is contained in:
wdfk-prog 2022-12-22 16:46:15 +08:00 committed by Man, Jianting (Meco)
parent 262392a69c
commit db6ee55379

View File

@ -133,11 +133,11 @@ void _Error_Handler(char *s, int num)
*/ */
void rt_hw_us_delay(rt_uint32_t us) void rt_hw_us_delay(rt_uint32_t us)
{ {
rt_uint32_t ticks; rt_uint64_t ticks;
rt_uint32_t told, tnow, tcnt = 0; rt_uint32_t told, tnow, tcnt = 0;
rt_uint32_t reload = SysTick->LOAD; rt_uint32_t reload = SysTick->LOAD;
ticks = us * reload / (1000000 / RT_TICK_PER_SECOND); ticks = us * (reload / (1000000 / RT_TICK_PER_SECOND));
told = SysTick->VAL; told = SysTick->VAL;
while (1) while (1)
{ {