mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-24 08:36:14 +01:00
adding some final comments, already checked build
This commit is contained in:
parent
d52f422f05
commit
b81b7ee27f
|
@ -58,7 +58,7 @@ 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_GIGA
|
#ifndef ARDUINO_GIGA // no giga
|
||||||
fastSignalPin.shadowinout = NULL;
|
fastSignalPin.shadowinout = NULL;
|
||||||
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);
|
||||||
|
@ -90,14 +90,14 @@ 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
|
#endif // giga
|
||||||
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_GIGA
|
#ifndef ARDUINO_GIGA // no giga
|
||||||
fastSignalPin2.shadowinout = NULL;
|
fastSignalPin2.shadowinout = NULL;
|
||||||
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);
|
||||||
|
@ -129,7 +129,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
|
#endif // giga
|
||||||
}
|
}
|
||||||
else dualSignal=false;
|
else dualSignal=false;
|
||||||
|
|
||||||
|
@ -508,13 +508,13 @@ unsigned int MotorDriver::mA2raw( unsigned int mA) {
|
||||||
|
|
||||||
void MotorDriver::getFastPin(const FSH* type,int pin, bool input, FASTPIN & result) {
|
void MotorDriver::getFastPin(const FSH* type,int pin, bool input, FASTPIN & result) {
|
||||||
// DIAG(F("MotorDriver %S Pin=%d,"),type,pin);
|
// DIAG(F("MotorDriver %S Pin=%d,"),type,pin);
|
||||||
#if defined(ARDUINO_GIGA)
|
#if defined(ARDUINO_GIGA) // yes giga
|
||||||
(void)type;
|
(void)type;
|
||||||
(void)input; // no warnings please
|
(void)input; // no warnings please
|
||||||
|
|
||||||
result = pin;
|
result = pin;
|
||||||
|
|
||||||
#else
|
#else // no giga
|
||||||
(void) type; // avoid compiler warning if diag not used above.
|
(void) type; // avoid compiler warning if diag not used above.
|
||||||
#if defined(ARDUINO_ARCH_SAMD)
|
#if defined(ARDUINO_ARCH_SAMD)
|
||||||
PortGroup *port = digitalPinToPort(pin);
|
PortGroup *port = digitalPinToPort(pin);
|
||||||
|
@ -529,7 +529,7 @@ void MotorDriver::getFastPin(const FSH* type,int pin, bool input, FASTPIN & res
|
||||||
result.inout = portOutputRegister(port);
|
result.inout = portOutputRegister(port);
|
||||||
result.maskHIGH = digitalPinToBitMask(pin);
|
result.maskHIGH = digitalPinToBitMask(pin);
|
||||||
result.maskLOW = ~result.maskHIGH;
|
result.maskLOW = ~result.maskHIGH;
|
||||||
#endif
|
#endif // giga
|
||||||
// DIAG(F(" port=0x%x, inoutpin=0x%x, isinput=%d, mask=0x%x"),port, result.inout,input,result.maskHIGH);
|
// DIAG(F(" port=0x%x, inoutpin=0x%x, isinput=%d, mask=0x%x"),port, result.inout,input,result.maskHIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,21 +31,21 @@
|
||||||
// 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};
|
||||||
#if defined(ARDUINO_GIGA)
|
#if defined(ARDUINO_GIGA) // yes giga
|
||||||
|
|
||||||
#define setHIGH(fastpin) digitalWrite(fastpin,1)
|
#define setHIGH(fastpin) digitalWrite(fastpin,1)
|
||||||
#define setLOW(fastpin) digitalWrite(fastpin,0)
|
#define setLOW(fastpin) digitalWrite(fastpin,0)
|
||||||
#else
|
#else // no giga
|
||||||
#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 // giga
|
||||||
#if defined(ARDUINO_GIGA)
|
#if defined(ARDUINO_GIGA) // yes giga
|
||||||
#define isHIGH(fastpin) ((PinStatus)digitalRead(fastpin)==1)
|
#define isHIGH(fastpin) ((PinStatus)digitalRead(fastpin)==1)
|
||||||
#define isLOW(fastpin) ((PinStatus)digitalRead(fastpin)==0)
|
#define isLOW(fastpin) ((PinStatus)digitalRead(fastpin)==0)
|
||||||
#else
|
#else // no giga
|
||||||
#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
|
#endif // giga
|
||||||
#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)
|
||||||
|
|
||||||
|
@ -127,18 +127,18 @@ typedef uint32_t portreg_t;
|
||||||
typedef uint8_t portreg_t;
|
typedef uint8_t portreg_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ARDUINO_GIGA)
|
#if defined(ARDUINO_GIGA) // yes giga
|
||||||
typedef int FASTPIN;
|
typedef int FASTPIN;
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else // no giga
|
||||||
struct FASTPIN {
|
struct FASTPIN {
|
||||||
volatile portreg_t *inout;
|
volatile portreg_t *inout;
|
||||||
portreg_t maskHIGH;
|
portreg_t maskHIGH;
|
||||||
portreg_t maskLOW;
|
portreg_t maskLOW;
|
||||||
volatile portreg_t *shadowinout;
|
volatile portreg_t *shadowinout;
|
||||||
};
|
};
|
||||||
#endif
|
#endif // giga
|
||||||
|
|
||||||
// The port registers that are shadowing
|
// The port registers that are shadowing
|
||||||
// the real port registers. These are
|
// the real port registers. These are
|
||||||
|
@ -165,12 +165,12 @@ class MotorDriver {
|
||||||
// otherwise the call from interrupt context can undo whatever we do
|
// otherwise the call from interrupt context can undo whatever we do
|
||||||
// from outside interrupt
|
// from outside interrupt
|
||||||
void setBrake( bool on, bool interruptContext=false);
|
void setBrake( bool on, bool interruptContext=false);
|
||||||
#if defined(ARDUINO_GIGA)
|
#if defined(ARDUINO_GIGA) // yes giga
|
||||||
__attribute__((always_inline)) inline void setSignal( bool high) {
|
__attribute__((always_inline)) inline void setSignal( bool high) {
|
||||||
digitalWrite(signalPin, high);
|
digitalWrite(signalPin, high);
|
||||||
if (dualSignal) digitalWrite(signalPin2, !high);
|
if (dualSignal) digitalWrite(signalPin2, !high);
|
||||||
};
|
};
|
||||||
#else
|
#else // no giga
|
||||||
__attribute__((always_inline)) inline void setSignal( bool high) {
|
__attribute__((always_inline)) inline void setSignal( bool high) {
|
||||||
if (trackPWM) {
|
if (trackPWM) {
|
||||||
DCCTimer::setPWM(signalPin,high);
|
DCCTimer::setPWM(signalPin,high);
|
||||||
|
@ -186,7 +186,7 @@ class MotorDriver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif // giga
|
||||||
inline void enableSignal(bool on) {
|
inline void enableSignal(bool on) {
|
||||||
if (on)
|
if (on)
|
||||||
pinMode(signalPin, OUTPUT);
|
pinMode(signalPin, OUTPUT);
|
||||||
|
@ -208,12 +208,12 @@ class MotorDriver {
|
||||||
int getCurrentRaw(bool fromISR=false);
|
int getCurrentRaw(bool fromISR=false);
|
||||||
unsigned int raw2mA( int raw);
|
unsigned int raw2mA( int raw);
|
||||||
unsigned int mA2raw( unsigned int mA);
|
unsigned int mA2raw( unsigned int mA);
|
||||||
#if defined(ARDUINO_GIGA)
|
#if defined(ARDUINO_GIGA) // yes giga
|
||||||
inline bool digitalPinHasPWM(int pin) {
|
inline bool digitalPinHasPWM(int pin) {
|
||||||
if (pin!=UNUSED_PIN && pin>=2 && pin<=13) return true;
|
if (pin!=UNUSED_PIN && pin>=2 && pin<=13) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // giga
|
||||||
inline bool brakeCanPWM() {
|
inline bool brakeCanPWM() {
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
return (brakePin != UNUSED_PIN); // This was just (true) but we probably do need to check for UNUSED_PIN!
|
return (brakePin != UNUSED_PIN); // This was just (true) but we probably do need to check for UNUSED_PIN!
|
||||||
|
|
|
@ -58,13 +58,13 @@ Stream * WifiInterface::wifiStream;
|
||||||
#define SERIAL3 Serial3
|
#define SERIAL3 Serial3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(ARDUINO_GIGA))
|
#if defined(ARDUINO_GIGA) // yes giga
|
||||||
#define NUM_SERIAL 5
|
#define NUM_SERIAL 5
|
||||||
#define SERIAL1 Serial1
|
#define SERIAL1 Serial1
|
||||||
#define SERIAL2 Serial2
|
#define SERIAL2 Serial2
|
||||||
#define SERIAL3 Serial3
|
#define SERIAL3 Serial3
|
||||||
#define SERIAL4 Serial4
|
#define SERIAL4 Serial4
|
||||||
#endif
|
#endif // giga
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_STM32)
|
#if defined(ARDUINO_ARCH_STM32)
|
||||||
// Handle serial ports availability on STM32 for variants!
|
// Handle serial ports availability on STM32 for variants!
|
||||||
|
|
|
@ -148,7 +148,7 @@
|
||||||
// #ifndef I2C_USE_WIRE
|
// #ifndef I2C_USE_WIRE
|
||||||
// #define I2C_USE_WIRE
|
// #define I2C_USE_WIRE
|
||||||
// #endif
|
// #endif
|
||||||
#elif defined(ARDUINO_ARCH_MBED_GIGA)
|
#elif defined(ARDUINO_GIGA)
|
||||||
#define ARDUINO_TYPE "Giga"
|
#define ARDUINO_TYPE "Giga"
|
||||||
#ifndef DISABLE_EEPROM
|
#ifndef DISABLE_EEPROM
|
||||||
#define DISABLE_EEPROM
|
#define DISABLE_EEPROM
|
||||||
|
|
Loading…
Reference in New Issue
Block a user