Skip to content

Commit 66377bf

Browse files
committed
[doxygen] add doxygen comment for cputimer components
Organize driver comment for cputimer component Signed-off-by: 1078249029 <[email protected]>
1 parent cfb44d1 commit 66377bf

File tree

7 files changed

+364
-20
lines changed

7 files changed

+364
-20
lines changed

components/drivers/cputime/cputime.c

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
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
* 2017-12-23 Bernard first version
9+
* 2025-01-30 wumingzi transform to doxygen comment
910
*/
1011

1112
#include <rtdevice.h>
1213
#include <rtthread.h>
1314
#include <sys/errno.h>
1415

16+
/**
17+
* @addtogroup Drivers RTTHREAD Driver
18+
* @defgroup cputimer cputimer
19+
* @brief cputimer driver api
20+
* @ingroup Drivers
21+
* @addtogroup cputimer
22+
* @{
23+
*/
24+
1525
static const struct rt_clock_cputime_ops *_cputime_ops = RT_NULL;
1626

1727
/**
18-
* The clock_cpu_getres() function shall return the resolution of CPU time, the
28+
* @brief The clock_cpu_getres() function shall return the resolution of CPU time, the
1929
* number of nanosecond per tick.
2030
*
21-
* @return the number of nanosecond per tick(x (1000UL * 1000))
31+
* @return the number of nanosecond per tick(x (1000UL * 1000))
2232
*/
2333
uint64_t clock_cpu_getres(void)
2434
{
@@ -30,9 +40,9 @@ uint64_t clock_cpu_getres(void)
3040
}
3141

3242
/**
33-
* The clock_cpu_gettime() function shall return the current value of cpu time tick.
43+
* @brief The clock_cpu_gettime() function shall return the current value of cpu time tick.
3444
*
35-
* @return the cpu tick
45+
* @return the cpu tick
3646
*/
3747
uint64_t clock_cpu_gettime(void)
3848
{
@@ -44,7 +54,7 @@ uint64_t clock_cpu_gettime(void)
4454
}
4555

4656
/**
47-
* The clock_cpu_settimeout() fucntion set timeout time and timeout callback function
57+
* @brief The clock_cpu_settimeout() fucntion set timeout time and timeout callback function
4858
* The timeout callback function will be called when the timeout time is reached
4959
*
5060
* @param tick the Timeout tick
@@ -61,6 +71,11 @@ int clock_cpu_settimeout(uint64_t tick, void (*timeout)(void *param), void *para
6171
return 0;
6272
}
6373

74+
/**
75+
* @brief Check if cputimer timeout callback function has been set
76+
*
77+
* @return RT_FALSE or RT_TURE
78+
*/
6479
int clock_cpu_issettimeout(void)
6580
{
6681
if (_cputime_ops)
@@ -69,12 +84,12 @@ int clock_cpu_issettimeout(void)
6984
}
7085

7186
/**
72-
* The clock_cpu_microsecond() fucntion shall return the microsecond according to
87+
* @brief The clock_cpu_microsecond() fucntion shall return the microsecond according to
7388
* cpu_tick parameter.
7489
*
7590
* @param cpu_tick the cpu tick
7691
*
77-
* @return the microsecond
92+
* @return the microseconds
7893
*/
7994
uint64_t clock_cpu_microsecond(uint64_t cpu_tick)
8095
{
@@ -84,12 +99,12 @@ uint64_t clock_cpu_microsecond(uint64_t cpu_tick)
8499
}
85100

86101
/**
87-
* The clock_cpu_microsecond() fucntion shall return the millisecond according to
102+
* @brief The clock_cpu_millisecond() fucntion shall return the millisecond according to
88103
* cpu_tick parameter.
89104
*
90105
* @param cpu_tick the cpu tick
91106
*
92-
* @return the millisecond
107+
* @return the milliseconds
93108
*/
94109
uint64_t clock_cpu_millisecond(uint64_t cpu_tick)
95110
{
@@ -99,9 +114,9 @@ uint64_t clock_cpu_millisecond(uint64_t cpu_tick)
99114
}
100115

101116
/**
102-
* The clock_cpu_seops() function shall set the ops of cpu time.
117+
* @brief The clock_cpu_seops() function shall set the ops of cpu time.
103118
*
104-
* @return always return 0.
119+
* @return always return 0.
105120
*/
106121
int clock_cpu_setops(const struct rt_clock_cputime_ops *ops)
107122
{
@@ -114,3 +129,4 @@ int clock_cpu_setops(const struct rt_clock_cputime_ops *ops)
114129

115130
return 0;
116131
}
132+
/*! @}*/

components/drivers/cputime/cputime_cortexm.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
*
@@ -18,7 +18,11 @@
1818
#include <perf_counter.h>
1919
#endif
2020

21-
/* Use Cycle counter of Data Watchpoint and Trace Register for CPU time */
21+
/**
22+
* @brief Get nanoseconds per tick
23+
*
24+
* @return the number of nanoseconds per tick multiplied by 1 000 000
25+
*/
2226
static uint64_t cortexm_cputime_getres(void)
2327
{
2428
uint64_t ret = 1000UL * 1000 * 1000;
@@ -27,6 +31,11 @@ static uint64_t cortexm_cputime_getres(void)
2731
return ret;
2832
}
2933

34+
/**
35+
* @brief Read time counter
36+
*
37+
* @return value of ticks
38+
*/
3039
static uint64_t cortexm_cputime_gettime(void)
3140
{
3241
#ifdef PKG_USING_PERF_COUNTER
@@ -42,7 +51,12 @@ const static struct rt_clock_cputime_ops _cortexm_ops =
4251
cortexm_cputime_gettime
4352
};
4453

45-
54+
/**
55+
* @brief Init cputimer operation of cortex-m architecture by using Cycle
56+
counter of Data Watchpoint and Trace Register for CPU time
57+
*
58+
* @return return 0 forever
59+
*/
4660
int cortexm_cputime_init(void)
4761
{
4862
#ifdef PKG_USING_PERF_COUNTER
@@ -66,4 +80,4 @@ int cortexm_cputime_init(void)
6680
#endif /* PKG_USING_PERF_COUNTER */
6781
return 0;
6882
}
69-
INIT_BOARD_EXPORT(cortexm_cputime_init);
83+
INIT_BOARD_EXPORT(cortexm_cputime_init);

components/drivers/cputime/cputime_riscv.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
1+
/*
2+
* Copyright (c) 2006-2025 RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2022-11-23 Guozhanxin first version
9+
* 2023-04-12 xqyjlj fix cpu timer in multithreading
10+
* 2025-01-30 wumingzi add doxygen comment
11+
*/
12+
113
#include <rthw.h>
214
#include <rtdevice.h>
315
#include <rtthread.h>
416

517
#include <board.h>
618

7-
/* Use Cycle counter of Data Watchpoint and Trace Register for CPU time */
19+
/**
20+
* @addtogroup Drivers RTTHREAD Driver
21+
* @defgroup cputimer cputimer
22+
* @brief cputimer driver api
23+
* @ingroup Drivers
24+
* @addtogroup cputimer
25+
* @{
26+
*/
827

28+
/**
29+
* @brief Get nanoseconds per tick
30+
*
31+
* @return the number of nanoseconds per tick multiplied by 1 000 000
32+
*/
933
static uint64_t riscv_cputime_getres(void)
1034
{
1135
uint64_t ret = 1000UL * 1000 * 1000;
@@ -14,6 +38,11 @@ static uint64_t riscv_cputime_getres(void)
1438
return ret;
1539
}
1640

41+
/**
42+
* @brief Read time counter
43+
*
44+
* @return value of ticks
45+
*/
1746
static uint64_t riscv_cputime_gettime(void)
1847
{
1948
uint64_t time_elapsed;
@@ -29,9 +58,16 @@ const static struct rt_clock_cputime_ops _riscv_ops =
2958
riscv_cputime_gettime
3059
};
3160

61+
/**
62+
* @brief Init cputimer operation of riscv architecture
63+
*
64+
* @return return 0 forever
65+
*/
3266
int riscv_cputime_init(void)
3367
{
3468
clock_cpu_setops(&_riscv_ops);
3569
return 0;
3670
}
3771
INIT_BOARD_EXPORT(riscv_cputime_init);
72+
73+
/*! @}*/

0 commit comments

Comments
 (0)