summaryrefslogtreecommitdiff
path: root/floppyMusic/uart.c
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2017-05-02 21:15:14 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2017-05-02 21:15:14 +0200
commitde57772e2027729e76482a2771d60f444a975036 (patch)
tree9d694deff1ff1e2261ae0190044486d8414eb05e /floppyMusic/uart.c
parent677c370834102ae43ce19d0931cc98d8267dacc5 (diff)
downloadavrFloppy-de57772e2027729e76482a2771d60f444a975036.tar.gz
added UART Library
Diffstat (limited to 'floppyMusic/uart.c')
-rw-r--r--floppyMusic/uart.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/floppyMusic/uart.c b/floppyMusic/uart.c
new file mode 100644
index 0000000..d4d5ccf
--- /dev/null
+++ b/floppyMusic/uart.c
@@ -0,0 +1,40 @@
+/*
+ * uart.c
+ *
+ * Created: 02.05.2017 20:48:26
+ * Author: Jonas
+ */
+
+ #include "uart.h"
+
+ void uart_init(uint32_t _baud)
+ {
+ unsigned int ubrr = _GET_UBBR(_baud);
+
+ UBRRH = (ubrr<<8);
+ UBRRL = ubrr;
+ }
+
+ void uart_send(char _data)
+ {
+ while(!(UCSRA & (1<<UDRE)));
+ UDR = _data;
+ }
+
+ void uart_send_string(char *_data)
+ {
+ char *data = _data;
+
+ while(*data != '\0')
+ {
+ uart_send(*data);
+ data++;
+ }
+ }
+
+ char uart_recieve()
+ {
+ while(!(UCSRA & (1<<RXC)));
+
+ return UDR;
+ } \ No newline at end of file