36 lines
586 B
C
36 lines
586 B
C
#include <avr/io.h>
|
|
#include <util/delay.h>
|
|
|
|
#include "interupt.h"
|
|
#include "mystd.h"
|
|
|
|
#include "uart.h"
|
|
|
|
// interrupt for INT0 (external interrupt)
|
|
void __attribute__((signal, used)) __vector_1(void) {
|
|
my_cli();
|
|
_delay_ms(20);
|
|
PORTB ^= _BV(PB0);
|
|
// clear the register "pending" bit
|
|
EIFR |= _BV(INTF0);
|
|
my_sei();
|
|
}
|
|
|
|
int main(void) {
|
|
uart_init();
|
|
|
|
DDRB |= _BV(PB0);
|
|
DDRD &= ~_BV(PD2);
|
|
|
|
// Set INT0 to trigger on falling edge
|
|
EICRA &= ~(_BV(ISC00) | _BV(ISC01));
|
|
EICRA |= _BV(ISC01);
|
|
|
|
// yes we want the INT0 interupt !
|
|
EIMSK |= _BV(INT0);
|
|
|
|
my_sei();
|
|
|
|
while (1) {
|
|
}
|
|
}
|