35,30 → 35,43 |
int main(void) |
{ |
char i,Parity; // Bit-Counter and Parity Bit |
DDRA = 0b011; // PORT A INPUT: /RESET; OUTPUT: Sync+Data |
DDRA = 0b011; // PORT A INPUT: RESET; OUTPUT: Sync+Data |
DDRB = 0b00000000; // PORT B INPUT: Jumper for Bypass |
DDRD = 0b0000000; // PORT D INPUT: Switches + DX7-Sync |
PORTA = 0b111; // Pull-Up for /RESET; High for Sync+Data |
PORTA = 0b111; // Pull-Up for /RESET, High for Sync+Data |
PORTB = 0b01000000; // Pull-Up for Jumper |
PORTD = 0b0011111; // Pull-Up for Switches |
|
while(1) // Main-Loop (Sending data all the time) |
{ |
Parity = 0; // Reset Parity Bit |
Send(1,0); // Send SYNC Pulse |
if (!(PINB & (1<<PINB6))) // By-Pass Mode |
{ |
if (PIND & (1<<PIND0)) PORTA |= 1 << PORTA1; // A1=D0 |
else PORTA &= ~(1 << PORTA1); |
|
for (i=0;i<5;i++) // Encode the first five Port Pins |
if (PIND & (1<<PIND1)) PORTA |= 1 << PORTA0; // A0=D1 |
else PORTA &= ~(1 << PORTA0); |
} |
else // Normal Mode |
{ |
if (PIND & (1<<i)) // Check Pin #i |
Parity = 0; // Reset Parity Bit |
Send(1,0); // Send SYNC Pulse |
|
for (i=0;i<5;i++) // Encode the first five Port Pins |
{ |
Send(0,0); // When High, Send Low (Switched to "0") |
Parity = ~Parity; // and invert Parity Bit |
if (PIND & (1<<i)) // Check Pin #i |
{ |
Send(0,0); // When High, Send Low (Switched to "0") |
Parity = ~Parity; // and invert Parity Bit |
} |
else |
{ |
Send(0,1); // When Low, Send High (Switched to "1") |
} |
} |
else |
{ |
Send(0,1); // When Low, Send High (Switched to "1") |
} |
|
Send(0,Parity); // Send Parity Bit |
} |
|
Send(0,Parity); // Send Parity Bit |
} |
|
} |