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