Skip to content

Commit ccd8776

Browse files
GUIDINGLIxiaoxiang781216
authored andcommitted
timers: add weak function up_timer_gettime()
Signed-off-by: ligd <[email protected]>
1 parent e334df6 commit ccd8776

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

drivers/timers/arch_alarm.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ int weak_function up_timer_gettick(FAR clock_t *ticks)
241241

242242
return ret;
243243
}
244+
245+
int weak_function up_timer_gettime(struct timespec *ts)
246+
{
247+
int ret = -EAGAIN;
248+
249+
if (g_oneshot_lower != NULL)
250+
{
251+
ret = ONESHOT_CURRENT(g_oneshot_lower, ts);
252+
}
253+
254+
return ret;
255+
}
244256
#endif
245257

246258
/****************************************************************************

drivers/timers/arch_timer.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,20 @@ int weak_function up_timer_gettick(FAR clock_t *ticks)
283283

284284
return ret;
285285
}
286+
287+
int weak_function up_timer_gettime(struct timespec *ts)
288+
{
289+
int ret = -EAGAIN;
290+
291+
if (g_timer.lower != NULL)
292+
{
293+
ts->tv_sec = current_usec() / USEC_PER_SEC;
294+
ts->tv_nsec = (current_usec() % USEC_PER_SEC) * NSEC_PER_USEC;
295+
ret = OK;
296+
}
297+
298+
return ret;
299+
}
286300
#endif
287301

288302
/****************************************************************************

0 commit comments

Comments
 (0)