Skip to content

Commit

Permalink
[doxygen] add doxygen comment for cputimer components
Browse files Browse the repository at this point in the history
Organize driver comment for cputimer component

Signed-off-by: 1078249029 <[email protected]>
  • Loading branch information
1078249029 committed Jan 30, 2025
1 parent cfb44d1 commit 744e02c
Show file tree
Hide file tree
Showing 7 changed files with 364 additions and 20 deletions.
40 changes: 28 additions & 12 deletions components/drivers/cputime/cputime.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017-12-23 Bernard first version
* 2025-01-30 wumingzi transform to doxygen comment
*/

#include <rtdevice.h>
#include <rtthread.h>
#include <sys/errno.h>

/**
* @addtogroup Drivers RTTHREAD Driver
* @defgroup cputimer cputimer
* @brief cputimer driver api
* @ingroup Drivers
* @addtogroup cputimer
* @{
*/

static const struct rt_clock_cputime_ops *_cputime_ops = RT_NULL;

/**
* The clock_cpu_getres() function shall return the resolution of CPU time, the
* @brief The clock_cpu_getres() function shall return the resolution of CPU time, the
* number of nanosecond per tick.
*
* @return the number of nanosecond per tick(x (1000UL * 1000))
* @return the number of nanosecond per tick(x (1000UL * 1000))
*/
uint64_t clock_cpu_getres(void)
{
Expand All @@ -30,9 +40,9 @@ uint64_t clock_cpu_getres(void)
}

/**
* The clock_cpu_gettime() function shall return the current value of cpu time tick.
* @brief The clock_cpu_gettime() function shall return the current value of cpu time tick.
*
* @return the cpu tick
* @return the cpu tick
*/
uint64_t clock_cpu_gettime(void)
{
Expand All @@ -44,7 +54,7 @@ uint64_t clock_cpu_gettime(void)
}

/**
* The clock_cpu_settimeout() fucntion set timeout time and timeout callback function
* @brief The clock_cpu_settimeout() fucntion set timeout time and timeout callback function
* The timeout callback function will be called when the timeout time is reached
*
* @param tick the Timeout tick
Expand All @@ -61,6 +71,11 @@ int clock_cpu_settimeout(uint64_t tick, void (*timeout)(void *param), void *para
return 0;
}

/**
* @brief Check if cputimer timeout callback function has been set
*
* @return RT_FALSE or RT_TURE
*/
int clock_cpu_issettimeout(void)
{
if (_cputime_ops)
Expand All @@ -69,12 +84,12 @@ int clock_cpu_issettimeout(void)
}

/**
* The clock_cpu_microsecond() fucntion shall return the microsecond according to
* @brief The clock_cpu_microsecond() fucntion shall return the microsecond according to
* cpu_tick parameter.
*
* @param cpu_tick the cpu tick
*
* @return the microsecond
* @return the microseconds
*/
uint64_t clock_cpu_microsecond(uint64_t cpu_tick)
{
Expand All @@ -84,12 +99,12 @@ uint64_t clock_cpu_microsecond(uint64_t cpu_tick)
}

/**
* The clock_cpu_microsecond() fucntion shall return the millisecond according to
* @brief The clock_cpu_millisecond() fucntion shall return the millisecond according to
* cpu_tick parameter.
*
* @param cpu_tick the cpu tick
*
* @return the millisecond
* @return the milliseconds
*/
uint64_t clock_cpu_millisecond(uint64_t cpu_tick)
{
Expand All @@ -99,9 +114,9 @@ uint64_t clock_cpu_millisecond(uint64_t cpu_tick)
}

/**
* The clock_cpu_seops() function shall set the ops of cpu time.
* @brief The clock_cpu_seops() function shall set the ops of cpu time.
*
* @return always return 0.
* @return always return 0.
*/
int clock_cpu_setops(const struct rt_clock_cputime_ops *ops)
{
Expand All @@ -114,3 +129,4 @@ int clock_cpu_setops(const struct rt_clock_cputime_ops *ops)

return 0;
}
/*! @}*/
22 changes: 18 additions & 4 deletions components/drivers/cputime/cputime_cortexm.c
Original file line number Diff line number Diff line change
@@ -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
*
Expand All @@ -18,7 +18,11 @@
#include <perf_counter.h>
#endif

/* Use Cycle counter of Data Watchpoint and Trace Register for CPU time */
/**
* @brief Get nanoseconds per tick
*
* @return the number of nanoseconds per tick multiplied by 1 000 000
*/
static uint64_t cortexm_cputime_getres(void)
{
uint64_t ret = 1000UL * 1000 * 1000;
Expand All @@ -27,6 +31,11 @@ static uint64_t cortexm_cputime_getres(void)
return ret;
}

/**
* @brief Read time counter
*
* @return value of ticks
*/
static uint64_t cortexm_cputime_gettime(void)
{
#ifdef PKG_USING_PERF_COUNTER
Expand All @@ -42,7 +51,12 @@ const static struct rt_clock_cputime_ops _cortexm_ops =
cortexm_cputime_gettime
};


/**
* @brief Init cputimer operation of cortex-m architecture by using Cycle
counter of Data Watchpoint and Trace Register for CPU time
*
* @return return 0 forever
*/
int cortexm_cputime_init(void)
{
#ifdef PKG_USING_PERF_COUNTER
Expand All @@ -66,4 +80,4 @@ int cortexm_cputime_init(void)
#endif /* PKG_USING_PERF_COUNTER */
return 0;
}
INIT_BOARD_EXPORT(cortexm_cputime_init);
INIT_BOARD_EXPORT(cortexm_cputime_init);
38 changes: 37 additions & 1 deletion components/drivers/cputime/cputime_riscv.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
/*
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-11-23 Guozhanxin first version
* 2023-04-12 xqyjlj fix cpu timer in multithreading
* 2025-01-30 wumingzi add doxygen comment
*/

#include <rthw.h>
#include <rtdevice.h>
#include <rtthread.h>

#include <board.h>

/* Use Cycle counter of Data Watchpoint and Trace Register for CPU time */
/**
* @addtogroup Drivers RTTHREAD Driver
* @defgroup cputimer cputimer
* @brief cputimer driver api
* @ingroup Drivers
* @addtogroup cputimer
* @{
*/

/**
* @brief Get nanoseconds per tick
*
* @return the number of nanoseconds per tick multiplied by 1 000 000
*/
static uint64_t riscv_cputime_getres(void)
{
uint64_t ret = 1000UL * 1000 * 1000;
Expand All @@ -14,6 +38,11 @@ static uint64_t riscv_cputime_getres(void)
return ret;
}

/**
* @brief Read time counter
*
* @return value of ticks
*/
static uint64_t riscv_cputime_gettime(void)
{
uint64_t time_elapsed;
Expand All @@ -29,9 +58,16 @@ const static struct rt_clock_cputime_ops _riscv_ops =
riscv_cputime_gettime
};

/**
* @brief Init cputimer operation of riscv architecture
*
* @return return 0 forever
*/
int riscv_cputime_init(void)
{
clock_cpu_setops(&_riscv_ops);
return 0;
}
INIT_BOARD_EXPORT(riscv_cputime_init);

/*! @}*/
Loading

0 comments on commit 744e02c

Please sign in to comment.