aboutsummaryrefslogtreecommitdiff
path: root/uart.c
blob: 49aea48898ebd79375271f762d9db279d8b4cc12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
}