mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 21:21:24 +01:00
shadow PORTX (PoC)
This commit is contained in:
parent
4a56998553
commit
af0d381e45
@ -28,6 +28,10 @@
|
|||||||
bool MotorDriver::usePWM=false;
|
bool MotorDriver::usePWM=false;
|
||||||
bool MotorDriver::commonFaultPin=false;
|
bool MotorDriver::commonFaultPin=false;
|
||||||
|
|
||||||
|
volatile byte fakePORTA;
|
||||||
|
volatile byte fakePORTB;
|
||||||
|
volatile byte fakePORTC;
|
||||||
|
|
||||||
MotorDriver::MotorDriver(VPIN power_pin, byte signal_pin, byte signal_pin2, int8_t brake_pin,
|
MotorDriver::MotorDriver(VPIN power_pin, byte signal_pin, byte signal_pin2, int8_t brake_pin,
|
||||||
byte current_pin, float sense_factor, unsigned int trip_milliamps, byte fault_pin) {
|
byte current_pin, float sense_factor, unsigned int trip_milliamps, byte fault_pin) {
|
||||||
powerPin=power_pin;
|
powerPin=power_pin;
|
||||||
@ -37,6 +41,19 @@ MotorDriver::MotorDriver(VPIN power_pin, byte signal_pin, byte signal_pin2, int8
|
|||||||
getFastPin(F("SIG"),signalPin,fastSignalPin);
|
getFastPin(F("SIG"),signalPin,fastSignalPin);
|
||||||
pinMode(signalPin, OUTPUT);
|
pinMode(signalPin, OUTPUT);
|
||||||
|
|
||||||
|
if (fastSignalPin.inout == &PORTA) {
|
||||||
|
DIAG(F("Found PORTA pin %d"),signalPin);
|
||||||
|
fastSignalPin.inout = &fakePORTA;
|
||||||
|
}
|
||||||
|
if (fastSignalPin.inout == &PORTB) {
|
||||||
|
DIAG(F("Found PORTB pin %d"),signalPin);
|
||||||
|
fastSignalPin.inout = &fakePORTB;
|
||||||
|
}
|
||||||
|
if (fastSignalPin.inout == &PORTC) {
|
||||||
|
DIAG(F("Found PORTC pin %d"),signalPin);
|
||||||
|
fastSignalPin.inout = &fakePORTC;
|
||||||
|
}
|
||||||
|
|
||||||
signalPin2=signal_pin2;
|
signalPin2=signal_pin2;
|
||||||
if (signalPin2!=UNUSED_PIN) {
|
if (signalPin2!=UNUSED_PIN) {
|
||||||
dualSignal=true;
|
dualSignal=true;
|
||||||
@ -50,6 +67,7 @@ MotorDriver::MotorDriver(VPIN power_pin, byte signal_pin, byte signal_pin2, int8
|
|||||||
invertBrake=brake_pin < 0;
|
invertBrake=brake_pin < 0;
|
||||||
brakePin=invertBrake ? 0-brake_pin : brake_pin;
|
brakePin=invertBrake ? 0-brake_pin : brake_pin;
|
||||||
getFastPin(F("BRAKE"),brakePin,fastBrakePin);
|
getFastPin(F("BRAKE"),brakePin,fastBrakePin);
|
||||||
|
// if brake is used for railcom cutout we need to do PORTX register trick here as well
|
||||||
pinMode(brakePin, OUTPUT);
|
pinMode(brakePin, OUTPUT);
|
||||||
setBrake(true); // start with brake on in case we hace DC stuff going on
|
setBrake(true); // start with brake on in case we hace DC stuff going on
|
||||||
}
|
}
|
||||||
|
@ -85,18 +85,34 @@ void TrackManager::addTrack(byte t, MotorDriver* driver) {
|
|||||||
track[t]->setPower(POWERMODE::OFF);
|
track[t]->setPower(POWERMODE::OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
extern byte fakePORTA;
|
||||||
|
extern byte fakePORTB;
|
||||||
|
extern byte fakePORTC;
|
||||||
|
|
||||||
void TrackManager::setDCCSignal( bool on) {
|
void TrackManager::setDCCSignal( bool on) {
|
||||||
|
fakePORTA=PORTA;
|
||||||
|
fakePORTB=PORTB;
|
||||||
|
fakePORTC=PORTC;
|
||||||
APPLY_BY_MODE(TRACK_MODE_MAIN,setSignal(on));
|
APPLY_BY_MODE(TRACK_MODE_MAIN,setSignal(on));
|
||||||
|
PORTA=fakePORTA;
|
||||||
|
PORTB=fakePORTB;
|
||||||
|
PORTC=fakePORTC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackManager::setCutout( bool on) {
|
void TrackManager::setCutout( bool on) {
|
||||||
(void) on;
|
(void) on;
|
||||||
|
// TODO Cutout needs fake ports as well
|
||||||
// TODO APPLY_BY_MODE(TRACK_MODE_MAIN,setCutout(on));
|
// TODO APPLY_BY_MODE(TRACK_MODE_MAIN,setCutout(on));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackManager::setPROGSignal( bool on) {
|
void TrackManager::setPROGSignal( bool on) {
|
||||||
|
fakePORTA=PORTA;
|
||||||
|
fakePORTB=PORTB;
|
||||||
|
fakePORTC=PORTC;
|
||||||
APPLY_BY_MODE(TRACK_MODE_PROG,setSignal(on));
|
APPLY_BY_MODE(TRACK_MODE_PROG,setSignal(on));
|
||||||
|
PORTA=fakePORTA;
|
||||||
|
PORTB=fakePORTB;
|
||||||
|
PORTC=fakePORTC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackManager::setDCSignal(int16_t cab, byte speedbyte) {
|
void TrackManager::setDCSignal(int16_t cab, byte speedbyte) {
|
||||||
|
Loading…
Reference in New Issue
Block a user