Skip to content

Commit e05532a

Browse files
CopilotBernardXiong
andcommitted
Add backward compatibility layer and Kconfig integration
Co-authored-by: BernardXiong <[email protected]>
1 parent 7db0837 commit e05532a

File tree

6 files changed

+45
-5
lines changed

6 files changed

+45
-5
lines changed

components/drivers/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ rsource "pci/Kconfig"
4646
rsource "pic/Kconfig"
4747
rsource "pin/Kconfig"
4848
rsource "pinctrl/Kconfig"
49+
rsource "clock_time/Kconfig"
4950
rsource "ktime/Kconfig"
5051
rsource "clk/Kconfig"
5152
rsource "hwtimer/Kconfig"

components/drivers/cputime/Kconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
config RT_USING_CPUTIME
2-
bool "Enable CPU time for high resolution clock counter"
2+
bool "Enable CPU time for high resolution clock counter (DEPRECATED - use RT_USING_CLOCK_TIME)"
33
default n
4+
depends on !RT_USING_CLOCK_TIME
45
help
6+
DEPRECATED: This option is maintained for backward compatibility only.
7+
New projects should use RT_USING_CLOCK_TIME instead.
8+
59
When enable this option, the BSP should provide a rt_clock_cputime_ops
610
for CPU time by:
711
const static struct rt_clock_cputime_ops _ops = {...};

components/drivers/hwtimer/Kconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
menuconfig RT_USING_HWTIMER
2-
bool "Using Hardware Timer device drivers"
2+
bool "Using Hardware Timer device drivers (DEPRECATED - use RT_USING_CLOCK_TIME)"
33
default n
4+
depends on !RT_USING_CLOCK_TIME
5+
help
6+
DEPRECATED: This option is maintained for backward compatibility only.
7+
New projects should use RT_USING_CLOCK_TIME instead.
48

59
config RT_HWTIMER_ARM_ARCH
610
bool "ARM ARCH Timer"

components/drivers/include/rtdevice.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ extern "C" {
242242
#include "drivers/dev_can.h"
243243
#endif /* RT_USING_CAN */
244244

245+
#ifdef RT_USING_CLOCK_TIME
246+
#include "drivers/clock_time.h"
247+
#endif /* RT_USING_CLOCK_TIME */
248+
245249
#ifdef RT_USING_HWTIMER
246250
#include "drivers/hwtimer.h"
247251
#endif /* RT_USING_HWTIMER */

components/drivers/ktime/Kconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
menuconfig RT_USING_KTIME
2-
bool "Ktime: kernel time"
2+
bool "Ktime: kernel time (DEPRECATED - use RT_USING_CLOCK_TIME)"
33
default n
4+
depends on !RT_USING_CLOCK_TIME
5+
help
6+
DEPRECATED: This option is maintained for backward compatibility only.
7+
New projects should use RT_USING_CLOCK_TIME instead.

components/drivers/ktime/inc/ktime.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/*
2-
* Copyright (c) 2006-2023, RT-Thread Development Team
2+
* Copyright (c) 2006-2025, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
77
* Date Author Notes
88
* 2023-07-10 xqyjlj The first version.
99
* 2024-04-26 Shell Improve ipc performance
10+
* 2025-01-01 RT-Thread Compatibility layer for unified clock_time
1011
*/
1112

1213
#ifndef __KTIME_H__
@@ -18,6 +19,26 @@
1819

1920
#include "rtthread.h"
2021

22+
/*
23+
* COMPATIBILITY LAYER:
24+
* When RT_USING_CLOCK_TIME is enabled, this header redirects to the
25+
* unified clock_time subsystem. All rt_ktime_* APIs are mapped to
26+
* rt_clock_* APIs via macros defined in clock_time.h.
27+
*
28+
* When RT_USING_CLOCK_TIME is not enabled, the original ktime
29+
* implementation is used.
30+
*/
31+
32+
#ifdef RT_USING_CLOCK_TIME
33+
34+
/* Include the unified clock_time header which provides all APIs */
35+
#include <drivers/clock_time.h>
36+
37+
/* All rt_ktime_* APIs are already defined as macros in clock_time.h */
38+
/* No additional definitions needed here */
39+
40+
#else /* !RT_USING_CLOCK_TIME - Original ktime implementation */
41+
2142
#define RT_KTIME_RESMUL (1000000ULL)
2243

2344
struct rt_ktime_hrtimer
@@ -166,4 +187,6 @@ rt_err_t rt_ktime_hrtimer_udelay(struct rt_ktime_hrtimer *timer, unsigned long u
166187
*/
167188
rt_err_t rt_ktime_hrtimer_mdelay(struct rt_ktime_hrtimer *timer, unsigned long ms);
168189

169-
#endif
190+
#endif /* !RT_USING_CLOCK_TIME */
191+
192+
#endif /* __KTIME_H__ */

0 commit comments

Comments
 (0)