From 2d9caa6f58bbd718f5ccfc7afe56bdb6b9025ff5 Mon Sep 17 00:00:00 2001 From: David Cutting Date: Sat, 18 Jul 2020 06:18:06 -0600 Subject: [PATCH] Move stuff to Arduino folder, add callback registration --- .../CommandStation.ino | 21 +++++++++++++++---- Config.h => CommandStation/Config.h | 5 +++-- platformio.ini | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) rename CommandStation.cpp => CommandStation/CommandStation.ino (76%) rename Config.h => CommandStation/Config.h (89%) diff --git a/CommandStation.cpp b/CommandStation/CommandStation.ino similarity index 76% rename from CommandStation.cpp rename to CommandStation/CommandStation.ino index ce75cb1..cd2ef17 100644 --- a/CommandStation.cpp +++ b/CommandStation/CommandStation.ino @@ -26,9 +26,12 @@ const uint8_t kIRQmicros = 29; const uint8_t kNumLocos = 50; -#if defined CONFIG_WSM_FIREBOX -DCCMain* mainTrack = DCCMain::Create_WSM_FireBox_Main(kNumLocos); -DCCService* progTrack = DCCService::Create_WSM_FireBox_Prog(); +#if defined CONFIG_WSM_FIREBOX_MK1 +DCCMain* mainTrack = DCCMain::Create_WSM_FireBox_MK1_Main(kNumLocos); +DCCService* progTrack = DCCService::Create_WSM_FireBox_MK1_Prog(); +#elif defined CONFIG_WSM_FIREBOX_MK1S +DCCMain* mainTrack = DCCMain::Create_WSM_FireBox_MK1S_Main(kNumLocos); +DCCService* progTrack = DCCService::Create_WSM_FireBox_MK1S_Prog(); #elif defined CONFIG_ARDUINO_MOTOR_SHIELD DCCMain* mainTrack = DCCMain::Create_Arduino_L298Shield_Main(kNumLocos); DCCService* progTrack = DCCService::Create_Arduino_L298Shield_Prog(); @@ -49,6 +52,11 @@ void SERCOM4_Handler() { mainTrack->railcom.getSerial()->IrqHandler(); } +#elif defined(ARDUINO_ARCH_SAMC) +void SERCOM0_Handler() +{ + mainTrack->railcom.getSerial()->IrqHandler(); +} #endif void setup() { @@ -62,9 +70,15 @@ void setup() { TimerA.attachInterrupt(waveform_IrqHandler); TimerA.start(); + mainTrack->hdw.config_setTrackPowerCallback(DCCEXParser::trackPowerCallback); + progTrack->hdw.config_setTrackPowerCallback(DCCEXParser::trackPowerCallback); + #if defined (ARDUINO_ARCH_SAMD) CommManager::registerInterface(new USBInterface(SerialUSB)); Wire.begin(); // Needed for EEPROM to work +#elif defined (ARDUINO_ARCH_SAMC) + CommManager::registerInterface(new SerialInterface(Serial)); + Wire.begin(); // Needed for EEPROM to work #elif defined(ARDUINO_ARCH_AVR) CommManager::registerInterface(new SerialInterface(Serial)); #endif @@ -82,4 +96,3 @@ void loop() { mainTrack->loop(); progTrack->loop(); } - diff --git a/Config.h b/CommandStation/Config.h similarity index 89% rename from Config.h rename to CommandStation/Config.h index 4605be8..28af7d2 100644 --- a/Config.h +++ b/CommandStation/Config.h @@ -22,8 +22,9 @@ // Choose the motor shield that you want to use. -//#define CONFIG_WSM_FIREBOX -#define CONFIG_ARDUINO_MOTOR_SHIELD +//#define CONFIG_WSM_FIREBOX_MK1 +#define CONFIG_WSM_FIREBOX_MK1S +//#define CONFIG_ARDUINO_MOTOR_SHIELD //#define CONFIG_POLOLU_MOTOR_SHIELD #endif diff --git a/platformio.ini b/platformio.ini index b16d180..0b70217 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,7 +10,7 @@ [platformio] default_envs = samd21, mega2560, mega328 -src_dir = . +src_dir = CommandStation [env] lib_deps =