From 7455a45f4d0e7655cf00a642d9835ae0bc7ff2ee Mon Sep 17 00:00:00 2001 From: David Cutting Date: Mon, 25 May 2020 17:21:21 -0600 Subject: [PATCH] Moved to single timer for both tracks using "stretched zero" trick --- platformio.ini | 2 +- src/main.cpp | 23 +++++------------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/platformio.ini b/platformio.ini index 9dfdf7a..6737792 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = mega2560 +default_envs = samd21, mega2560 [env] lib_deps = diff --git a/src/main.cpp b/src/main.cpp index 07a01f1..01ebd78 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,9 +7,6 @@ DCC* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(2); void main_IrqHandler() { mainTrack->interrupt_handler(); -} - -void prog_IrqHandler() { progTrack->interrupt_handler(); } @@ -17,26 +14,16 @@ void setup() { #if defined (ATSAMD21G) CommManager::registerInterface(new USBInterface(SerialUSB)); // Register SerialUSB as an interface - mainTrack->int_timer->initialize(); - mainTrack->int_timer->setPeriod(58); - mainTrack->int_timer->attachInterrupt(main_IrqHandler); - mainTrack->int_timer->start(); - - progTrack->int_timer->initialize(); - progTrack->int_timer->setPeriod(58); - progTrack->int_timer->attachInterrupt(prog_IrqHandler); - progTrack->int_timer->start(); + TimerTCC0.initialize(); + TimerTCC0.setPeriod(58); + TimerTCC0.attachInterrupt(main_IrqHandler); + TimerTCC0.start(); #elif defined(ATMEGA2560) CommManager::registerInterface(new SerialInterface(Serial)); // Register Serial (USB port on mega/uno) as an interface - Timer1.initialize(); - Timer1.setPeriod(58); - Timer1.attachInterrupt(main_IrqHandler); - Timer1.start(); - Timer3.initialize(); Timer3.setPeriod(58); - Timer3.attachInterrupt(prog_IrqHandler); + Timer3.attachInterrupt(main_IrqHandler); Timer3.start(); #endif