Skip to content

Commit 743b614

Browse files
authored
[components][clock_time] Refactor time subsystem around clock_time (#11111)
* [components][clock_time] Refactor time subsystem around clock_time Introduce the clock_time core with clock source/event separation, high-resolution scheduling, and boot-time helpers, plus clock_timer adapters for timer peripherals. Remove legacy ktime/cputime/hwtimer implementations and migrate arch and BSP time paths to the new subsystem while keeping POSIX time integration functional. Update drivers, Kconfig/SConscript wiring, documentation, and tests; add clock_time overview docs and align naming to clock_boottime/clock_hrtimer/clock_timer. * [components][clock_time] Use BSP-provided clock timer frequency on riscv64 * [risc-v] Use runtime clock timer frequency for tick and delays * [bsp] Add clock timer frequency hooks for riscv64 boards * [bsp] Update Renesas RA driver doc clock_timer link * [bsp] Sync zynqmp-r5-axu4ev rtconfig after config refresh * [bsp][rk3500] Update rk3500 clock configuration * [bsp][hpmicro] Add rt_hw_us_delay hook and update board delays * [bsp][stm32l496-st-nucleo] enable clock_time for hwtimer sample in ci * [bsp][hpmicro] Fix rtconfig include scope for hpm6750evk Move rtconfig.h include outside the ENET_MULTIPLE_PORT guard for hpm6750evk and hpm6750evk2 so configuration macros are available regardless of ENET settings. * [bsp][raspi3] select clock time for systimer * [bsp][hpm5300evk] Trim trailing blank line * [bsp][hpm5301evklite] Trim trailing blank line * [bsp][hpm5e00evk] Trim trailing blank line * [bsp][hpm6200evk] Trim trailing blank line * [bsp][hpm6300evk] Trim trailing blank line * [bsp][hpm6750evk] Trim trailing blank line * [bsp][hpm6750evk2] Trim trailing blank line * [bsp][hpm6750evkmini] Trim trailing blank line * [bsp][hpm6800evk] Trim trailing blank line * [bsp][hpm6e00evk] Trim trailing blank line * [bsp][nxp] switch lpc178x to gcc and remove mcx timer source * [bsp][stm32] fix the CONFIG_RT_USING_CLOCK_TIME issue. * [docs][clock_time] add clock time documentation * [docs][clock_time] Update clock time subsystem documentation - Update device driver index to use correct page reference - Clarify upper layer responsibilities in architecture overview - Update README to describe POSIX/libc, Soft RTC, and device driver usage - Refine architecture diagram with improved layout and color scheme - Remove obsolete clock_timer.md file * [kernel][utest] Trim trailing space * [clock_time] Fix hrtimer wrap handling * [clock_time] fix the static rt_inline issue * [clock_time] fix the rt_clock_hrtimer_control result issue
1 parent f2a646c commit 743b614

File tree

671 files changed

+10119
-8371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

671 files changed

+10119
-8371
lines changed

bsp/ESP32_C3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Each peripheral supporting condition for this BSP is as follows:
4747
| WIFI | Partial support | There are currently some problems, such as `rt_mq_recive` cannot be used in ISR, etc. |
4848
| BLE | Partially supported | There are currently some problems, such as `NimBLE` running errors after starting for a while |
4949
| GDBStub | Support | You can use the GDB provided by ESP-IDF by turning on the `BSP_ENABLE_GDBSTUB` switch, which will enter GDB mode after a chip error |
50-
| HWTIMER | Support |
50+
| CLOCK_TIMER | Support |
5151
Note:
5252

5353
1. WIFI and BLE cannot be enabled at the same time. When using the BLE driver, be sure to turn off the `RT_USING_WIFI` and `LWIP` switches in `menuconfig`. In addition, due to limited capabilities and lack of debugging equipment, there are problems with WIFI and BLE driver operation. If it can be solved, please contact [timwcx@qq.com](mailto:timwcx@qq.com).

bsp/ESP32_C3/README_ZH.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
| WIFI | 部分支持 | 目前存在一些问题,例如不能在ISR中使用`rt_mq_recive`|
5555
| BLE | 部分支持 | 目前存在一些问题,例如`NimBLE`启动一段时间后运行错误 |
5656
| GDBStub | 支持 | 通过开启`BSP_ENABLE_GDBSTUB`开关即可使用ESP-IDF所提供的GDB,其会在芯片出错后进入GDB模式 |
57-
| HWTIMER | 支持 |
57+
| CLOCK_TIMER | 支持 |
5858
注:
5959

6060
1、WIFI和BLE不能同时启用,在使用BLE驱动时注意在`menuconfig`中关闭`RT_USING_WIFI``LWIP`开关。另外由于能力有限且缺乏调试设备,WIFI和BLE驱动运行都有问题,如果可以解决联系[timwcx@qq.com](mailto:timwcx@qq.com)

bsp/ESP32_C3/drivers/Kconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ menu "On-chip Peripheral Drivers"
115115
bool "Enable BLE"
116116
default n
117117

118-
menuconfig BSP_USING_HWTIMER
119-
bool "Enable HWTIMER"
120-
select RT_USING_HWTIMER
118+
menuconfig BSP_USING_CLOCK_TIMER
119+
bool "Enable CLOCK_TIMER"
120+
select RT_USING_CLOCK_TIME
121121
default n
122-
if BSP_USING_HWTIMER
122+
if BSP_USING_CLOCK_TIMER
123123
config BSP_USING_TIMER0
124-
bool "Enable HWTIMER0"
124+
bool "Enable CLOCK_TIMER0"
125125
default n
126126
endif
127127

bsp/ESP32_C3/drivers/SConscript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ if GetDepend('BSP_USING_SW_I2C'):
2424
if GetDepend('BSP_USING_PWM'):
2525
src += ['drv_pwm.c']
2626

27-
if GetDepend('BSP_USING_HWTIMER'):
28-
src += ['drv_hwtimer.c']
27+
if GetDepend('BSP_USING_CLOCK_TIMER'):
28+
src += ['drv_timer.c']
2929

3030
if GetDepend('BSP_USING_WIFI'):
3131
src += ['drv_wifi.c']
Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,34 @@
88
* 2023-11-15 BetMul first version
99
*/
1010

11-
#include "drv_hwtimer.h"
11+
#include "drv_timer.h"
1212

1313
#include <rtthread.h>
1414
#include <rtdevice.h>
1515
#include "driver/gptimer.h"
1616
#include "sdkconfig.h"
1717

18-
#ifdef RT_USING_HWTIMER
18+
#ifdef RT_USING_CLOCK_TIME
1919

2020
/**
21-
* handle interrupt for hwtimer.
21+
* handle interrupt for clock_timer.
2222
*/
23-
static bool mcu_hwtimer_intr_handler(gptimer_handle_t gptimer, const gptimer_alarm_event_data_t *edata, void *user_ctx)
23+
static bool mcu_clock_timer_intr_handler(gptimer_handle_t gptimer, const gptimer_alarm_event_data_t *edata, void *user_ctx)
2424
{
2525
rt_interrupt_enter();
2626

27-
rt_hwtimer_t *hwtimer = (rt_hwtimer_t *)user_ctx;
28-
rt_device_hwtimer_isr(hwtimer);
27+
rt_clock_timer_t *clock_timer = (rt_clock_timer_t *)user_ctx;
28+
rt_clock_timer_isr(clock_timer);
2929

3030
rt_interrupt_leave();
3131

3232
return 0;
3333
}
3434

3535
/**
36-
* init the hwtimer
36+
* init the clock_timer
3737
*/
38-
static void mcu_hwtimer_init(rt_hwtimer_t *timer, rt_uint32_t state)
38+
static void mcu_clock_timer_init(rt_clock_timer_t *timer, rt_uint32_t state)
3939
{
4040
gptimer_handle_t gptimer = (gptimer_handle_t)timer->parent.user_data;
4141

@@ -44,15 +44,15 @@ static void mcu_hwtimer_init(rt_hwtimer_t *timer, rt_uint32_t state)
4444
}
4545

4646
/**
47-
* start the hwtimer, change status into running
47+
* start the clock_timer, change status into running
4848
*/
49-
static rt_err_t mcu_hwtimer_start(rt_hwtimer_t *timer, rt_uint32_t cnt, rt_hwtimer_mode_t mode)
49+
static rt_err_t mcu_clock_timer_start(rt_clock_timer_t *timer, rt_uint32_t cnt, rt_clock_timer_mode_t mode)
5050
{
5151
gptimer_handle_t gptimer = (gptimer_handle_t)timer->parent.user_data;
5252
gptimer_alarm_config_t alarm_config = {
5353
.alarm_count = cnt,
5454
};
55-
if (mode == HWTIMER_MODE_ONESHOT)
55+
if (mode == CLOCK_TIMER_MODE_ONESHOT)
5656
{
5757

5858
}
@@ -68,9 +68,9 @@ static rt_err_t mcu_hwtimer_start(rt_hwtimer_t *timer, rt_uint32_t cnt, rt_hwtim
6868
}
6969

7070
/**
71-
* stop the hwtimer, change the status from running into enable
71+
* stop the clock_timer, change the status from running into enable
7272
*/
73-
static void mcu_hwtimer_stop(rt_hwtimer_t *timer)
73+
static void mcu_clock_timer_stop(rt_clock_timer_t *timer)
7474
{
7575
gptimer_handle_t gptimer = (gptimer_handle_t)timer->parent.user_data;
7676

@@ -80,7 +80,7 @@ static void mcu_hwtimer_stop(rt_hwtimer_t *timer)
8080
/**
8181
* get count
8282
*/
83-
static rt_uint32_t mcu_hwtimer_count_get(rt_hwtimer_t *timer)
83+
static rt_uint32_t mcu_clock_timer_count_get(rt_clock_timer_t *timer)
8484
{
8585
gptimer_handle_t gptimer = (gptimer_handle_t)timer->parent.user_data;
8686
// get count number
@@ -90,53 +90,53 @@ static rt_uint32_t mcu_hwtimer_count_get(rt_hwtimer_t *timer)
9090
}
9191

9292
/**
93-
* control the hwtimer
93+
* control the clock_timer
9494
*/
95-
static rt_err_t mcu_hwtimer_control(rt_hwtimer_t *timer, rt_uint32_t cmd, void *args)
95+
static rt_err_t mcu_clock_timer_control(rt_clock_timer_t *timer, rt_uint32_t cmd, void *args)
9696
{
9797

9898
rt_err_t err = RT_EOK;
9999

100100
switch (cmd)
101101
{
102-
case HWTIMER_CTRL_FREQ_SET:
102+
case CLOCK_TIMER_CTRL_FREQ_SET:
103103
err = -RT_ERROR;
104104
break;
105105

106-
case HWTIMER_CTRL_INFO_GET:
106+
case CLOCK_TIMER_CTRL_INFO_GET:
107107
err = -RT_ERROR;
108108
break;
109109

110-
case HWTIMER_CTRL_MODE_SET:
110+
case CLOCK_TIMER_CTRL_MODE_SET:
111111
timer->mode = *(rt_uint32_t *)args;
112112
break;
113113

114-
case HWTIMER_CTRL_STOP:
115-
mcu_hwtimer_stop(timer);
114+
case CLOCK_TIMER_CTRL_STOP:
115+
mcu_clock_timer_stop(timer);
116116
break;
117117
}
118118

119119
return err;
120120
}
121121

122-
static struct rt_hwtimer_device _hwtimer;
123-
static const struct rt_hwtimer_ops _hwtimer_ops =
122+
static struct rt_clock_timer_device _clock_timer;
123+
static const struct rt_clock_timer_ops _clock_timer_ops =
124124
{
125-
.init = mcu_hwtimer_init,
126-
.start = mcu_hwtimer_start,
127-
.stop = mcu_hwtimer_stop,
128-
.count_get = mcu_hwtimer_count_get,
129-
.control = mcu_hwtimer_control};
125+
.init = mcu_clock_timer_init,
126+
.start = mcu_clock_timer_start,
127+
.stop = mcu_clock_timer_stop,
128+
.count_get = mcu_clock_timer_count_get,
129+
.control = mcu_clock_timer_control};
130130

131-
static const struct rt_hwtimer_info _hwtimer_info =
131+
static const struct rt_clock_timer_info _clock_timer_info =
132132
{
133133
// TODO:what is the true max and min?
134134
.maxfreq = 1000000UL,
135135
.minfreq = 1000000UL,
136136
.maxcnt = 0xFFFF,
137-
.cntmode = HWTIMER_MODE_ONESHOT};
137+
.cntmode = CLOCK_TIMER_MODE_ONESHOT};
138138

139-
int rt_hw_hwtimer_init(void)
139+
int rt_hw_clock_timer_init(void)
140140
{
141141

142142
char *name = "timer0";
@@ -149,18 +149,18 @@ int rt_hw_hwtimer_init(void)
149149
};
150150

151151
gptimer_event_callbacks_t cbs = {
152-
.on_alarm = mcu_hwtimer_intr_handler,
152+
.on_alarm = mcu_clock_timer_intr_handler,
153153
};
154154

155155
ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &gptimer));
156-
ESP_ERROR_CHECK(gptimer_register_event_callbacks(gptimer, &cbs, &_hwtimer));
156+
ESP_ERROR_CHECK(gptimer_register_event_callbacks(gptimer, &cbs, &_clock_timer));
157157

158-
_hwtimer.info = &_hwtimer_info;
159-
_hwtimer.ops = &_hwtimer_ops;
158+
_clock_timer.info = &_clock_timer_info;
159+
_clock_timer.ops = &_clock_timer_ops;
160160

161-
return rt_device_hwtimer_register(&_hwtimer, name, (void *)gptimer);
161+
return rt_clock_timer_register(&_clock_timer, name, (void *)gptimer);
162162

163163
}
164164

165-
INIT_DEVICE_EXPORT(rt_hw_hwtimer_init);
166-
#endif /* RT_USING_HWTIMER */
165+
INIT_DEVICE_EXPORT(rt_hw_clock_timer_init);
166+
#endif /* RT_USING_CLOCK_TIME */
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
* Date Author Notes
88
* 2023-11-15 BetMul first version
99
*/
10-
#ifndef __DRV_HWTIMER_H__
11-
#define __DRV_HWTIMER_H__
10+
#ifndef __DRV_CLOCK_TIMER_H__
11+
#define __DRV_CLOCK_TIMER_H__
1212

1313
#include <rtconfig.h>
1414

15-
#ifdef RT_USING_HWTIMER
16-
int rt_hw_hwtimer_init(void);
15+
#ifdef RT_USING_CLOCK_TIME
16+
int rt_hw_clock_timer_init(void);
1717
#endif
1818

1919

20-
#endif /* __DRV_HWTIMER_H__ */
20+
#endif /* __DRV_CLOCK_TIMER_H__ */

bsp/Infineon/libraries/HAL_Drivers/SConscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if GetDepend(['RT_USING_DAC']):
5757
src += ['drv_dac.c']
5858

5959
if GetDepend(['BSP_USING_TIM']):
60-
src += ['drv_hwtimer.c']
60+
src += ['drv_timer.c']
6161

6262
if GetDepend(['BSP_USING_ETH']):
6363
src += ['drv_eth.c']

0 commit comments

Comments
 (0)