summaryrefslogtreecommitdiff
path: root/src/clock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/clock.c')
-rw-r--r--src/clock.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/clock.c b/src/clock.c
index 36e26238ed..734c0d5014 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -108,13 +108,23 @@ void rt_tick_increase(void)
* This function will calculate the tick from millisecond.
*
* @param ms the specified millisecond
+ * - Negative Number wait forever
+ * - Zero not wait
+ * - Max 0x7fffffff
*
* @return the calculated tick
*/
-rt_tick_t rt_tick_from_millisecond(rt_uint32_t ms)
+int rt_tick_from_millisecond(rt_int32_t ms)
{
+ int tick;
+
+ if (ms < 0)
+ tick = RT_WAITING_FOREVER;
+ else
+ tick = (RT_TICK_PER_SECOND * ms + 999) / 1000;
+
/* return the calculated tick */
- return (RT_TICK_PER_SECOND * ms + 999) / 1000;
+ return tick;
}
RTM_EXPORT(rt_tick_from_millisecond);