From 7c1d6ffd3c10dfc0af8608ff1546a6a8b0d0b54c Mon Sep 17 00:00:00 2001 From: zhkag Date: Mon, 6 Feb 2023 14:00:32 +0800 Subject: [PATCH] add clock_cpu_settimeout function --- components/drivers/cputime/cputime.c | 18 ++++++++++++++++++ components/drivers/include/drivers/cputime.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/components/drivers/cputime/cputime.c b/components/drivers/cputime/cputime.c index 22b56e6db2..b39e789cd2 100644 --- a/components/drivers/cputime/cputime.c +++ b/components/drivers/cputime/cputime.c @@ -43,6 +43,24 @@ uint64_t clock_cpu_gettime(void) return 0; } +/** + * 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 + * @param timeout the Timeout function + * @param parameter the Parameters of timeout function + * + */ +void clock_cpu_settimeout(uint64_t tick, void (*timeout)(void *param), void *param) +{ + if (_cputime_ops) + return _cputime_ops->cputime_settimeout(tick, timeout, param); + + rt_set_errno(ENOSYS); + return 0; +} + /** * The clock_cpu_microsecond() fucntion shall return the microsecond according to * cpu_tick parameter. diff --git a/components/drivers/include/drivers/cputime.h b/components/drivers/include/drivers/cputime.h index 8fce901c6a..2547ffa42e 100644 --- a/components/drivers/include/drivers/cputime.h +++ b/components/drivers/include/drivers/cputime.h @@ -17,10 +17,12 @@ struct rt_clock_cputime_ops { double (*cputime_getres)(void); uint64_t (*cputime_gettime)(void); + void (*cputime_settimeout)(uint64_t tick, void (*timeout)(void *param), void *param); }; double clock_cpu_getres(void); uint64_t clock_cpu_gettime(void); +void clock_cpu_settimeout(uint64_t tick, void (*timeout)(void *param), void *param); uint64_t clock_cpu_microsecond(uint64_t cpu_tick); uint64_t clock_cpu_millisecond(uint64_t cpu_tick); -- GitLab