aboutsummaryrefslogtreecommitdiffstats
path: root/serial/main.c
blob: 2e9ff5c40cf4a63ca0106731eda55b2815132408 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <avr/io.h>
#include "uart.h"

int main(void)
{
    /* serial */
    uart_init();

    /* D4 = output and high (=> atx down) */
    PORTD |= 0x10;
    DDRD  |= 0x10;

    for (;;)
    {
        switch(uart_getchar()) {
            case '?': break; /* useful for auto documentation */
            case '0': PORTD |=  0x10; break;
            case '1': PORTD &= ~0x10; break;
            case 'T': PORTD ^=  0x10; break;
        }
        uart_putchar((PORTD & 0x10) ? '0' : '1');
    }

    return 0;
}