blob: b2f1a596fe216be8a6bf882284d4c0f5402c579e (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "uart.h"
/// // UART-Receiver...
/// ISR(USART_RXC_vect)
/// {
/// unsigned char buffer;
/// buffer = UDR;
/// if(uart_string.size == -1) return;
/// if(buffer == '\n')
/// {
/// uart_string.data[uart_string.size] = '\0';
/// uart_string.size = -1;
/// }
/// else
/// {
/// uart_string.data[uart_string.size] = buffer;
/// if(++uart_string.size > STRING_SIZE)
/// { uart_string.size = 0; }
/// }
/// }
void uart_init()
{
/// uart_string.size = 0;
/// uart_string.data[0] = '\0';
// activate UART TX // and RX...
UCSRB |= (1<<TXEN); // | (1<<RXEN) | (1<<RXCIE);
// Asynchron 8N1 ...
UCSRC |= (1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0);
UBRRH = UBRRH_VALUE;
UBRRL = UBRRL_VALUE;
#if USE_2X
UCSRA |= (1 << U2X);
#else
UCSRA &= ~(1 << U2X);
#endif
}
void uart_putc(char c)
{
UDR = c; /* schreibt das Zeichen x auf die Schnittstelle */
loop_until_bit_is_set(UCSRA, UDRE);
}
|