//  test.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 "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);/* Data Direction Register: 1 means output; 0 means input*/
    outp (0x00,DDRD);/* set all bits in PORTD to Direction 0 = input */

    //outp(0,PORTB);
    while (1) {
	unsigned char x, y;
	x = inp(PIND);
	y = x;  /* can do some other things here like y=255-x; */
        outp (y,PORTB);
    }
}

