//
// Pin Change Interrupt Example
// By PEK '2004
//
// Compiler: GCC
// MCU: ATtiny2313
// Clock:
//

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>

// Pin Change Interrupt ISR
SIGNAL(SIG_PCINT)
{
	PORTD = PINB;
}

int main(void)
{	
	DDRB = 0x00;	// PortB as input
	PORTB = 0xFF;	// Enable pull-up
	
	DDRD = 0xFF;	// PortD as input
	PORTD = 0x00;

	GIMSK = _BV(PCIE);	// Pin Change Interrupt Enable
	PCMSK = 0xFF;	// Enable interrupt on all pins

	sei();	// Enable global interrupts
	
	while(1);	// Loop forever
	
	return 1;
}

