summaryrefslogtreecommitdiff
path: root/floppyMusic/uart.c
diff options
context:
space:
mode:
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