1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 08:06:13 +01:00

SAMD support issues

This commit is contained in:
Asbelos 2020-07-24 12:00:07 +01:00
parent 575b5da606
commit 32240c97e2
4 changed files with 20 additions and 11 deletions

View File

@ -85,7 +85,8 @@ void setup() {
// The main sketch has responsibilities during setup()
// Responsibility 1: Start the usb connection for diagnostics and possible JMRI input
Serial.begin(115200);
// DIAGSERAL is normally Serial but uses SerialUSB on a SAMD processor
DIAGSERIAL.begin(115200);
// Responsibility 2: Start the DCC engine.
DCC::begin();
@ -122,7 +123,7 @@ void loop() {
DCC::loop();
// Responsibility 2: handle any incoming commands on USB connection
serialParser.loop(Serial);
serialParser.loop(DIAGSERIAL);
// Responsibility 3: Optionally handle any incoming WiFi traffic
#ifdef WIFI

View File

@ -17,7 +17,8 @@
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
*/
#include <Arduino.h>
#include <TimerOne.h> // use IDE menu Tools..Manage Libraries to locate and install TimerOne
//#include <TimerOne.h> // use IDE menu Tools..Manage Libraries to locate and install TimerOne
#include <ArduinoTimers.h> // use IDE menu Tools..Manage Libraries to locate and install TimerOne
#include "avdweb_AnalogReadFast.h"
#include "Hardware.h"
#include "Config.h"
@ -82,11 +83,10 @@ unsigned int Hardware::getCurrentMilliamps(bool isMainTrack, int raw) {
}
void Hardware::setCallback(int duration, void (*isr)()) {
Timer1.initialize(duration);
// We don't want the timer to set pins because these often clash with motor shields etc.
Timer1.disablePwm(TIMER1_A_PIN);
Timer1.disablePwm(TIMER1_B_PIN);
Timer1.attachInterrupt(isr);
TimerA.initialize();
TimerA.setPeriod(duration);
TimerA.attachInterrupt(isr);
TimerA.start();
}
// shortcut to cpu dependent high speed write

View File

@ -19,11 +19,10 @@
#include "StringFormatter.h"
#include <stdarg.h>
void StringFormatter::print( const __FlashStringHelper* input...) {
va_list args;
va_start(args, input);
send2(Serial,input,args);
send2(DIAGSERIAL,input,args);
}
void StringFormatter::send(Print & stream, const __FlashStringHelper* input...) {

View File

@ -19,6 +19,15 @@
#ifndef StringFormatter_h
#define StringFormatter_h
#include <Arduino.h>
#if defined(ARDUINO_ARCH_SAMD)
// Some processors use a gcc compiler that renames va_list!!!
#include <cstdarg>
#define DIAGSERIAL SerialUSB
#elif defined(ARDUINO_ARCH_AVR)
#define DIAGSERIAL Serial
#endif
class StringFormatter
{
public: