summaryrefslogtreecommitdiff
path: root/src/clock.c
diff options
context:
space:
mode:
authortmmdh <[email protected]>2021-01-20 18:45:20 +0800
committertmmdh <[email protected]>2021-01-20 18:45:20 +0800
commit9db4d446382426d215ffe79f60920c98a8b1be53 (patch)
treea3bd61199194d5f8251bf7ee889e22baedf5dc31 /src/clock.c
parent55c0a9f27900d19556d52110be6397f3ee15a6c3 (diff)
parentafd575105d2fdd29fb003fb49c6e4f5446f824ce (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'src/clock.c')
-rw-r--r--src/clock.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/clock.c b/src/clock.c
index a91cd829b6..66923e5c00 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -13,6 +13,7 @@
* 2010-07-13 Bernard fix rt_tick_from_millisecond issue found by kuronca
* 2011-06-26 Bernard add rt_tick_set function.
* 2018-11-22 Jesven add per cpu tick
+ * 2020-12-29 Meco Man add function rt_tick_get_millisecond()
*/
#include <rthw.h>
@@ -25,17 +26,6 @@ static rt_tick_t rt_tick = 0;
#endif
/**
- * This function will initialize system tick and set it to zero.
- * @ingroup SystemInit
- *
- * @deprecated since 1.1.0, this function does not need to be invoked
- * in the system initialization.
- */
-void rt_system_tick_init(void)
-{
-}
-
-/**
* @addtogroup Clock
*/
@@ -127,5 +117,21 @@ rt_tick_t rt_tick_from_millisecond(rt_int32_t ms)
}
RTM_EXPORT(rt_tick_from_millisecond);
+/**
+ * This function will provide the passed millisecond from boot.
+ *
+ * @return passed millisecond from boot
+ */
+RT_WEAK rt_tick_t rt_tick_get_millisecond(void)
+{
+#if 1000 % RT_TICK_PER_SECOND == 0u
+ return rt_tick_get() * (1000u / RT_TICK_PER_SECOND);
+#else
+ #warning "rt-thread cannot provide a correct 1ms-based tick any longer,\
+ please redefine this function in another file by using a high-precision hard-timer."
+ return 0;
+#endif
+}
+
/**@}*/