aboutsummaryrefslogtreecommitdiff
path: root/src/inc/uart/uart.c
diff options
context:
space:
mode:
authorMax Christian Pohle2015-07-27 15:12:22 +0200
committerMax Christian Pohle2015-07-27 15:12:22 +0200
commit2df2697107d7873232c31a25a6947711b0903edb (patch)
treeff7247e9e970c69f3d3385950b19db9997a511b8 /src/inc/uart/uart.c
downloadalarmclock-2df2697107d7873232c31a25a6947711b0903edb.tar.bz2
alarmclock-2df2697107d7873232c31a25a6947711b0903edb.zip
latest running version from march 2011, not having been in repo before,
dcf77 working, mp3 playback and two display types are supported
Diffstat (limited to 'src/inc/uart/uart.c')
-rwxr-xr-xsrc/inc/uart/uart.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/inc/uart/uart.c b/src/inc/uart/uart.c
new file mode 100755
index 0000000..b2f1a59
--- /dev/null
+++ b/src/inc/uart/uart.c
@@ -0,0 +1,47 @@
1#include "uart.h"
2
3/// // UART-Receiver...
4/// ISR(USART_RXC_vect)
5/// {
6 /// unsigned char buffer;
7 /// buffer = UDR;
8 /// if(uart_string.size == -1) return;
9 /// if(buffer == '\n')
10 /// {
11 /// uart_string.data[uart_string.size] = '\0';
12 /// uart_string.size = -1;
13 /// }
14 /// else
15 /// {
16 /// uart_string.data[uart_string.size] = buffer;
17 /// if(++uart_string.size > STRING_SIZE)
18 /// { uart_string.size = 0; }
19 /// }
20/// }
21
22void uart_init()
23{
24 /// uart_string.size = 0;
25 /// uart_string.data[0] = '\0';
26
27 // activate UART TX // and RX...
28 UCSRB |= (1<<TXEN); // | (1<<RXEN) | (1<<RXCIE);
29 // Asynchron 8N1 ...
30 UCSRC |= (1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0);
31
32 UBRRH = UBRRH_VALUE;
33 UBRRL = UBRRL_VALUE;
34 #if USE_2X
35 UCSRA |= (1 << U2X);
36 #else
37 UCSRA &= ~(1 << U2X);
38 #endif
39}
40
41void uart_putc(char c)
42{
43 UDR = c; /* schreibt das Zeichen x auf die Schnittstelle */
44 loop_until_bit_is_set(UCSRA, UDRE);
45}
46
47
..