aboutsummaryrefslogtreecommitdiff
path: root/uart.h
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.h
Diffstat (limited to 'uart.h')
-rw-r--r--uart.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/uart.h b/uart.h
new file mode 100644
index 0000000..d50ceb8
--- /dev/null
+++ b/uart.h
@@ -0,0 +1,39 @@
+#ifndef _H_UART
+#define _H_UART
+
+#include "uart_config.h"
+
+#ifdef UART_EUSART1
+ #define TXSTA TX1STA
+ #define RCSTA RC1STA
+ #define BAUDCON BAUD1CON
+ #define SPBRGH SP1BRGH
+ #define SPBRGL SP1BRGL
+ #define TXREG TX1REG
+# ifdef P16F1778
+ #define TXIF PIR1bits.TXIF
+# else
+ #define TXIF PIR3bits.TX1IF
+# endif
+#else
+#ifdef UART_EUSART2
+ #define TXSTA TX2STA
+ #define RCSTA RCRXTA
+ #define BAUDCON BAUD2CON
+ #define SPBRGH SP2BRGH
+ #define SPBRGL SP2BRGL
+ #define TXREG TX2REG
+# ifdef P16F1778
+ #define TXIF PIR1bits.TXIF
+# else
+ #define TXIF PIR3bits.TX2IF
+# endif
+#else
+ #error Define either UART_EUSART1 or UART_EUSART2
+#endif
+#endif
+
+void uart_init(void);
+void uart_putch(unsigned char data);
+
+#endif