Subversion Repositories Projects

Rev

Blame | Last modification | View Log | RSS feed

//############################################################################
// - PPM2PentaxIR Uart for Debug only
// - ATMEGA8 mit 8MHz
// - Nur für den privaten Gebrauch
// - Keine Garantie auf Fehlerfreiheit
// - Kommerzielle Nutzung nur mit meiner Zustimmung
// - walter Meyer @ www.freakware.de
//############################################################################*/

#include "main.h"
#include "uart.h"

void StartUART(void)
{
       
        // UART Double Speed (U2X)
        UCSRA |= (1<<U2X);          
        /* Enable receiver and transmitter, no RX Int, no TX Int */
        UCSRB = (1<<RXEN)|(1<<TXEN); // (1<<RXCIE)|(1<<TXCIE)
        /* Set frame format: 8data, 1stop bit */
        UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);

        //Teiler wird gesetzt
        UBRRL= (SYSCLK / (BAUD_RATE * 8L) -1 );

        //öffnet einen Kanal für printf (STDOUT)
        fdevopen (uart_putchar, NULL);

}

int uart_putchar (char c)
{
        if (c == '\n') uart_putchar('\r');
        loop_until_bit_is_set(UCSRA, UDRE);
        UDR = c;
       
        return (0);
}