1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 13:21:23 +01:00

Moved to single timer for both tracks using "stretched zero" trick

This commit is contained in:
David Cutting 2020-05-25 17:21:21 -06:00
parent c3fd15025e
commit 7455a45f4d
2 changed files with 6 additions and 19 deletions

View File

@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[platformio] [platformio]
default_envs = mega2560 default_envs = samd21, mega2560
[env] [env]
lib_deps = lib_deps =

View File

@ -7,9 +7,6 @@ DCC* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(2);
void main_IrqHandler() { void main_IrqHandler() {
mainTrack->interrupt_handler(); mainTrack->interrupt_handler();
}
void prog_IrqHandler() {
progTrack->interrupt_handler(); progTrack->interrupt_handler();
} }
@ -17,26 +14,16 @@ void setup() {
#if defined (ATSAMD21G) #if defined (ATSAMD21G)
CommManager::registerInterface(new USBInterface(SerialUSB)); // Register SerialUSB as an interface CommManager::registerInterface(new USBInterface(SerialUSB)); // Register SerialUSB as an interface
mainTrack->int_timer->initialize(); TimerTCC0.initialize();
mainTrack->int_timer->setPeriod(58); TimerTCC0.setPeriod(58);
mainTrack->int_timer->attachInterrupt(main_IrqHandler); TimerTCC0.attachInterrupt(main_IrqHandler);
mainTrack->int_timer->start(); TimerTCC0.start();
progTrack->int_timer->initialize();
progTrack->int_timer->setPeriod(58);
progTrack->int_timer->attachInterrupt(prog_IrqHandler);
progTrack->int_timer->start();
#elif defined(ATMEGA2560) #elif defined(ATMEGA2560)
CommManager::registerInterface(new SerialInterface(Serial)); // Register Serial (USB port on mega/uno) as an interface 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.initialize();
Timer3.setPeriod(58); Timer3.setPeriod(58);
Timer3.attachInterrupt(prog_IrqHandler); Timer3.attachInterrupt(main_IrqHandler);
Timer3.start(); Timer3.start();
#endif #endif