mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-24 16:46:13 +01:00
Keeping up to date
This commit is contained in:
parent
9e6104fc16
commit
5b4a1dd6fa
|
@ -501,9 +501,15 @@ unsigned int MotorDriver::mA2raw( unsigned int mA) {
|
||||||
return (int32_t)mA * senseScale / senseFactorInternal;
|
return (int32_t)mA * senseScale / senseFactorInternal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
(void) type; // avoid compiler warning if diag not used above.
|
(void) type; // avoid compiler warning if diag not used above.
|
||||||
|
#if defined(ARDUINO_GIGA)
|
||||||
|
(void)type;
|
||||||
|
(void)input; // no warnings please
|
||||||
|
*result = digitalPinToGpio(pin);
|
||||||
|
#else
|
||||||
#if defined(ARDUINO_ARCH_SAMD)
|
#if defined(ARDUINO_ARCH_SAMD)
|
||||||
PortGroup *port = digitalPinToPort(pin);
|
PortGroup *port = digitalPinToPort(pin);
|
||||||
#elif defined(ARDUINO_ARCH_STM32)
|
#elif defined(ARDUINO_ARCH_STM32)
|
||||||
|
@ -517,6 +523,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
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,14 @@
|
||||||
// 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)
|
||||||
|
|
||||||
|
#define setHIGH(fastpin) gpio_write(&fastpin, 1)
|
||||||
|
#define setLOW(fastpin) gpio_write(&fastpin, 0)
|
||||||
|
#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
|
||||||
#define isHIGH(fastpin) (*fastpin.inout & fastpin.maskHIGH)
|
#define isHIGH(fastpin) (*fastpin.inout & fastpin.maskHIGH)
|
||||||
#define isLOW(fastpin) (!isHIGH(fastpin))
|
#define isLOW(fastpin) (!isHIGH(fastpin))
|
||||||
|
|
||||||
|
@ -117,12 +122,17 @@ typedef uint32_t portreg_t;
|
||||||
typedef uint8_t portreg_t;
|
typedef uint8_t portreg_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARDUINO_GIGA)
|
||||||
|
typedef gpio_t FASTPIN;
|
||||||
|
#else
|
||||||
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
|
||||||
|
|
||||||
// The port registers that are shadowing
|
// The port registers that are shadowing
|
||||||
// the real port registers. These are
|
// the real port registers. These are
|
||||||
// defined in Motordriver.cpp
|
// defined in Motordriver.cpp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user