This is an automated email from the ASF dual-hosted git repository.
jiuzhudong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new acb9a1a2961 drivers/timers: check CONFIG_BOARD_LOOPSPERMSEC != 0 at
runtime
acb9a1a2961 is described below
commit acb9a1a296117576f7fa81813327b7b6d50a52f2
Author: Xiang Xiao <[email protected]>
AuthorDate: Thu Jan 15 02:59:26 2026 +0800
drivers/timers: check CONFIG_BOARD_LOOPSPERMSEC != 0 at runtime
this config is optional for arch timer/alarm
since it is used only in very early boot stage
Signed-off-by: Xiang Xiao <[email protected]>
---
drivers/timers/arch_alarm.c | 8 ++++++++
drivers/timers/arch_timer.c | 8 ++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/timers/arch_alarm.c b/drivers/timers/arch_alarm.c
index 4a439bdd2a3..98a49a8e2d4 100644
--- a/drivers/timers/arch_alarm.c
+++ b/drivers/timers/arch_alarm.c
@@ -26,6 +26,8 @@
#include <nuttx/config.h>
+#include <assert.h>
+
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/timers/arch_alarm.h>
@@ -34,6 +36,10 @@
* Pre-processor Definitions
****************************************************************************/
+#ifndef CONFIG_BOARD_LOOPSPERMSEC
+# define CONFIG_BOARD_LOOPSPERMSEC 0
+#endif
+
#define CONFIG_BOARD_LOOPSPER100USEC ((CONFIG_BOARD_LOOPSPERMSEC+5)/10)
#define CONFIG_BOARD_LOOPSPER10USEC ((CONFIG_BOARD_LOOPSPERMSEC+50)/100)
#define CONFIG_BOARD_LOOPSPERUSEC ((CONFIG_BOARD_LOOPSPERMSEC+500)/1000)
@@ -56,6 +62,8 @@ static void udelay_coarse(useconds_t microseconds)
{
volatile int i;
+ DEBUGASSERT(CONFIG_BOARD_LOOPSPERMSEC != 0);
+
/* We'll do this a little at a time because we expect that the
* CONFIG_BOARD_LOOPSPERUSEC is very inaccurate during to truncation in
* the divisions of its calculation. We'll use the largest values that
diff --git a/drivers/timers/arch_timer.c b/drivers/timers/arch_timer.c
index edeb0945d5a..da4bf6a486d 100644
--- a/drivers/timers/arch_timer.c
+++ b/drivers/timers/arch_timer.c
@@ -26,6 +26,8 @@
#include <nuttx/config.h>
+#include <assert.h>
+
#include <nuttx/arch.h>
#include <nuttx/clock.h>
#include <nuttx/timers/arch_timer.h>
@@ -34,8 +36,8 @@
* Pre-processor Definitions
****************************************************************************/
-#if defined(CONFIG_SCHED_TICKLESS) && defined(CONFIG_SCHED_TICKLESS_ALARM)
-# error CONFIG_SCHED_TICKLESS_ALARM must be unset to use the arch timer
+#ifndef CONFIG_BOARD_LOOPSPERMSEC
+# define CONFIG_BOARD_LOOPSPERMSEC 0
#endif
#define CONFIG_BOARD_LOOPSPER100USEC ((CONFIG_BOARD_LOOPSPERMSEC+5)/10)
@@ -122,6 +124,8 @@ static void udelay_coarse(useconds_t microseconds)
{
volatile int i;
+ DEBUGASSERT(CONFIG_BOARD_LOOPSPERMSEC != 0);
+
/* We'll do this a little at a time because we expect that the
* CONFIG_BOARD_LOOPSPERUSEC is very inaccurate during to truncation in
* the divisions of its calculation. We'll use the largest values that