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:
parent
575b5da606
commit
32240c97e2
|
@ -85,7 +85,8 @@ void setup() {
|
||||||
// The main sketch has responsibilities during setup()
|
// The main sketch has responsibilities during setup()
|
||||||
|
|
||||||
// Responsibility 1: Start the usb connection for diagnostics and possible JMRI input
|
// 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.
|
// Responsibility 2: Start the DCC engine.
|
||||||
DCC::begin();
|
DCC::begin();
|
||||||
|
@ -122,7 +123,7 @@ void loop() {
|
||||||
DCC::loop();
|
DCC::loop();
|
||||||
|
|
||||||
// Responsibility 2: handle any incoming commands on USB connection
|
// Responsibility 2: handle any incoming commands on USB connection
|
||||||
serialParser.loop(Serial);
|
serialParser.loop(DIAGSERIAL);
|
||||||
|
|
||||||
// Responsibility 3: Optionally handle any incoming WiFi traffic
|
// Responsibility 3: Optionally handle any incoming WiFi traffic
|
||||||
#ifdef WIFI
|
#ifdef WIFI
|
||||||
|
|
12
Hardware.cpp
12
Hardware.cpp
|
@ -17,7 +17,8 @@
|
||||||
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include <Arduino.h>
|
#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 "avdweb_AnalogReadFast.h"
|
||||||
#include "Hardware.h"
|
#include "Hardware.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
@ -82,11 +83,10 @@ unsigned int Hardware::getCurrentMilliamps(bool isMainTrack, int raw) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hardware::setCallback(int duration, void (*isr)()) {
|
void Hardware::setCallback(int duration, void (*isr)()) {
|
||||||
Timer1.initialize(duration);
|
TimerA.initialize();
|
||||||
// We don't want the timer to set pins because these often clash with motor shields etc.
|
TimerA.setPeriod(duration);
|
||||||
Timer1.disablePwm(TIMER1_A_PIN);
|
TimerA.attachInterrupt(isr);
|
||||||
Timer1.disablePwm(TIMER1_B_PIN);
|
TimerA.start();
|
||||||
Timer1.attachInterrupt(isr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// shortcut to cpu dependent high speed write
|
// shortcut to cpu dependent high speed write
|
||||||
|
|
|
@ -19,11 +19,10 @@
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
void StringFormatter::print( const __FlashStringHelper* input...) {
|
void StringFormatter::print( const __FlashStringHelper* input...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, input);
|
va_start(args, input);
|
||||||
send2(Serial,input,args);
|
send2(DIAGSERIAL,input,args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringFormatter::send(Print & stream, const __FlashStringHelper* input...) {
|
void StringFormatter::send(Print & stream, const __FlashStringHelper* input...) {
|
||||||
|
|
|
@ -19,6 +19,15 @@
|
||||||
#ifndef StringFormatter_h
|
#ifndef StringFormatter_h
|
||||||
#define StringFormatter_h
|
#define StringFormatter_h
|
||||||
#include <Arduino.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
|
class StringFormatter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user