summaryrefslogtreecommitdiff
path: root/components/drivers/include/ktime.h
diff options
context:
space:
mode:
Diffstat (limited to 'components/drivers/include/ktime.h')
-rw-r--r--components/drivers/include/ktime.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/components/drivers/include/ktime.h b/components/drivers/include/ktime.h
index 42bb4ac9de..91e79832b8 100644
--- a/components/drivers/include/ktime.h
+++ b/components/drivers/include/ktime.h
@@ -18,6 +18,13 @@
#ifndef __KTIME_H__
#define __KTIME_H__
+#include <rtthread.h>
+#include <sys/time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#ifdef RT_USING_CLOCK_TIME
/* Include the unified clock_time header which provides all APIs */
#include <drivers/clock_time.h>
@@ -25,7 +32,36 @@
/* All rt_ktime_* APIs are already defined as macros in clock_time.h */
#else
-#error "ktime subsystem has been removed. Please enable RT_USING_CLOCK_TIME in menuconfig."
+/* When clock_time is not enabled, provide stub implementations for backward compatibility */
+
+/* These are minimal stub implementations to maintain compilation compatibility */
+rt_inline rt_err_t rt_ktime_boottime_get_ns(struct timespec *ts)
+{
+ rt_uint64_t tick = rt_tick_get();
+ rt_uint64_t ns = tick * (1000000000ULL / RT_TICK_PER_SECOND);
+ ts->tv_sec = ns / 1000000000ULL;
+ ts->tv_nsec = ns % 1000000000ULL;
+ return RT_EOK;
+}
+
+rt_inline rt_err_t rt_ktime_boottime_get_us(struct timeval *tv)
+{
+ rt_uint64_t tick = rt_tick_get();
+ rt_uint64_t us = tick * (1000000ULL / RT_TICK_PER_SECOND);
+ tv->tv_sec = us / 1000000ULL;
+ tv->tv_usec = us % 1000000ULL;
+ return RT_EOK;
+}
+
+rt_inline void rt_ktime_cputimer_init(void)
+{
+ /* Stub implementation */
+}
+
#endif /* RT_USING_CLOCK_TIME */
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __KTIME_H__ */