mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-24 03:18:51 +01:00
Select Pololu Motor shield
This commit is contained in:
parent
7455a45f4d
commit
37824f586b
@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for project header files.
|
|
||||||
|
|
||||||
A header file is a file containing C declarations and macro definitions
|
|
||||||
to be shared between several project source files. You request the use of a
|
|
||||||
header file in your project source file (C, C++, etc) located in `src` folder
|
|
||||||
by including it, with the C preprocessing directive `#include'.
|
|
||||||
|
|
||||||
```src/main.c
|
|
||||||
|
|
||||||
#include "header.h"
|
|
||||||
|
|
||||||
int main (void)
|
|
||||||
{
|
|
||||||
...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Including a header file produces the same results as copying the header file
|
|
||||||
into each source file that needs it. Such copying would be time-consuming
|
|
||||||
and error-prone. With a header file, the related declarations appear
|
|
||||||
in only one place. If they need to be changed, they can be changed in one
|
|
||||||
place, and programs that include the header file will automatically use the
|
|
||||||
new version when next recompiled. The header file eliminates the labor of
|
|
||||||
finding and changing all the copies as well as the risk that a failure to
|
|
||||||
find one copy will result in inconsistencies within a program.
|
|
||||||
|
|
||||||
In C, the usual convention is to give header files names that end with `.h'.
|
|
||||||
It is most portable to use only letters, digits, dashes, and underscores in
|
|
||||||
header file names, and at most one dot.
|
|
||||||
|
|
||||||
Read more about using header files in official GCC documentation:
|
|
||||||
|
|
||||||
* Include Syntax
|
|
||||||
* Include Operation
|
|
||||||
* Once-Only Headers
|
|
||||||
* Computed Includes
|
|
||||||
|
|
||||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
|
@ -9,15 +9,13 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
default_envs = samd21, mega2560
|
default_envs = samd21
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/davidcutting42/CommandStation.git#master
|
https://github.com/davidcutting42/CommandStation.git#master
|
||||||
https://github.com/davidcutting42/ArduinoTimers.git#master
|
https://github.com/davidcutting42/ArduinoTimers.git#master
|
||||||
SparkFun External EEPROM Arduino Library
|
|
||||||
DIO2
|
|
||||||
|
|
||||||
[env:samd21]
|
[env:samd21]
|
||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
board = sparkfun_samd21_dev_usb
|
board = sparkfun_samd21_dev_usb
|
||||||
@ -25,6 +23,7 @@ framework = arduino
|
|||||||
upload_protocol = atmel-ice
|
upload_protocol = atmel-ice
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
|
SparkFun External EEPROM Arduino Library
|
||||||
build_flags = -D ATSAMD21G
|
build_flags = -D ATSAMD21G
|
||||||
|
|
||||||
[env:mega2560]
|
[env:mega2560]
|
||||||
@ -33,4 +32,14 @@ board = megaatmega2560
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
build_flags = -D ATMEGA2560
|
DIO2
|
||||||
|
build_flags = -D ATMEGA2560
|
||||||
|
|
||||||
|
[env:mega328]
|
||||||
|
platform = atmelavr
|
||||||
|
board = uno
|
||||||
|
framework = arduino
|
||||||
|
lib_deps =
|
||||||
|
${env.lib_deps}
|
||||||
|
DIO2
|
||||||
|
build_flags = -D ATMEGA328
|
51
src/main.cpp
51
src/main.cpp
@ -2,37 +2,50 @@
|
|||||||
#include <CommandStation.h>
|
#include <CommandStation.h>
|
||||||
#include <ArduinoTimers.h>
|
#include <ArduinoTimers.h>
|
||||||
|
|
||||||
DCC* mainTrack = DCC::Create_WSM_SAMCommandStation_Main(50);
|
#define DCC_IRQ_MICROSECONDS 58
|
||||||
DCC* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(2);
|
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
// 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_Arduino_L298Shield_Main(50);
|
||||||
|
// DCC* progTrack = DCC::Create_Arduino_L298Shield_Prog(2);
|
||||||
|
|
||||||
|
DCC* mainTrack = DCC::Create_Pololu_MC33926Shield_Main(10);
|
||||||
|
DCC* progTrack = DCC::Create_Pololu_MC33926Shield_Prog(2);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void main_IrqHandler() {
|
void main_IrqHandler() {
|
||||||
mainTrack->interrupt_handler();
|
mainTrack->interruptHandler();
|
||||||
progTrack->interrupt_handler();
|
progTrack->interruptHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
#if defined (ATSAMD21G)
|
// TimerA is TCC0 on SAMD21, Timer1 on MEGA2560, and Timer1 on MEGA328
|
||||||
CommManager::registerInterface(new USBInterface(SerialUSB)); // Register SerialUSB as an interface
|
// We will fire an interrupt every 58us to generate the signal on the track
|
||||||
|
TimerA.initialize();
|
||||||
TimerTCC0.initialize();
|
TimerA.setPeriod(DCC_IRQ_MICROSECONDS);
|
||||||
TimerTCC0.setPeriod(58);
|
TimerA.attachInterrupt(main_IrqHandler);
|
||||||
TimerTCC0.attachInterrupt(main_IrqHandler);
|
TimerA.start();
|
||||||
TimerTCC0.start();
|
|
||||||
#elif defined(ATMEGA2560)
|
|
||||||
CommManager::registerInterface(new SerialInterface(Serial)); // Register Serial (USB port on mega/uno) as an interface
|
|
||||||
|
|
||||||
Timer3.initialize();
|
#if defined (ARDUINO_ARCH_SAMD)
|
||||||
Timer3.setPeriod(58);
|
CommManager::registerInterface(new USBInterface(SerialUSB)); // Register SerialUSB as an interface
|
||||||
Timer3.attachInterrupt(main_IrqHandler);
|
#elif defined(ARDUINO_ARCH_AVR)
|
||||||
Timer3.start();
|
CommManager::registerInterface(new SerialInterface(Serial)); // Register Serial (USB port on mega/uno) as an interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//EEStore::init();
|
||||||
|
|
||||||
StringParser::init(mainTrack, progTrack); // Set up the string parser to accept commands from the interfaces
|
StringParser::init(mainTrack, progTrack); // Set up the string parser to accept commands from the interfaces
|
||||||
CommManager::showInitInfo();
|
CommManager::showInitInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
CommManager::update();
|
CommManager::update();
|
||||||
mainTrack->check();
|
mainTrack->loop();
|
||||||
progTrack->check();
|
progTrack->loop();
|
||||||
}
|
}
|
11
test/README
11
test/README
@ -1,11 +0,0 @@
|
|||||||
|
|
||||||
This directory is intended for PIO Unit Testing and project tests.
|
|
||||||
|
|
||||||
Unit Testing is a software testing method by which individual units of
|
|
||||||
source code, sets of one or more MCU program modules together with associated
|
|
||||||
control data, usage procedures, and operating procedures, are tested to
|
|
||||||
determine whether they are fit for use. Unit testing finds problems early
|
|
||||||
in the development cycle.
|
|
||||||
|
|
||||||
More information about PIO Unit Testing:
|
|
||||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
|
Loading…
Reference in New Issue
Block a user