summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2021-06-12 19:24:11 +0800
committerGitHub <[email protected]>2021-06-12 19:24:11 +0800
commit03b758c7f336a2d341d56748b3691ea0e0fc783c (patch)
tree8cdb5550d3972186c6ae78bb6882b91a329ae293
parent146a64686e6e876412ea990e42e0e074bff619a4 (diff)
parent4e545551201fa301cc238a898e07021f970735d9 (diff)
Merge pull request #4786 from chunyexixiaoyu/dev
update board.c in k210 bsp
-rw-r--r--bsp/k210/driver/board.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/bsp/k210/driver/board.c b/bsp/k210/driver/board.c
index 3343da0fb7..d9c9279dca 100644
--- a/bsp/k210/driver/board.c
+++ b/bsp/k210/driver/board.c
@@ -1,10 +1,11 @@
/*
- * Copyright (c) 2006-2018, RT-Thread Development Team
+ * Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
+ *2021-06-10 xiaoyu implement rt_hw_us_delay()
*/
#include <rthw.h>
@@ -117,3 +118,19 @@ void rt_hw_cpu_reset(void)
}
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reboot, reset machine);
+
+/**
+ * This function will delay for some us.
+ *
+ * @param us the delay time of us
+ */
+void rt_hw_us_delay(rt_uint32_t usec)
+{
+ rt_uint32_t cycle = read_cycle();
+ rt_uint32_t nop_all = usec * sysctl_clock_get_freq(SYSCTL_CLOCK_CPU) / 1000000UL;
+ while (1)
+ {
+ if(read_cycle() - cycle >= nop_all)
+ break;
+ }
+}