From c3fd15025ee301f4d15c7c99e510d49d1894d19a Mon Sep 17 00:00:00 2001 From: David Cutting Date: Mon, 25 May 2020 04:56:03 -0600 Subject: [PATCH] Move timers names to pointers in main file --- lib/README | 46 ---------------------------------------------- platformio.ini | 21 ++++++++++++++------- src/main.cpp | 19 ++++++++++--------- 3 files changed, 24 insertions(+), 62 deletions(-) delete mode 100644 lib/README diff --git a/lib/README b/lib/README deleted file mode 100644 index 6debab1..0000000 --- a/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in a an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini index 89d476a..9dfdf7a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,14 +8,23 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -[env:samd21] -platform = atmelsam -board = sparkfun_samd21_dev_usb -framework = arduino +[platformio] +default_envs = mega2560 + +[env] lib_deps = https://github.com/davidcutting42/CommandStation.git#master https://github.com/davidcutting42/ArduinoTimers.git#master SparkFun External EEPROM Arduino Library + DIO2 + +[env:samd21] +platform = atmelsam +board = sparkfun_samd21_dev_usb +framework = arduino +upload_protocol = atmel-ice +lib_deps = + ${env.lib_deps} build_flags = -D ATSAMD21G [env:mega2560] @@ -23,7 +32,5 @@ platform = atmelavr board = megaatmega2560 framework = arduino lib_deps = - https://github.com/davidcutting42/CommandStation.git#master - https://github.com/davidcutting42/ArduinoTimers.git#master - SparkFun External EEPROM Arduino Library + ${env.lib_deps} build_flags = -D ATMEGA2560 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index e6b333f..07a01f1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include #include +#include DCC* mainTrack = DCC::Create_WSM_SAMCommandStation_Main(50); DCC* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(2); @@ -14,17 +15,17 @@ void prog_IrqHandler() { void setup() { #if defined (ATSAMD21G) - CommManager::registerInterface(new SerialInterface(SerialUSB)); // Register SerialUSB as an interface + CommManager::registerInterface(new USBInterface(SerialUSB)); // Register SerialUSB as an interface - TimerTCC0.initialize(); - TimerTCC0.setPeriod(58); - TimerTCC0.attachInterrupt(main_IrqHandler); - TimerTCC0.start(); + mainTrack->int_timer->initialize(); + mainTrack->int_timer->setPeriod(58); + mainTrack->int_timer->attachInterrupt(main_IrqHandler); + mainTrack->int_timer->start(); - TimerTCC1.initialize(); - TimerTCC1.setPeriod(58); - TimerTCC1.attachInterrupt(prog_IrqHandler); - TimerTCC1.start(); + progTrack->int_timer->initialize(); + progTrack->int_timer->setPeriod(58); + progTrack->int_timer->attachInterrupt(prog_IrqHandler); + progTrack->int_timer->start(); #elif defined(ATMEGA2560) CommManager::registerInterface(new SerialInterface(Serial)); // Register Serial (USB port on mega/uno) as an interface