From 631204a1feffa8cf3795060370b14dfb9f53f533 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 31 Jan 2017 23:15:28 +0100 Subject: WIP --- uart.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 uart.c (limited to 'uart.c') 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 + +#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; +} -- cgit v1.2.3