summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
author杨连钊 <[email protected]>2018-06-11 08:59:30 +0800
committerGitHub <[email protected]>2018-06-11 08:59:30 +0800
commit699bb320735a5fc0d26b196ef75b5387ffa28226 (patch)
tree4f3d142df4fe69a8bce9a83b25cb3fba797f3d26 /bsp
parente1a57f053a4b77cabaf988779c107c54c7995e77 (diff)
[stm32f10x-HAL] add function rt_hw_us_delay
实现rt_hw_us_delay函数
Diffstat (limited to 'bsp')
-rw-r--r--bsp/stm32f10x-HAL/drivers/board.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/bsp/stm32f10x-HAL/drivers/board.c b/bsp/stm32f10x-HAL/drivers/board.c
index 12d5b7d80f..61029214c1 100644
--- a/bsp/stm32f10x-HAL/drivers/board.c
+++ b/bsp/stm32f10x-HAL/drivers/board.c
@@ -113,3 +113,23 @@ void rt_hw_board_init(void)
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
}
+
+/**
+ * This function will delay for some us.
+ *
+ * @param us the delay time of us
+ */
+void rt_hw_us_delay(rt_uint32_t us)
+{
+ rt_uint32_t delta;
+ us = us * (SysTick->LOAD / (1000000 / RT_TICK_PER_SECOND));
+ delta = SysTick->VAL;
+ if (delta < us)
+ {
+ /* wait current OSTick left time gone */
+ while (SysTick->VAL < us);
+ us -= delta;
+ delta = SysTick->LOAD;
+ }
+ while (delta - SysTick->VAL < us);
+}