From b51a8fe126d75bddc96ab5e6f1742a0c6be2da61 Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:41:29 +1000 Subject: [PATCH 1/2] Add STARTUP_DELAY --- CommandStation-EX.ino | 5 +++++ config.example.h | 8 ++++++++ version.h | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index 205babf..9c94606 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -76,6 +76,11 @@ void setup() DIAG(F("License GPLv3 fsf.org (c) dcc-ex.com")); +// If user has defined a startup delay, delay here before starting IO +#if defined(STARTUP_DELAY) + delay(STARTUP_DELAY) +#endif + // Initialise HAL layer before reading EEprom or setting up MotorDrivers IODevice::begin(); diff --git a/config.example.h b/config.example.h index 89d6c1f..a2e08b2 100644 --- a/config.example.h +++ b/config.example.h @@ -222,6 +222,14 @@ The configuration file for DCC-EX Command Station // We do not support to use the same address, for example 100(long) and 100(short) // at the same time, there must be a border. +///////////////////////////////////////////////////////////////////////////////////// +// Some newer 32bit microcontrollers boot very quickly, so powering on I2C and other +// peripheral devices at the same time may result in the CommandStation booting too +// quickly to detect them. +// To work around this, uncomment the STARTUP_DELAY line below and set a value in +// milliseconds that works for your environment, default is 3000 (3 seconds). +// #define STARTUP_DELAY 3000 + ///////////////////////////////////////////////////////////////////////////////////// // // DEFINE TURNOUTS/ACCESSORIES FOLLOW NORM RCN-213 diff --git a/version.h b/version.h index 75c2899..9f19afe 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,8 @@ #include "StringFormatter.h" -#define VERSION "5.2.20" +#define VERSION "5.2.21" +// 5.2.21 - Add STARTUP_DELAY config option to delay CS bootup // 5.2.20 - Check return of Ethernet.begin() // 5.2.19 - ESP32: Determine if the RMT hardware can handle DCC // 5.2.18 - Display network IP fix From 5ac26ce505b28c7f0a0a76b2d4e39b6b51b6cc5c Mon Sep 17 00:00:00 2001 From: peteGSX <97784652+peteGSX@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:49:22 +1000 Subject: [PATCH 2/2] Add missing ; and DIAG message --- CommandStation-EX.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index 9c94606..2cd9d33 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -78,7 +78,8 @@ void setup() // If user has defined a startup delay, delay here before starting IO #if defined(STARTUP_DELAY) - delay(STARTUP_DELAY) + DIAG(F("Delaying startup for %dms"), STARTUP_DELAY); + delay(STARTUP_DELAY); #endif // Initialise HAL layer before reading EEprom or setting up MotorDrivers