diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino index 7363566..cbe55a3 100644 --- a/CommandStation-EX.ino +++ b/CommandStation-EX.ino @@ -77,6 +77,8 @@ void setup() // Initialise HAL layer before reading EEprom or setting up MotorDrivers IODevice::begin(); +// Set up MotorDrivers early to initialize all pins + TrackManager::Setup(MOTOR_SHIELD_TYPE); DISPLAY_START ( // This block is still executed for DIAGS if display not in use @@ -104,11 +106,7 @@ void setup() // let's make sure to initialise the ADCee class! ADCee::begin(); // Responsibility 3: Start the DCC engine. - // Note: this provides DCC with two motor drivers, main and prog, which handle the motor shield(s) - // Standard supported devices have pre-configured macros but custome hardware installations require - // detailed pin mappings and may also require modified subclasses of the MotorDriver to implement specialist logic. - // STANDARD_MOTOR_SHIELD, POLOLU_MOTOR_SHIELD, FIREBOX_MK1, FIREBOX_MK1S are pre defined in MotorShields.h - TrackManager::Setup(MOTOR_SHIELD_TYPE); + DCC::begin(); // Start RMFT aka EX-RAIL (ignored if no automnation) RMFT::begin(); diff --git a/DCC.cpp b/DCC.cpp index c9535b2..30fcf5f 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -60,8 +60,7 @@ const byte FN_GROUP_5=0x10; FSH* DCC::shieldName=NULL; byte DCC::globalSpeedsteps=128; -void DCC::begin(const FSH * motorShieldName) { - shieldName=(FSH *)motorShieldName; +void DCC::begin() { StringFormatter::send(&USB_SERIAL,F("\n"), F(VERSION), F(ARDUINO_TYPE), shieldName, F(GITHUB_SHA)); #ifndef DISABLE_EEPROM // Load stuff from EEprom diff --git a/DCC.h b/DCC.h index 15d5a4f..74b4e77 100644 --- a/DCC.h +++ b/DCC.h @@ -51,7 +51,10 @@ const byte MAX_LOCOS = 30; class DCC { public: - static void begin(const FSH * motorShieldName); + static inline void setShieldName(const FSH * motorShieldName) { + shieldName=(FSH *)motorShieldName; + }; + static void begin(); static void loop(); // Public DCC API functions diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index 57a2187..549ccda 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202306210849Z" +#define GITHUB_SHA "devel-202306222055Z" diff --git a/TrackManager.cpp b/TrackManager.cpp index dd0fb4a..8f66677 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -134,7 +134,7 @@ void TrackManager::Setup(const FSH * shieldname, } } } - DCC::begin(shieldname); + DCC::setShieldName(shieldname); } void TrackManager::addTrack(byte t, MotorDriver* driver) { diff --git a/version.h b/version.h index fc470c8..75228d0 100644 --- a/version.h +++ b/version.h @@ -4,7 +4,8 @@ #include "StringFormatter.h" -#define VERSION "4.2.57" +#define VERSION "4.2.58" +// 4.2.58 - Start motordriver as soon as possible but without waveform // 4.2.57 - New overload handling (faster and handles commonFaultPin again) // - Optimize analog read STM32 // 4.2.56 - Update IO_RotaryEncoder.h: