timers: add weak function up_timer_gettime()

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2024-08-22 23:14:42 +08:00 committed by Xiang Xiao
parent e334df6d9a
commit ccd87767da
2 changed files with 26 additions and 0 deletions

View File

@ -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
/****************************************************************************

View File

@ -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
/****************************************************************************