1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-24 16:46:13 +01:00

corrected changes from haba

This commit is contained in:
travis-farmer 2023-10-20 04:45:39 -04:00
parent 94273b6e11
commit b417ad6575
2 changed files with 12 additions and 9 deletions

View File

@ -57,9 +57,8 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
getFastPin(F("SIG"),signalPin,fastSignalPin); getFastPin(F("SIG"),signalPin,fastSignalPin);
pinMode(signalPin, OUTPUT); pinMode(signalPin, OUTPUT);
#ifndef ARDUINO_ARCH_MBED_GIGA #ifndef ARDUINO_GIGA
fastSignalPin.shadowinout = NULL; fastSignalPin.shadowinout = NULL;
#endif
if (HAVE_PORTA(fastSignalPin.inout == &PORTA)) { if (HAVE_PORTA(fastSignalPin.inout == &PORTA)) {
DIAG(F("Found PORTA pin %d"),signalPin); DIAG(F("Found PORTA pin %d"),signalPin);
fastSignalPin.shadowinout = fastSignalPin.inout; fastSignalPin.shadowinout = fastSignalPin.inout;
@ -90,16 +89,15 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
fastSignalPin.shadowinout = fastSignalPin.inout; fastSignalPin.shadowinout = fastSignalPin.inout;
fastSignalPin.inout = &shadowPORTF; fastSignalPin.inout = &shadowPORTF;
} }
#endif
signalPin2=signal_pin2; signalPin2=signal_pin2;
if (signalPin2!=UNUSED_PIN) { if (signalPin2!=UNUSED_PIN) {
dualSignal=true; dualSignal=true;
getFastPin(F("SIG2"),signalPin2,fastSignalPin2); getFastPin(F("SIG2"),signalPin2,fastSignalPin2);
pinMode(signalPin2, OUTPUT); pinMode(signalPin2, OUTPUT);
#ifndef ARDUINO_ARCH_MBED_ARDUINO #ifndef ARDUINO_GIGA
fastSignalPin2.shadowinout = NULL; fastSignalPin2.shadowinout = NULL;
#endif
if (HAVE_PORTA(fastSignalPin2.inout == &PORTA)) { if (HAVE_PORTA(fastSignalPin2.inout == &PORTA)) {
DIAG(F("Found PORTA pin %d"),signalPin2); DIAG(F("Found PORTA pin %d"),signalPin2);
fastSignalPin2.shadowinout = fastSignalPin2.inout; fastSignalPin2.shadowinout = fastSignalPin2.inout;
@ -130,6 +128,7 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
fastSignalPin2.shadowinout = fastSignalPin2.inout; fastSignalPin2.shadowinout = fastSignalPin2.inout;
fastSignalPin2.inout = &shadowPORTF; fastSignalPin2.inout = &shadowPORTF;
} }
#endif
} }
else dualSignal=false; else dualSignal=false;

View File

@ -30,16 +30,20 @@
// use powers of two so we can do logical and/or on the track modes in if clauses. // use powers of two so we can do logical and/or on the track modes in if clauses.
enum TRACK_MODE : byte {TRACK_MODE_NONE = 1, TRACK_MODE_MAIN = 2, TRACK_MODE_PROG = 4, enum TRACK_MODE : byte {TRACK_MODE_NONE = 1, TRACK_MODE_MAIN = 2, TRACK_MODE_PROG = 4,
TRACK_MODE_DC = 8, TRACK_MODE_DCX = 16, TRACK_MODE_EXT = 32}; TRACK_MODE_DC = 8, TRACK_MODE_DCX = 16, TRACK_MODE_EXT = 32};
#ifdef ARDUINO_ARCH_MBED_GIGA #ifdef ARDUINO_GIGA
#define setHIGH(fastpin) (gpio_read(&fastpin)==1) #define setHIGH(fastpin) gpio_write(&fastpin, 1)
#define setLOW(fastpin) (gpio_read(&fastpin)==0) #define setLOW(fastpin) gpio_write(&fastpin, 0)
#else #else
#define setHIGH(fastpin) *fastpin.inout |= fastpin.maskHIGH #define setHIGH(fastpin) *fastpin.inout |= fastpin.maskHIGH
#define setLOW(fastpin) *fastpin.inout &= fastpin.maskLOW #define setLOW(fastpin) *fastpin.inout &= fastpin.maskLOW
#endif #endif
#if defined(ARDUINO_GIGA)
#define isHIGH(fastpin) (gpio_read(&fastpin)==1)
#define isLOW(fastpin) (gpio_read(&fastpin)==0)
#else
#define isHIGH(fastpin) (*fastpin.inout & fastpin.maskHIGH) #define isHIGH(fastpin) (*fastpin.inout & fastpin.maskHIGH)
#define isLOW(fastpin) (!isHIGH(fastpin)) #define isLOW(fastpin) (!isHIGH(fastpin))
#endif
#define TOKENPASTE(x, y) x ## y #define TOKENPASTE(x, y) x ## y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y) #define TOKENPASTE2(x, y) TOKENPASTE(x, y)