From a33270dff389abbc44dcb2d149779704a5630eb5 Mon Sep 17 00:00:00 2001 From: David Cutting Date: Sat, 30 May 2020 03:03:19 -0600 Subject: [PATCH] Added railcom stuff --- src/main.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9a03cc4..7f5f6ae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,20 +2,30 @@ #include #include -#define DCC_IRQ_MICROSECONDS 58 +#define DCC_IRQ_MICROSECONDS 29 + +#if defined(ARDUINO_ARCH_SAMD) + +Uart mainRailcomUART(&sercom2, 5, 2, SERCOM_RX_PAD_3, UART_TX_PAD_2); + +void SERCOM2_Handler() +{ + mainRailcomUART.IrqHandler(); +} +#endif //////////////////////////////////////////////////////////////// // Motor driver selection: // Comment out all but the two lines that you want to use -// DCC* mainTrack = DCC::Create_WSM_SAMCommandStation_Main(50); -// DCC* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(2); +DCC* mainTrack = DCC::Create_WSM_SAMCommandStation_Main(50); +DCC* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(2); // DCC* mainTrack = DCC::Create_Arduino_L298Shield_Main(50); // DCC* progTrack = DCC::Create_Arduino_L298Shield_Prog(2); -DCC* mainTrack = DCC::Create_Pololu_MC33926Shield_Main(50); -DCC* progTrack = DCC::Create_Pololu_MC33926Shield_Prog(2); +// DCC* mainTrack = DCC::Create_Pololu_MC33926Shield_Main(50); +// DCC* progTrack = DCC::Create_Pololu_MC33926Shield_Prog(2); //////////////////////////////////////////////////////////////// @@ -32,6 +42,8 @@ void setup() { TimerA.attachInterrupt(main_IrqHandler); TimerA.start(); + mainRailcomUART.begin(250000); + #if defined (ARDUINO_ARCH_SAMD) CommManager::registerInterface(new USBInterface(SerialUSB)); // Register SerialUSB as an interface Wire.begin(); // Needed for EEPROM to work @@ -49,4 +61,5 @@ void loop() { CommManager::update(); mainTrack->loop(); progTrack->loop(); -} \ No newline at end of file +} +