mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 21:21:24 +01:00
commit
545eb54ee5
@ -24,7 +24,6 @@ upload_protocol = atmel-ice
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
SparkFun External EEPROM Arduino Library
|
SparkFun External EEPROM Arduino Library
|
||||||
build_flags = -D ATSAMD21G
|
|
||||||
|
|
||||||
[env:mega2560]
|
[env:mega2560]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
@ -33,7 +32,6 @@ framework = arduino
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
DIO2
|
DIO2
|
||||||
build_flags = -D ATMEGA2560
|
|
||||||
|
|
||||||
[env:mega328]
|
[env:mega328]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
@ -42,4 +40,3 @@ framework = arduino
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
DIO2
|
DIO2
|
||||||
build_flags = -D ATMEGA328
|
|
27
src/main.cpp
27
src/main.cpp
@ -2,34 +2,44 @@
|
|||||||
#include <CommandStation.h>
|
#include <CommandStation.h>
|
||||||
#include <ArduinoTimers.h>
|
#include <ArduinoTimers.h>
|
||||||
|
|
||||||
#define DCC_IRQ_MICROSECONDS 58
|
#define DCC_IRQ_MICROSECONDS 29
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
// Motor driver selection:
|
// Motor driver selection:
|
||||||
// Comment out all but the two lines that you want to use
|
// Comment out all but the two lines that you want to use
|
||||||
|
|
||||||
// DCC* mainTrack = DCC::Create_WSM_SAMCommandStation_Main(50);
|
DCC* mainTrack = DCC::Create_WSM_SAMCommandStation_Main(50);
|
||||||
// DCC* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(2);
|
DCC* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(2);
|
||||||
|
|
||||||
// DCC* mainTrack = DCC::Create_Arduino_L298Shield_Main(50);
|
// DCC* mainTrack = DCC::Create_Arduino_L298Shield_Main(50);
|
||||||
// DCC* progTrack = DCC::Create_Arduino_L298Shield_Prog(2);
|
// DCC* progTrack = DCC::Create_Arduino_L298Shield_Prog(2);
|
||||||
|
|
||||||
DCC* mainTrack = DCC::Create_Pololu_MC33926Shield_Main(50);
|
// DCC* mainTrack = DCC::Create_Pololu_MC33926Shield_Main(50);
|
||||||
DCC* progTrack = DCC::Create_Pololu_MC33926Shield_Prog(2);
|
// DCC* progTrack = DCC::Create_Pololu_MC33926Shield_Prog(2);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void main_IrqHandler() {
|
void waveform_IrqHandler() {
|
||||||
mainTrack->interruptHandler();
|
mainTrack->interruptHandler();
|
||||||
progTrack->interruptHandler();
|
progTrack->interruptHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_SAMD)
|
||||||
|
void SERCOM4_Handler()
|
||||||
|
{
|
||||||
|
mainTrack->hdw.railcom_serial->IrqHandler();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
mainTrack->hdw.init();
|
||||||
|
progTrack->hdw.init();
|
||||||
|
|
||||||
// TimerA is TCC0 on SAMD21, Timer1 on MEGA2560, and Timer1 on MEGA328
|
// TimerA is TCC0 on SAMD21, Timer1 on MEGA2560, and Timer1 on MEGA328
|
||||||
// We will fire an interrupt every 58us to generate the signal on the track
|
// We will fire an interrupt every 58us to generate the signal on the track
|
||||||
TimerA.initialize();
|
TimerA.initialize();
|
||||||
TimerA.setPeriod(DCC_IRQ_MICROSECONDS);
|
TimerA.setPeriod(DCC_IRQ_MICROSECONDS);
|
||||||
TimerA.attachInterrupt(main_IrqHandler);
|
TimerA.attachInterrupt(waveform_IrqHandler);
|
||||||
TimerA.start();
|
TimerA.start();
|
||||||
|
|
||||||
#if defined (ARDUINO_ARCH_SAMD)
|
#if defined (ARDUINO_ARCH_SAMD)
|
||||||
@ -41,7 +51,7 @@ void setup() {
|
|||||||
|
|
||||||
EEStore::init();
|
EEStore::init();
|
||||||
|
|
||||||
StringParser::init(mainTrack, progTrack); // Set up the string parser to accept commands from the interfaces
|
JMRIParser::init(mainTrack, progTrack); // Set up the string parser to accept commands from the interfaces
|
||||||
CommManager::showInitInfo();
|
CommManager::showInitInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,3 +60,4 @@ void loop() {
|
|||||||
mainTrack->loop();
|
mainTrack->loop();
|
||||||
progTrack->loop();
|
progTrack->loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user