samd21: Get serial driver building
[fw/altos] / src / samd21 / 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 struct ao_samd21_usart   ao_samd21_usart0;
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 struct ao_samd21_usart   ao_samd21_usart1;
52
53 char
54 ao_serial1_getchar(void);
55
56 int
57 _ao_serial1_pollchar(void);
58
59 uint8_t
60 _ao_serial1_sleep_for(uint16_t timeout);
61
62 void
63 ao_serial1_putchar(char c);
64
65 void
66 ao_serial1_drain(void);
67
68 void
69 ao_serial1_set_speed(uint8_t speed);
70 #endif
71
72 #if HAS_SERIAL_2
73 extern struct ao_samd21_usart   ao_samd21_usart2;
74
75 char
76 ao_serial2_getchar(void);
77
78 int
79 _ao_serial2_pollchar(void);
80
81 uint8_t
82 _ao_serial2_sleep_for(uint16_t timeout);
83
84 void
85 ao_serial2_putchar(char c);
86
87 void
88 ao_serial2_drain(void);
89
90 void
91 ao_serial2_set_speed(uint8_t speed);
92 #endif
93
94 #if HAS_SERIAL_3
95 extern struct ao_samd21_usart   ao_samd21_usart3;
96
97 char
98 ao_serial3_getchar(void);
99
100 int
101 _ao_serial3_pollchar(void);
102
103 uint8_t
104 _ao_serial3_sleep_for(uint16_t timeout);
105
106 void
107 ao_serial3_putchar(char c);
108
109 void
110 ao_serial3_drain(void);
111
112 void
113 ao_serial3_set_speed(uint8_t speed);
114 #endif
115
116 #if HAS_SERIAL_4
117 extern struct ao_samd21_usart   ao_samd21_usart4;
118
119 char
120 ao_serial4_getchar(void);
121
122 int
123 _ao_serial4_pollchar(void);
124
125 uint8_t
126 _ao_serial4_sleep_for(uint16_t timeout);
127
128 void
129 ao_serial4_putchar(char c);
130
131 void
132 ao_serial4_drain(void);
133
134 void
135 ao_serial4_set_speed(uint8_t speed);
136 #endif
137
138 #if HAS_SERIAL_5
139 extern struct ao_samd21_usart   ao_samd21_usart5;
140
141 char
142 ao_serial5_getchar(void);
143
144 int
145 _ao_serial5_pollchar(void);
146
147 uint8_t
148 _ao_serial5_sleep_for(uint16_t timeout);
149
150 void
151 ao_serial5_putchar(char c);
152
153 void
154 ao_serial5_drain(void);
155
156 void
157 ao_serial5_set_speed(uint8_t speed);
158 #endif
159
160 void
161 ao_serial_init(void);
162
163 #endif /* _AO_SERIAL_H_ */