FreeCalypso > hg > leo2moko-debug
comparison chipsetsw/drivers/drv_core/uart/uart.h @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /******************************************************************************* | |
2 * | |
3 * UART.H | |
4 * | |
5 * This module allows to use the UARTs of chipset 1.5 in interrupt mode. | |
6 * The driver calls a user's function when characters are received. | |
7 * | |
8 * (C) Texas Instruments 1999 - 2003 | |
9 * | |
10 ******************************************************************************/ | |
11 | |
12 #ifndef __UART_H__ | |
13 #define __UART_H__ | |
14 | |
15 #include "l1sw.cfg" | |
16 | |
17 #ifndef _WINDOWS | |
18 #include "chipset.cfg" | |
19 #endif | |
20 | |
21 #include "uart/traceswitch.h" | |
22 | |
23 #if (OP_L1_STANDALONE == 0) | |
24 #include "main/sys_types.h" | |
25 #else | |
26 #include "sys_types.h" | |
27 #endif | |
28 | |
29 | |
30 typedef enum { | |
31 UA_UART_0, /* IrDA */ | |
32 UA_UART_1 /* Modem */ | |
33 #if (CHIPSET == 12) | |
34 , UA_UART_2 /* Modem 2 */ | |
35 #endif | |
36 } T_tr_UartId; | |
37 | |
38 #if (CHIPSET == 12) | |
39 #define NUMBER_OF_TR_UART (3) | |
40 #else | |
41 #define NUMBER_OF_TR_UART (2) | |
42 #endif | |
43 | |
44 #ifndef C_EXTERN | |
45 #if (OP_L1_STANDALONE == 1) | |
46 #define C_EXTERN extern | |
47 #else | |
48 #define C_EXTERN | |
49 #endif | |
50 #endif | |
51 | |
52 /******************************************************************************* | |
53 * | |
54 * initialize_uart_sleep | |
55 * | |
56 * Purpose : Performs basic UART hardware initialization including sleep mode. | |
57 * | |
58 * Arguments: In : uart_id : UART id. | |
59 * Out: none | |
60 * | |
61 * Returns: none | |
62 * | |
63 * Warning: Parameters are not verified. | |
64 * | |
65 ******************************************************************************/ | |
66 | |
67 C_EXTERN void initialize_uart_sleep (T_tr_UartId uart_id); | |
68 | |
69 /******************************************************************************* | |
70 * | |
71 * UA_Init | |
72 * | |
73 * Purpose : Initializes the module and the UART. | |
74 * | |
75 * Arguments: In : uart_id : UART id. | |
76 * baudrate: baud rate selected. | |
77 * callback: user's function called characters are received. | |
78 * Out: none | |
79 * | |
80 * Returns: none | |
81 * | |
82 * Warning: Parameters are not verified. | |
83 * | |
84 ******************************************************************************/ | |
85 | |
86 C_EXTERN void UA_Init (T_tr_UartId uart_id, | |
87 T_tr_Baudrate baudrate, | |
88 void (callback_function (void))); | |
89 | |
90 /******************************************************************************* | |
91 * | |
92 * UA_ReadNChars | |
93 * | |
94 * Purpose : Reads N characters from the RX buffer. | |
95 * | |
96 * Arguments: In : uart_id : UART id. | |
97 * buffer : buffer address where the characters are | |
98 * copied. | |
99 * chars_to_read: number of characters to read. | |
100 * Out: none | |
101 * | |
102 * Returns : The number of characters read. | |
103 * | |
104 * Warning: Parameters are not verified. | |
105 * | |
106 ******************************************************************************/ | |
107 | |
108 C_EXTERN SYS_UWORD32 UA_ReadNChars (T_tr_UartId uart_id, | |
109 char *buffer, | |
110 SYS_UWORD32 chars_to_read); | |
111 | |
112 /******************************************************************************* | |
113 * | |
114 * UA_ReadNBytes | |
115 * | |
116 * Purpose : Reads and destuff N bytes from the RX buffer. | |
117 * | |
118 * Arguments: In : uart_id : UART id. | |
119 * buffer : buffer address where the bytes are copied. | |
120 * chars_to_read: number of bytes to read. | |
121 * Out: eof_detected : indicates if an EOF has been detected. | |
122 * | |
123 * Returns : The number of bytes read. | |
124 * | |
125 * Warning: Parameters are not verified. | |
126 * | |
127 ******************************************************************************/ | |
128 | |
129 C_EXTERN SYS_UWORD32 UA_ReadNBytes (T_tr_UartId uart_id, | |
130 char *buffer, | |
131 SYS_UWORD32 bytes_to_read, | |
132 SYS_BOOL *eof_detected); | |
133 | |
134 /******************************************************************************* | |
135 * | |
136 * UA_WriteNChars | |
137 * | |
138 * Purpose : Writes N characters in the TX FIFO. | |
139 * | |
140 * Arguments: In : uart_id : UART id. | |
141 * buffer : buffer address from which characters are | |
142 * written. | |
143 * bytes_to_write: number of bytes to write. | |
144 * Out: none | |
145 * | |
146 * Returns : Number of bytes written. | |
147 * | |
148 * Warning: Parameters are not verified. | |
149 * | |
150 ******************************************************************************/ | |
151 | |
152 C_EXTERN SYS_UWORD32 UA_WriteNChars (T_tr_UartId uart_id, | |
153 char *buffer, | |
154 SYS_UWORD32 chars_to_write); | |
155 | |
156 /******************************************************************************* | |
157 * | |
158 * UA_EncapsulateNChars | |
159 * | |
160 * Purpose : Writes N characters in the TX FIFO in encapsulating them with 2 | |
161 * STX bytes (one at the beginning and one at the end). | |
162 * | |
163 * Arguments: In : uart_id : UART id. | |
164 * buffer : buffer address from which characters are | |
165 * written. | |
166 * chars_to_write: number of chars to write. | |
167 * Out: none | |
168 * | |
169 * Returns : Number of chars written. | |
170 * | |
171 * Warning: Parameters are not verified. | |
172 * | |
173 ******************************************************************************/ | |
174 | |
175 C_EXTERN SYS_UWORD32 UA_EncapsulateNChars (T_tr_UartId uart_id, | |
176 char *buffer, | |
177 SYS_UWORD32 chars_to_write); | |
178 | |
179 /******************************************************************************* | |
180 * | |
181 * UA_WriteNBytes | |
182 * | |
183 * Purpose : Writes N bytes in the TX FIFO in encapsulating with 2 STX bytes | |
184 * at the beginning and the end of the frame, and in making byte | |
185 * stuffing. | |
186 * | |
187 * Arguments: In : uart_id : UART id. | |
188 * buffer : buffer address from which bytes are | |
189 * written. | |
190 * bytes_to_write: number of bytes to write. | |
191 * Out: none | |
192 * | |
193 * Returns : Number of bytes written. | |
194 * | |
195 * Warning: Parameters are not verified. | |
196 * | |
197 ******************************************************************************/ | |
198 | |
199 C_EXTERN SYS_UWORD32 UA_WriteNBytes (T_tr_UartId uart_id, | |
200 SYS_UWORD8 *buffer, | |
201 SYS_UWORD32 bytes_to_write); | |
202 | |
203 /******************************************************************************* | |
204 * | |
205 * UA_WriteChar | |
206 * | |
207 * Purpose : Writes a character in the TX FIFO. | |
208 * | |
209 * Arguments: In : uart: UART id. | |
210 * character | |
211 * Out: none | |
212 * | |
213 * Returns : none | |
214 * | |
215 * Warning: Parameters are not verified. | |
216 * | |
217 ******************************************************************************/ | |
218 | |
219 C_EXTERN void UA_WriteChar (T_tr_UartId uart_id, | |
220 char character); | |
221 | |
222 /******************************************************************************* | |
223 * | |
224 * UA_WriteString | |
225 * | |
226 * Purpose : Writes a null terminated string in the TX FIFO. | |
227 * | |
228 * Arguments: In : uart_id: UART id. | |
229 * buffer : buffer address from which characters are written. | |
230 * Out: none | |
231 * | |
232 * Returns : none | |
233 * | |
234 * Warning: Parameters are not verified. | |
235 * | |
236 ******************************************************************************/ | |
237 | |
238 C_EXTERN void UA_WriteString (T_tr_UartId uart_id, | |
239 char *buffer); | |
240 | |
241 /******************************************************************************* | |
242 * | |
243 * UA_EnterSleep | |
244 * | |
245 * Purpose : Checks if UART is ready to enter Deep Sleep. If ready, enables | |
246 * wake-up interrupt. | |
247 * | |
248 * Arguments: In : uart_id : UART id. | |
249 * Out: none | |
250 * | |
251 * Returns: 0 : Deep Sleep is not possible. | |
252 * >= 1 : Deep Sleep is possible. | |
253 * | |
254 * Warning: Parameters are not verified. | |
255 * | |
256 ******************************************************************************/ | |
257 | |
258 C_EXTERN SYS_BOOL UA_EnterSleep (T_tr_UartId uart_id); | |
259 | |
260 /******************************************************************************* | |
261 * | |
262 * UA_WakeUp | |
263 * | |
264 * Purpose : Wakes up UART after Deep Sleep. | |
265 * | |
266 * Arguments: In : uart_id : UART id. | |
267 * Out: none | |
268 * | |
269 * Returns: none | |
270 * | |
271 * Warning: Parameters are not verified. | |
272 * | |
273 ******************************************************************************/ | |
274 | |
275 C_EXTERN void UA_WakeUp (T_tr_UartId uart_id); | |
276 | |
277 /******************************************************************************* | |
278 * | |
279 * UA_InterruptHandler | |
280 * | |
281 * Purpose : Interrupt handler. | |
282 * | |
283 * Arguments: In : uart_id : origin of interrupt | |
284 * interrupt_status: source of interrupt | |
285 * Out: none | |
286 * | |
287 * Returns : none | |
288 * | |
289 ******************************************************************************/ | |
290 | |
291 void UA_InterruptHandler (T_tr_UartId uart_id, | |
292 SYS_UWORD8 interrupt_status); | |
293 | |
294 #undef C_EXTERN | |
295 | |
296 #endif /* __UART_H__ */ |