Imported Upstream version 2.9.0
[debian/cc1111] / device / include / pic16 / usart.h
1
2 /*
3  * USART communications module library header
4  *
5  * written for SDCC/pic16 port by Vangelis Rokas, 2005 <vrokas AT otenet.gr>
6  *
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.
11  *
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.
16  *
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.
20  *
21  *
22  * $Id: usart.h 3785 2005-06-24 14:19:36Z tecodev $
23  */
24
25 #ifndef __USART_H__
26 #define __USART_H__
27
28 #pragma library io
29
30
31 #define RAM_SCLS        __data
32
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
48
49 /* status bits */
50 union USART
51 {
52   unsigned char val;
53   struct
54   {
55     unsigned RX_NINE:1;
56     unsigned TX_NINE:1;
57     unsigned FRAME_ERROR:1;
58     unsigned OVERRUN_ERROR:1;
59     unsigned fill:4;
60   };
61 };
62
63 void usart_open(unsigned char config, unsigned int spbrg) __wparam;
64 void usart_close(void);
65
66 unsigned char usart_busy(void) __naked;
67 unsigned char usart_drdy(void) __naked;
68
69 unsigned char usart_getc(void);
70 void usart_gets(RAM_SCLS char *buffer, unsigned char len);
71
72 void usart_putc(unsigned char data) __wparam __naked;
73 void usart_puts(char *data);
74
75
76 void usart_baud(unsigned char baudconfig) __wparam;
77
78 #endif