#define F_CPU 8000000UL #include #include #define baud 9600 #define baud_prescale (F_CPU / 16 / baud-1) #define portio PORTD #define irrec PD2 #define rxled PD7 volatile uint16_t ir_data = 0; volatile uint8_t ir_cnt = 0; volatile uint8_t ir_1st = 0; volatile uint8_t ir_paste = 0; volatile uint8_t rx_store = 0; volatile uint8_t rx_enable = 0; volatile uint8_t rx_enable_cnt = 0; void io_init(void) { DDRD |= (1 << PD7); DDRB = 0xff; PORTB = 0xff; DDRC = 0xff; PORTC = 0xff; } void int_init(void) { GICR |= (1<> 8); } void sendChar(char data) { while(!(UCSRA & (1< 8000 && TCNT1 < 11200) ir_data &= ~(1< 12800 && TCNT1 < 16000) ir_data |= (1< 0) { if(rx_enable_cnt < 4) rx_enable_cnt++; else { if(!(portio & (1<= 20) { portio &= ~(1 << rxled); rx_enable_cnt = 0; rx_enable = 0; } } } } ISR(USART_RXC_vect) { rx_store = UDR; rx_enable = 1; } int main(void) { io_init(); int_init(); usart_init(); sei(); int0cnt = 0; while(1) { if(TCNT1 > 20000) { ir_1st = 0; TCCR1B &= ~(1<> 8); } } }