aboutsummaryrefslogtreecommitdiff
path: root/uart.c
diff options
context:
space:
mode:
authorCamil Staps2017-01-31 23:15:28 +0100
committerCamil Staps2017-01-31 23:15:28 +0100
commit631204a1feffa8cf3795060370b14dfb9f53f533 (patch)
tree001d32e0157127607f7c088881f098c2eca841a1 /uart.c
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;
+}