Testground/Test/rs232.c

32 lines
703 B
C
Raw Normal View History

2013-10-06 18:10:06 +02:00
/*
* rs232.c
*
* Created: 06.10.2013 16:34:27
* Author: netz
*/
#include "config.h"
#include <stdio.h>
#include <avr/io.h>
#include "rs232.h"
int uart_putchar(char c, FILE *stream)
{
if (c == '\n') {
uart_putchar('\r', stream); //Warten solange bis Zeichen gesendet wurde
}
loop_until_bit_is_set(UCSR1A, UDRE1); //Ausgabe des Zeichens
UDR1 = c;
return (0);
}
void init_rs232()
{
UCSR1C = (1 << UCSZ11) |(1 << UCSZ10); //8N1
UCSR1B |= /*(1<<RXEN1) | (1<<RXCIE1) | */ (1<<TXEN1); //Enable TXEN im Register UCR TX-Data Enable
UBRR1L = (F_CPU / (BAUD_RATE * 16L) - 1); //Teiler wird gesetzt
stdout = &rs232; //<2F>ffnet einen Kanal f<>r printf (STDOUT)
}