1
0
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:
travis-farmer 2023-10-27 11:11:21 -04:00
parent d52f422f05
commit b81b7ee27f
4 changed files with 24 additions and 24 deletions

View File

@ -58,7 +58,7 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
getFastPin(F("SIG"),signalPin,fastSignalPin);
pinMode(signalPin, OUTPUT);
#ifndef ARDUINO_GIGA
#ifndef ARDUINO_GIGA // no giga
fastSignalPin.shadowinout = NULL;
if (HAVE_PORTA(fastSignalPin.inout == &PORTA)) {
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.inout = &shadowPORTF;
}
#endif
#endif // giga
signalPin2=signal_pin2;
if (signalPin2!=UNUSED_PIN) {
dualSignal=true;
getFastPin(F("SIG2"),signalPin2,fastSignalPin2);
pinMode(signalPin2, OUTPUT);
#ifndef ARDUINO_GIGA
#ifndef ARDUINO_GIGA // no giga
fastSignalPin2.shadowinout = NULL;
if (HAVE_PORTA(fastSignalPin2.inout == &PORTA)) {
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.inout = &shadowPORTF;
}
#endif
#endif // giga
}
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) {
// DIAG(F("MotorDriver %S Pin=%d,"),type,pin);
#if defined(ARDUINO_GIGA)
#if defined(ARDUINO_GIGA) // yes giga
(void)type;
(void)input; // no warnings please
result = pin;
#else
#else // no giga
(void) type; // avoid compiler warning if diag not used above.
#if defined(ARDUINO_ARCH_SAMD)
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.maskHIGH = digitalPinToBitMask(pin);
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);
}

View File

@ -31,21 +31,21 @@
// 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,
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 setLOW(fastpin) digitalWrite(fastpin,0)
#else
#else // no giga
#define setHIGH(fastpin) *fastpin.inout |= fastpin.maskHIGH
#define setLOW(fastpin) *fastpin.inout &= fastpin.maskLOW
#endif
#if defined(ARDUINO_GIGA)
#endif // giga
#if defined(ARDUINO_GIGA) // yes giga
#define isHIGH(fastpin) ((PinStatus)digitalRead(fastpin)==1)
#define isLOW(fastpin) ((PinStatus)digitalRead(fastpin)==0)
#else
#else // no giga
#define isHIGH(fastpin) (*fastpin.inout & fastpin.maskHIGH)
#define isLOW(fastpin) (!isHIGH(fastpin))
#endif
#endif // giga
#define TOKENPASTE(x, y) x ## y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
@ -127,18 +127,18 @@ typedef uint32_t portreg_t;
typedef uint8_t portreg_t;
#endif
#if defined(ARDUINO_GIGA)
#if defined(ARDUINO_GIGA) // yes giga
typedef int FASTPIN;
#else
#else // no giga
struct FASTPIN {
volatile portreg_t *inout;
portreg_t maskHIGH;
portreg_t maskLOW;
volatile portreg_t *shadowinout;
};
#endif
#endif // giga
// The port registers that are shadowing
// the real port registers. These are
@ -165,12 +165,12 @@ class MotorDriver {
// otherwise the call from interrupt context can undo whatever we do
// from outside interrupt
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) {
digitalWrite(signalPin, high);
if (dualSignal) digitalWrite(signalPin2, !high);
};
#else
#else // no giga
__attribute__((always_inline)) inline void setSignal( bool high) {
if (trackPWM) {
DCCTimer::setPWM(signalPin,high);
@ -186,7 +186,7 @@ class MotorDriver {
}
}
};
#endif
#endif // giga
inline void enableSignal(bool on) {
if (on)
pinMode(signalPin, OUTPUT);
@ -208,12 +208,12 @@ class MotorDriver {
int getCurrentRaw(bool fromISR=false);
unsigned int raw2mA( int raw);
unsigned int mA2raw( unsigned int mA);
#if defined(ARDUINO_GIGA)
#if defined(ARDUINO_GIGA) // yes giga
inline bool digitalPinHasPWM(int pin) {
if (pin!=UNUSED_PIN && pin>=2 && pin<=13) return true;
else return false;
}
#endif
#endif // giga
inline bool brakeCanPWM() {
#if defined(ARDUINO_ARCH_ESP32)
return (brakePin != UNUSED_PIN); // This was just (true) but we probably do need to check for UNUSED_PIN!

View File

@ -58,13 +58,13 @@ Stream * WifiInterface::wifiStream;
#define SERIAL3 Serial3
#endif
#if (defined(ARDUINO_GIGA))
#if defined(ARDUINO_GIGA) // yes giga
#define NUM_SERIAL 5
#define SERIAL1 Serial1
#define SERIAL2 Serial2
#define SERIAL3 Serial3
#define SERIAL4 Serial4
#endif
#endif // giga
#if defined(ARDUINO_ARCH_STM32)
// Handle serial ports availability on STM32 for variants!

View File

@ -148,7 +148,7 @@
// #ifndef I2C_USE_WIRE
// #define I2C_USE_WIRE
// #endif
#elif defined(ARDUINO_ARCH_MBED_GIGA)
#elif defined(ARDUINO_GIGA)
#define ARDUINO_TYPE "Giga"
#ifndef DISABLE_EEPROM
#define DISABLE_EEPROM