diff --git a/drivers/timers/arch_alarm.c b/drivers/timers/arch_alarm.c index 8c73d5591c7..6c39731432b 100644 --- a/drivers/timers/arch_alarm.c +++ b/drivers/timers/arch_alarm.c @@ -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 /**************************************************************************** diff --git a/drivers/timers/arch_timer.c b/drivers/timers/arch_timer.c index fb2b24939ab..14ebb88dfa9 100644 --- a/drivers/timers/arch_timer.c +++ b/drivers/timers/arch_timer.c @@ -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 /****************************************************************************