//  mirror.c -- does something with input PORTD onto output PORTB
//  implemented and tested on an AT90S8515 & STK500 
// 
//  Copyleft (!C) 2003 S. Mann and C. Manders,
//  (http://www.gnu.org/copyleft/gpl.html);
//  based on Stephen Lacy's (slacy@slacy.com) "mirror.c"


//#include <io-avr.h> (doesn't compile when this is there)
#include <avr/io.h>
#include <avr/wdt.h> 
//#include <unistd.h>

void delay(long N) {
    long n;
    for (n=0; n<N; n++);
}

int main(void) {
    outp (0xFF,DDRB); /* PORTB is all output; 1 means output; 0 means input */
    outp (0x00,DDRD); /* PORTD is all input */

    //outp(0,PORTB);
    while (1) {
	unsigned char x, y;
	x = inp(PIND);
	y = x; /* you can add various modifications like 255-x, etc. */
        outp (y,DDRB); /* we're using DDRB because PORTB not properly defined */
    }
}

