3 * USART communications module library header
5 * written for SDCC/pic16 port by Vangelis Rokas, 2005 <vrokas AT otenet.gr>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #define RAM_SCLS __data
33 /* configuration bit masks for open function */
34 #define USART_TX_INT_ON 0xff
35 #define USART_TX_INT_OFF 0x7f
36 #define USART_RX_INT_ON 0xff
37 #define USART_RX_INT_OFF 0xbf
38 #define USART_BRGH_HIGH 0xff
39 #define USART_BRGH_LOW 0xef
40 #define USART_CONT_RX 0xff
41 #define USART_SINGLE_RX 0xf7
42 #define USART_SYNC_MASTER 0xff
43 #define USART_SYNC_SLAVE 0xfb
44 #define USART_NINE_BIT 0xff
45 #define USART_EIGHT_BIT 0xfd
46 #define USART_SYNCH_MODE 0xff
47 #define USART_ASYNCH_MODE 0xfe
49 #if defined(__MULTIPLE_USARTS) && __MULTIPLE_USARTS > 0
50 /* added for USART compatibility with smaller devices */
55 #define RCSTAbits RCSTA1bits
56 #define TXSTAbits TXSTA1bits
59 /* and now for use in inline assembly */
60 #define _RCREG _RCREG1
61 #define _TXREG _TXREG1
62 #define _RCSTA _RCSTA1
63 #define _TXSTA _TXSTA1
64 #define _RCSTAbits _RCSTA1bits
65 #define _TXSTAbits _TXSTA1bits
66 #define _SPBRG _SPBRG1
77 unsigned FRAME_ERROR:1;
78 unsigned OVERRUN_ERROR:1;
83 void usart_open(unsigned char config, unsigned int spbrg) __wparam;
84 void usart_close(void);
86 unsigned char usart_busy(void) __naked;
87 unsigned char usart_drdy(void) __naked;
89 unsigned char usart_getc(void);
90 void usart_gets(RAM_SCLS char *buffer, unsigned char len);
92 void usart_putc(unsigned char data) __wparam __naked;
93 void usart_puts(char *data);
96 void usart_baud(unsigned char baudconfig) __wparam;