#include <avr/io.h>
#include <avr/interrupt.h>
void port_init(void)
{
DDRD &= ~(1<PD0); // PORTD PD0 Input Port
PORTD |= (1<<PD0); // Switch pulled up
DDRL = 0xff; // PORTL Output Port
PORTL = 0x00; // PORTL (PORTL LED)
EICRA = (1<<ISC00); //level
// EICRA = (1<<ISC01) //falling edge
EIMSK |= (1<<INT0); //enable INT0
}
void init_devices(void)
{
cli(); // disable all interrupts
port_init();
sei(); // re-enable interrupts
}
int main(void)
{
init_devices();
while(1)
{
}
}
//External Interrupt
ISR(INT0_vect)
{
PORTL ^= 0xFF; // Toggle all LEDs on PORTL
}