aboutsummaryrefslogtreecommitdiff
path: root/uart.c
diff options
context:
space:
mode:
Diffstat (limited to 'uart.c')
-rw-r--r--uart.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/uart.c b/uart.c
new file mode 100644
index 0000000..49aea48
--- /dev/null
+++ b/uart.c
@@ -0,0 +1,21 @@
+#include <xc.h>
+
+#include "uart.h"
+
+void uart_init(void) {
+ BAUDCON = 0x08;
+ SPBRGH = 0;
+#ifdef P18F27K40
+ SPBRGL = 138;
+#endif
+#ifdef P16F1778
+ SPBRGL = 68;
+#endif
+ TXSTA = 0x24;
+ RCSTA = 0x90;
+}
+
+void uart_putch(unsigned char data) {
+ while (!TXIF) continue;
+ TXREG = data;
+}