Skip to content

Commit 1c5b113

Browse files
committed
arch/delays: Set invalid default value for BOARD_LOOPSPERMSEC
To resolve #17004, this commit sets the default Kconfig value for CONFIG_BOARD_LOOPSPERMSEC as -1, which is invalid. It statically asserts at compile time that the value is greater than or equal to 0 so that the user is notified if their board/configuration does not yet have a calibrated value for this configuration option. The user is directed to set a non-negative value and then later calibrate with `calib_udelay`. Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
1 parent 778f3fa commit 1c5b113

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

arch/Kconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,11 +1274,12 @@ comment "Board Settings"
12741274

12751275
config BOARD_LOOPSPERMSEC
12761276
int "Delay loops per millisecond"
1277-
default 5000
1277+
default -1
12781278
---help---
12791279
Simple delay loops are used by some logic, especially during boot-up,
1280-
driver initialization. These delay loops must be calibrated for each
1281-
board in order to assure accurate timing by the delay loops.
1280+
driver initialization. These delay loops must be calibrated for each
1281+
board in order to assure accurate timing by the delay loops. You can
1282+
do so with `calib_udelay` (EXAMPLES_CALIB_UDELAY).
12821283

12831284
comment "Interrupt options"
12841285

include/nuttx/arch.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@
9999
#define DEBUGPOINT_BREAKPOINT 0x04
100100
#define DEBUGPOINT_STEPPOINT 0x05
101101

102+
/* Ensure that LOOPSPERMSEC is not the default, invalid value. If it is, let
103+
* the user know that they need to change it and then calibrate it.
104+
*/
105+
106+
static_assert(
107+
CONFIG_BOARD_LOOPSPERMSEC >= 0,
108+
"Please set a non-negative value for CONFIG_BOARD_LOOPSPERMSEC to pass "
109+
"compilation. It is recommended that after your initial build, you use "
110+
"the example 'calib_udelay' to get a precise value for this option. "
111+
"Please search the NuttX documentation for CONFIG_BOARD_LOOPSPERMSEC for "
112+
"more information.");
113+
102114
/****************************************************************************
103115
* Name: up_cpu_index
104116
*

0 commit comments

Comments
 (0)