summaryrefslogtreecommitdiffstats
path: root/stdio.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdio.c')
-rw-r--r--stdio.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/stdio.c b/stdio.c
new file mode 100644
index 0000000..c12a9ab
--- /dev/null
+++ b/stdio.c
@@ -0,0 +1,24 @@
+#include "project.h"
+
+static int
+stdio_uart_putchar (char var, FILE * stream)
+{
+
+ if (var == '\n')
+ uart_putc ('\r');
+ uart_putc (var);
+ return 0;
+}
+
+
+static FILE stdio_uart_stdout =
+FDEV_SETUP_STREAM (stdio_uart_putchar, NULL, _FDEV_SETUP_WRITE);
+
+void
+stdio_init (void)
+{
+ stdout = &stdio_uart_stdout;
+
+ uart_init (UART_BAUD_SELECT (UART_BAUD_RATE, F_CPU));
+ sei ();
+}