未验证 提交 52e1d762 编写于 作者: o777788's avatar o777788 提交者: GitHub

[imxrt 1170]Support us delay (#6424)

* add us delay

* formating file
上级 8d0392e3
......@@ -1273,10 +1273,6 @@ void imxrt_can_pins_init(void)
}
#endif
void rt_hw_us_delay(rt_uint32_t us)
{
}
void rt_hw_board_init()
{
BOARD_ConfigMPU();
......
......@@ -76,7 +76,8 @@ if GetDepend('RT_USING_USB_HOST'):
if GetDepend('BSP_USING_PULSE_ENCODER'):
src += ['drv_pulse_encoder.c']
src += ['drv_common.c']
path = [cwd]
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES=CPPDEFINES)
......
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-09-13 xjy198903 first implementation
*/
#include <rtthread.h>
#include "clock_config.h"
void rt_hw_us_delay(rt_uint32_t us)
{
rt_uint32_t ticks;
rt_uint32_t told, tnow, tcnt = 0;
rt_uint32_t reload = SysTick->LOAD;
ticks = us * reload / (1000000 / RT_TICK_PER_SECOND);
told = SysTick->VAL;
while (1)
{
tnow = SysTick->VAL;
if (tnow != told)
{
if (tnow < told)
{
tcnt += told - tnow;
}
else
{
tcnt += reload - tnow + told;
}
told = tnow;
if (tcnt >= ticks)
{
break;
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册