فهرست منبع

Add backward compatibility layer and Kconfig integration

Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>
copilot-swe-agent[bot] 2 هفته پیش
والد
کامیت
e05532a08c

+ 1 - 0
components/drivers/Kconfig

@@ -46,6 +46,7 @@ rsource "pci/Kconfig"
 rsource "pic/Kconfig"
 rsource "pin/Kconfig"
 rsource "pinctrl/Kconfig"
+rsource "clock_time/Kconfig"
 rsource "ktime/Kconfig"
 rsource "clk/Kconfig"
 rsource "hwtimer/Kconfig"

+ 5 - 1
components/drivers/cputime/Kconfig

@@ -1,7 +1,11 @@
 config RT_USING_CPUTIME
-    bool "Enable CPU time for high resolution clock counter"
+    bool "Enable CPU time for high resolution clock counter (DEPRECATED - use RT_USING_CLOCK_TIME)"
     default n
+    depends on !RT_USING_CLOCK_TIME
     help
+        DEPRECATED: This option is maintained for backward compatibility only.
+        New projects should use RT_USING_CLOCK_TIME instead.
+        
         When enable this option, the BSP should provide a rt_clock_cputime_ops
         for CPU time by:
         const static struct rt_clock_cputime_ops _ops = {...};

+ 5 - 1
components/drivers/hwtimer/Kconfig

@@ -1,6 +1,10 @@
 menuconfig RT_USING_HWTIMER
-    bool "Using Hardware Timer device drivers"
+    bool "Using Hardware Timer device drivers (DEPRECATED - use RT_USING_CLOCK_TIME)"
     default n
+    depends on !RT_USING_CLOCK_TIME
+    help
+        DEPRECATED: This option is maintained for backward compatibility only.
+        New projects should use RT_USING_CLOCK_TIME instead.
 
 config RT_HWTIMER_ARM_ARCH
     bool "ARM ARCH Timer"

+ 4 - 0
components/drivers/include/rtdevice.h

@@ -242,6 +242,10 @@ extern "C" {
 #include "drivers/dev_can.h"
 #endif /* RT_USING_CAN */
 
+#ifdef RT_USING_CLOCK_TIME
+#include "drivers/clock_time.h"
+#endif /* RT_USING_CLOCK_TIME */
+
 #ifdef RT_USING_HWTIMER
 #include "drivers/hwtimer.h"
 #endif /* RT_USING_HWTIMER */

+ 5 - 1
components/drivers/ktime/Kconfig

@@ -1,3 +1,7 @@
 menuconfig RT_USING_KTIME
-    bool "Ktime: kernel time"
+    bool "Ktime: kernel time (DEPRECATED - use RT_USING_CLOCK_TIME)"
     default n
+    depends on !RT_USING_CLOCK_TIME
+    help
+        DEPRECATED: This option is maintained for backward compatibility only.
+        New projects should use RT_USING_CLOCK_TIME instead.

+ 25 - 2
components/drivers/ktime/inc/ktime.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006-2023, RT-Thread Development Team
+ * Copyright (c) 2006-2025, RT-Thread Development Team
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -7,6 +7,7 @@
  * Date           Author       Notes
  * 2023-07-10     xqyjlj       The first version.
  * 2024-04-26     Shell        Improve ipc performance
+ * 2025-01-01     RT-Thread    Compatibility layer for unified clock_time
  */
 
 #ifndef __KTIME_H__
@@ -18,6 +19,26 @@
 
 #include "rtthread.h"
 
+/*
+ * COMPATIBILITY LAYER:
+ * When RT_USING_CLOCK_TIME is enabled, this header redirects to the
+ * unified clock_time subsystem. All rt_ktime_* APIs are mapped to
+ * rt_clock_* APIs via macros defined in clock_time.h.
+ * 
+ * When RT_USING_CLOCK_TIME is not enabled, the original ktime
+ * implementation is used.
+ */
+
+#ifdef RT_USING_CLOCK_TIME
+
+/* Include the unified clock_time header which provides all APIs */
+#include <drivers/clock_time.h>
+
+/* All rt_ktime_* APIs are already defined as macros in clock_time.h */
+/* No additional definitions needed here */
+
+#else /* !RT_USING_CLOCK_TIME - Original ktime implementation */
+
 #define RT_KTIME_RESMUL (1000000ULL)
 
 struct rt_ktime_hrtimer
@@ -166,4 +187,6 @@ rt_err_t rt_ktime_hrtimer_udelay(struct rt_ktime_hrtimer *timer, unsigned long u
  */
 rt_err_t rt_ktime_hrtimer_mdelay(struct rt_ktime_hrtimer *timer, unsigned long ms);
 
-#endif
+#endif /* !RT_USING_CLOCK_TIME */
+
+#endif /* __KTIME_H__ */