comparison gsm-fw/serial/uart.h @ 143:afceeeb2cba1

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