This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 06fe9f076ee31f2eef58948159111364e8d82d99 Author: ouyangxiangzhen <[email protected]> AuthorDate: Mon Aug 4 15:24:45 2025 +0800 timers/oneshot: Introduce count-based interfaces. This commit introduced count-based oneshot interfaces. Signed-off-by: ouyangxiangzhen <[email protected]> --- drivers/timers/Kconfig | 7 +++++++ include/nuttx/timers/oneshot.h | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/timers/Kconfig b/drivers/timers/Kconfig index a44a7cda9f2..7cc2d4abc1f 100644 --- a/drivers/timers/Kconfig +++ b/drivers/timers/Kconfig @@ -123,6 +123,13 @@ config ONESHOT if ONESHOT +config ONESHOT_COUNT + bool "Oneshot count-based clock device driver" + default n + ---help--- + This option enables the oneshot implementation to be based on the + new clock device driver interfaces. + config ALARM_ARCH bool "Alarm Arch Implementation" select ARCH_HAVE_TICKLESS diff --git a/include/nuttx/timers/oneshot.h b/include/nuttx/timers/oneshot.h index 8de31fd71a2..877c7acf086 100644 --- a/include/nuttx/timers/oneshot.h +++ b/include/nuttx/timers/oneshot.h @@ -36,6 +36,7 @@ #include <time.h> #include <nuttx/clock.h> +#include <nuttx/timers/clkcnt.h> #include <nuttx/fs/ioctl.h> /**************************************************************************** @@ -186,11 +187,24 @@ typedef CODE void (*oneshot_callback_t) (FAR struct oneshot_lowerhalf_s *lower, FAR void *arg); -/* The one short operations supported by the lower half driver */ +/* The oneshot operations supported by the lower half driver */ struct timespec; struct oneshot_operations_s { +#ifdef CONFIG_ONESHOT_COUNT + /* New clkcnt interfaces with better performance, overflow-free timing + * conversion, and the theoretical optimal timing accuracy. + */ + + CODE clkcnt_t (*current)(FAR struct oneshot_lowerhalf_s *lower); + CODE void (*start)(FAR struct oneshot_lowerhalf_s *lower, + clkcnt_t delay); + CODE void (*cancel)(FAR struct oneshot_lowerhalf_s *lower); + CODE clkcnt_t (*max_delay)(FAR struct oneshot_lowerhalf_s *lower); +#else + /* Deprecated interfaces, just for compatiable-usage. */ + CODE int (*max_delay)(FAR struct oneshot_lowerhalf_s *lower, FAR struct timespec *ts); CODE int (*start)(FAR struct oneshot_lowerhalf_s *lower, @@ -199,6 +213,7 @@ struct oneshot_operations_s FAR struct timespec *ts); CODE int (*current)(FAR struct oneshot_lowerhalf_s *lower, FAR struct timespec *ts); +#endif }; /* This structure describes the state of the oneshot timer lower-half @@ -216,6 +231,10 @@ struct oneshot_lowerhalf_s FAR oneshot_callback_t callback; FAR void *arg; +#ifdef CONFIG_ONESHOT_COUNT + uint32_t frequency; +#endif + /* Private lower half data may follow */ };
