summaryrefslogtreecommitdiff
path: root/src/uart.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/uart.h')
-rw-r--r--src/uart.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/uart.h b/src/uart.h
new file mode 100644
index 0000000..c709487
--- /dev/null
+++ b/src/uart.h
@@ -0,0 +1,36 @@
+/*
+ * src/uart.h
+ * (c) 2021 Jonas Gunz <himself@jonasgunz.de>
+ * License: All rights reserved.
+ */
+
+/*
+ * Interrupt controlled UART
+ */
+
+#ifndef _UART_H_
+#define _UART_H_
+
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <stdint.h>
+#include <string.h>
+
+#ifndef BAUD
+#warning BAUD "BAUD not defined. Dafaulting to 9600"
+#define BAUD 9600
+#endif
+
+#ifndef F_CPU
+#error "F_CPU not defined"
+#endif
+
+#define UBRR F_CPU/16/BAUD-1
+
+void uart_init();
+
+uint8_t uart_putchar(char _c);
+
+uint8_t uart_getchar(char *_c);
+
+#endif