Switch from GPLv2 to GPLv2+
[fw/altos] / src / kernel / ao_serial.h
1 /*
2  * Copyright © 2012 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #ifndef _AO_SERIAL_H_
20 #define _AO_SERIAL_H_
21
22 #define AO_SERIAL_SPEED_4800    0
23 #define AO_SERIAL_SPEED_9600    1
24 #define AO_SERIAL_SPEED_19200   2
25 #define AO_SERIAL_SPEED_57600   3
26 #define AO_SERIAL_SPEED_115200  4
27
28 #if HAS_SERIAL_0
29 extern volatile __xdata struct ao_fifo  ao_serial0_rx_fifo;
30 extern volatile __xdata struct ao_fifo  ao_serial0_tx_fifo;
31
32 char
33 ao_serial0_getchar(void);
34
35 int
36 _ao_serial0_pollchar(void);
37
38 uint8_t
39 _ao_serial0_sleep_for(uint16_t timeout);
40
41 void
42 ao_serial0_putchar(char c);
43
44 void
45 ao_serial0_drain(void);
46
47 void
48 ao_serial0_set_speed(uint8_t speed);
49 #endif
50
51 #if HAS_SERIAL_1
52 extern volatile __xdata struct ao_fifo  ao_serial1_rx_fifo;
53 extern volatile __xdata struct ao_fifo  ao_serial1_tx_fifo;
54
55 char
56 ao_serial1_getchar(void);
57
58 int
59 _ao_serial1_pollchar(void);
60
61 uint8_t
62 _ao_serial1_sleep_for(uint16_t timeout);
63
64 void
65 ao_serial1_putchar(char c);
66
67 void
68 ao_serial1_drain(void);
69
70 void
71 ao_serial1_set_speed(uint8_t speed);
72 #endif
73
74 #if HAS_SERIAL_2
75 extern volatile __xdata struct ao_fifo  ao_serial2_rx_fifo;
76 extern volatile __xdata struct ao_fifo  ao_serial2_tx_fifo;
77
78 char
79 ao_serial2_getchar(void);
80
81 int
82 _ao_serial2_pollchar(void);
83
84 uint8_t
85 _ao_serial2_sleep_for(uint16_t timeout);
86
87 void
88 ao_serial2_putchar(char c);
89
90 void
91 ao_serial2_drain(void);
92
93 void
94 ao_serial2_set_speed(uint8_t speed);
95 #endif
96
97 #if HAS_SERIAL_3
98 extern volatile __xdata struct ao_fifo  ao_serial3_rx_fifo;
99 extern volatile __xdata struct ao_fifo  ao_serial3_tx_fifo;
100
101 char
102 ao_serial3_getchar(void);
103
104 int
105 _ao_serial3_pollchar(void);
106
107 uint8_t
108 _ao_serial3_sleep_for(uint16_t timeout);
109
110 void
111 ao_serial3_putchar(char c);
112
113 void
114 ao_serial3_drain(void);
115
116 void
117 ao_serial3_set_speed(uint8_t speed);
118 #endif
119
120 void
121 ao_serial_init(void);
122
123 #endif /* _AO_SERIAL_H_ */