mirror of
https://github.com/apache/nuttx.git
synced 2026-03-27 02:29:15 +08:00
timers: add weak function up_timer_gettime()
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
@@ -241,6 +241,18 @@ int weak_function up_timer_gettick(FAR clock_t *ticks)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int weak_function up_timer_gettime(struct timespec *ts)
|
||||
{
|
||||
int ret = -EAGAIN;
|
||||
|
||||
if (g_oneshot_lower != NULL)
|
||||
{
|
||||
ret = ONESHOT_CURRENT(g_oneshot_lower, ts);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -283,6 +283,20 @@ int weak_function up_timer_gettick(FAR clock_t *ticks)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int weak_function up_timer_gettime(struct timespec *ts)
|
||||
{
|
||||
int ret = -EAGAIN;
|
||||
|
||||
if (g_timer.lower != NULL)
|
||||
{
|
||||
ts->tv_sec = current_usec() / USEC_PER_SEC;
|
||||
ts->tv_nsec = (current_usec() % USEC_PER_SEC) * NSEC_PER_USEC;
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user