src/hello.c
author Tero Marttila <terom@paivola.fi>
Wed, 24 Sep 2014 22:54:26 +0300
changeset 1 dc293f9aa873
parent 0 cae83b7bfcf4
child 2 2687fbd14fd9
permissions -rw-r--r--
hello: use serial
#include <avr/interrupt.h>
#include <avr/io.h>

#define DEBUG_DDR DDRB
#define DEBUG_PIN 5
#define DEBUG_PORT PORTB

#include "debug.h"
#include "serial.h"
#include "timer.h"

int main (void)
{
    debug_init();
    serial_init(SERIAL_BAUD_9600, SERIAL_PARITY_N, SERIAL_STOPBITS_1);
    timer_init();

    // init
    char c = '.';
    unsigned short timeout = 8000;

    debug_set();
    sei();


    // start
    while (true) {
        if (timer_sleep(timeout)) {
            c = '.';
        } else if ((c = serial_read())) {

        } else {
            c = '?';
        }

        debug_toggle();

        // out
        serial_write(c);
    }
}