1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-26 17:46:14 +01:00
This commit is contained in:
Asbelos 2022-12-26 10:09:34 +00:00
parent 3e5d3b1caa
commit e06668f042

View File

@ -70,23 +70,22 @@ void _loopInput(unsigned long currentMicros) {
//set latch to HIGH to freeze & store parallel data //set latch to HIGH to freeze & store parallel data
ArduinoPins::fastWriteDigital(_latchPin, HIGH); ArduinoPins::fastWriteDigital(_latchPin, HIGH);
delayMicroseconds(50); delayMicroseconds(1);
//set latch to LOW to enable the data to be transmitted serially //set latch to LOW to enable the data to be transmitted serially
ArduinoPins::fastWriteDigital(_latchPin, LOW); ArduinoPins::fastWriteDigital(_latchPin, LOW);
delayMicroseconds(50);
// stream in the bitmap using mapping order provided at constructor // stream in the bitmap using mapping order provided at constructor
for (int xmitByte=0;xmitByte<_nShiftBytes; xmitByte++) { for (int xmitByte=0;xmitByte<_nShiftBytes; xmitByte++) {
byte newByte=0; byte newByte=0;
for (int xmitBit=0;xmitBit<8; xmitBit++) { for (int xmitBit=0;xmitBit<8; xmitBit++) {
ArduinoPins::fastWriteDigital(_clockPin, LOW); ArduinoPins::fastWriteDigital(_clockPin, LOW);
delayMicroseconds(20); delayMicroseconds(1);
bool data = ArduinoPins::fastReadDigital(_dataPin); bool data = ArduinoPins::fastReadDigital(_dataPin);
byte map=_pinMap[xmitBit]; byte map=_pinMap[xmitBit];
if (data) newByte |= map; if (data) newByte |= map;
else newByte &= ~map; else newByte &= ~map;
ArduinoPins::fastWriteDigital(_clockPin, HIGH); ArduinoPins::fastWriteDigital(_clockPin, HIGH);
delayMicroseconds(20); delayMicroseconds(1);
} }
_pinValues[xmitByte]=newByte; _pinValues[xmitByte]=newByte;
// DIAG(F("DIN %x=%x"),xmitByte, newByte); // DIAG(F("DIN %x=%x"),xmitByte, newByte);