Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 22 lines (20 sloc) 0.651 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#define pinPort( P ) ( ( P ) <= 7 ? &PORTD : ( ( P ) <= 13 ? &PORTB : &PORTC ) )
#define pinBit( P ) ( ( P ) <= 7 ? ( P ) : ( ( P ) <= 13 ? ( P ) - 8 : ( P ) - 14 ) )
#define fastWrite( P, V ) bitWrite( *pinPort( P ), pinBit( P ), ( V ) )
#define fastRead( P ) bitRead( *pinPort( P ), pinBit( P ) )

void setup() {
  pinMode(0, INPUT);
  pinMode(1, OUTPUT);
  pinMode(2, INPUT);
  pinMode(3, OUTPUT);
}

void loop() {
  // disable interrupts - reduces jitter
  cli();
  while(1) {
    // copy+invert data between pc usb port (0&1)
    // and machine "virtual" serial port (2&3)
    fastWrite(3,!fastRead(0));
    fastWrite(2,!fastRead(1));
  }
}
Something went wrong with that request. Please try again.