comparison src/cs/drivers/drv_app/uart/serialswitch.h @ 0:4e78acac3d88

src/{condat,cs,gpf,nucleus}: import from Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:23:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
1 /*******************************************************************************
2 *
3 * SERIALSWITCH.H
4 *
5 * This module allows managing the use of the serial ports of TI GSM Evaluation
6 * Boards.
7 * An application may have to send several serial data flows. The board on which
8 * the application is running may have one or several devices. The purpose of
9 * this module is to establish connections between the serial data flows and the
10 * serial devices at runtime, when the application is started.
11 *
12 * (C) Texas Instruments 1999 - 2003
13 *
14 ******************************************************************************/
15
16 #ifndef __SERIALSWITCH_H__
17 #define __SERIALSWITCH_H__
18
19 #ifndef _WINDOWS
20 #include "l1sw.cfg"
21 #include "swconfig.cfg"
22 #if (!OP_L1_STANDALONE)
23 #include "rv.cfg"
24 #endif
25 #include "chipset.cfg"
26 #endif
27
28 #ifndef __MONITOR__
29 #include "main/sys_types.h"
30 #include "uart/traceswitch.h"
31 #include "faxdata.h"
32 #endif /* __MONITOR__ */
33
34 #ifdef BTEMOBILE
35 #include "hci_ser.h"
36 #endif
37
38 #ifndef C_EXTERN
39 #if (OP_L1_STANDALONE)
40 #define C_EXTERN extern
41 #else
42 #define C_EXTERN
43 #endif
44 #endif
45
46 /*
47 * Constants used to identify the serial data flows.
48 */
49
50 #define SER_FLOW_1 (0)
51 #define SER_FLOW_2 (1)
52 #define SER_FLOW_3 (2)
53 #define SER_FLOW_4 (3)
54
55 #define SER_PROTOCOL_STACK (SER_FLOW_1)
56 #define SER_LAYER_1 (SER_FLOW_2)
57 #define SER_FAX_DATA (SER_FLOW_3)
58 #define SER_BLUETOOTH_HCI (SER_FLOW_4)
59
60 #define SER_HWTEST (SER_FLOW_1)
61 #define SER_SERIAL_TEST_1 (SER_FLOW_3)
62
63
64 #define SER_MAX_NUMBER_OF_FLOWS (4)
65
66 #define SER_MAX_NUMBER_OF_CFG (16)
67
68 /*
69 * Type used to define the various drivers configuration
70 * available, according to the UART devices.
71 */
72
73 typedef enum {
74 /* Trace Flow */
75 DUMMY_TRACE, /* = 0 */
76 UART_IRDA_TRACE, /* = 1 */
77 UART_MODEM_TRACE, /* = 2 */
78 #if (CHIPSET == 12)
79 UART_MODEM2_TRACE, /* = 3 */
80 #endif
81 /* AT-Commands/Fax & Data Flow */
82 DUMMY_FAX_DATA = 4, /* = 4 */
83 /* UART IrDA F&D Driver, not supported - should be = 5 */
84 UART_MODEM_FAX_DATA = 6, /* = 6 */
85 #if (CHIPSET == 12)
86 /* UART Modem2 F&D Driver, not supported - should be = 7 */
87 #endif
88 /* Bluetooth HCI Flow */
89 DUMMY_BT_HCI = 8, /* = 8 */
90 UART_IRDA_BT_HCI, /* = 9 */
91 UART_MODEM_BT_HCI /* = A */
92 #if (CHIPSET == 12)
93 , UART_MODEM2_BT_HCI /* = B */
94 #endif
95 } T_SerialDriver;
96
97 /*
98 * Type used to describe a defined serial configuration;
99 * Each field is a 4 bits field representing one serial flow.
100 *
101 * T_DefinedSerialConfig : [ flow_1 | flow_2 | flow_3 | flow_4 ]
102 * 15 12 11 8 7 4 3 0
103 */
104
105 typedef struct {
106
107 unsigned int flow_4 :4;
108 unsigned int flow_3 :4;
109 unsigned int flow_2 :4;
110 unsigned int flow_1 :4;
111
112 } T_DefinedSerialConfig;
113
114
115 /*
116 * Type used to describe all serial configuration informations
117 * of a defined application:
118 * - the default configuration to set up, if the current one is
119 * not valid,
120 * - the number of allowed serial configurations,
121 * - the entire allowed serial configurations.
122 */
123
124 typedef struct {
125
126 T_DefinedSerialConfig default_config;
127 SYS_UWORD8 num_config;
128 T_DefinedSerialConfig allowed_config[SER_MAX_NUMBER_OF_CFG];
129
130 } T_AppliSerialInfo;
131
132
133 /*
134 * Functions prototypes.
135 */
136
137 #ifndef __MONITOR__
138
139 #if (DP==1)
140 void SER_InitSerialConfig (int application_id);
141 #else
142 C_EXTERN void SER_InitSerialConfig (T_AppliSerialInfo *serial_info);
143 #endif //DP
144
145 C_EXTERN SYS_BOOL SER_UartSleepStatus (void);
146
147 C_EXTERN void SER_WakeUpUarts (void);
148
149 void SER_restart_uart_sleep_timer (void);
150
151 void SER_activate_timer_hisr (void);
152
153 #if (DP==1)
154 void SER_tr_Init (int serial_data_flow,
155 int baudrate,
156 void (callback_function (void)));
157 #else
158 C_EXTERN void SER_tr_Init (int serial_data_flow,
159 T_tr_Baudrate baudrate,
160 void (callback_function (void)));
161 #endif //DP
162
163 C_EXTERN SYS_UWORD32 SER_tr_ReadNChars (int serial_data_flow,
164 char *buffer,
165 SYS_UWORD32 chars_to_read);
166
167 C_EXTERN SYS_UWORD32 SER_tr_ReadNBytes (int serial_data_flow,
168 char *buffer,
169 SYS_UWORD32 chars_to_read,
170 SYS_BOOL *eof_detected);
171
172 C_EXTERN SYS_UWORD32 SER_tr_WriteNChars (int serial_data_flow,
173 char *buffer,
174 SYS_UWORD32 chars_to_write);
175
176 C_EXTERN SYS_UWORD32 SER_tr_EncapsulateNChars (int serial_data_flow,
177 char *buffer,
178 SYS_UWORD32 chars_to_write);
179
180 C_EXTERN SYS_UWORD32 SER_tr_WriteNBytes (int serial_data_flow,
181 SYS_UWORD8 *buffer,
182 SYS_UWORD32 chars_to_write);
183
184 C_EXTERN void SER_tr_WriteChar (int serial_data_flow,
185 char character);
186
187 C_EXTERN SYS_BOOL SER_tr_EnterSleep (int serial_data_flow);
188
189 C_EXTERN void SER_tr_WakeUp (int serial_data_flow);
190
191 C_EXTERN void SER_tr_WriteString (int serial_data_flow,
192 char *buffer);
193
194 #define T_UFRET T_FDRET
195
196 #define UF_DEVICE_0 (0)
197
198 #define UF_OK FD_OK
199 #define UF_SUSPENDED FD_SUSPENDED
200 #define UF_NOT_SUPPORTED FD_NOT_SUPPORTED
201 #define UF_NOT_READY FD_NOT_READY
202 #define UF_INTERNAL_ERROR FD_INTERNAL_ERR
203
204 #define UF_LINE_ON FD_LINE_ON
205 #define UF_LINE_OFF FD_LINE_OFF
206
207 #define UF_MAX_BUFFER_SIZE FD_MAX_BUFFER_SIZE
208
209 #define UF_BAUD_AUTO FD_BAUD_AUTO
210 #define UF_BAUD_75 FD_BAUD_75
211 #define UF_BAUD_150 FD_BAUD_150
212 #define UF_BAUD_300 FD_BAUD_300
213 #define UF_BAUD_600 FD_BAUD_600
214 #define UF_BAUD_1200 FD_BAUD_1200
215 #define UF_BAUD_2400 FD_BAUD_2400
216 #define UF_BAUD_4800 FD_BAUD_4800
217 #define UF_BAUD_7200 FD_BAUD_7200
218 #define UF_BAUD_9600 FD_BAUD_9600
219 #define UF_BAUD_14400 FD_BAUD_14400
220 #define UF_BAUD_19200 FD_BAUD_19200
221 #define UF_BAUD_28800 FD_BAUD_28800
222 #define UF_BAUD_33900 FD_BAUD_33900
223 #define UF_BAUD_38400 FD_BAUD_38400
224 #define UF_BAUD_57600 FD_BAUD_57600
225 #define UF_BAUD_115200 FD_BAUD_115200
226 #define UF_BAUD_203125 FD_BAUD_203125
227 #define UF_BAUD_406250 FD_BAUD_406250
228 #define UF_BAUD_812500 FD_BAUD_812500
229
230 C_EXTERN T_FDRET SER_fd_Init (void);
231
232 #if (DP==0)
233 C_EXTERN T_FDRET SER_fd_Initialize (void);
234 #endif
235
236 C_EXTERN T_FDRET SER_fd_Enable (SYS_BOOL enable);
237
238 C_EXTERN T_FDRET SER_fd_SetComPar (T_baudrate baudrate,
239 T_bitsPerCharacter bpc,
240 T_stopBits sb,
241 T_parity parity);
242
243 C_EXTERN T_FDRET SER_fd_SetBuffer (SYS_UWORD16 bufSize,
244 SYS_UWORD16 rxThreshold,
245 SYS_UWORD16 txThreshold);
246
247 C_EXTERN T_FDRET SER_fd_SetFlowCtrl (T_flowCtrlMode fcMode,
248 SYS_UWORD8 XON,
249 SYS_UWORD8 XOFF);
250
251 C_EXTERN T_FDRET SER_fd_SetEscape (char escChar,
252 SYS_UWORD16 guardPeriod);
253
254 C_EXTERN T_FDRET SER_fd_InpAvail (void);
255
256 C_EXTERN T_FDRET SER_fd_OutpAvail (void);
257
258 C_EXTERN T_FDRET SER_fd_EnterSleep (void);
259
260 C_EXTERN T_FDRET SER_fd_WakeUp (void);
261
262 C_EXTERN T_FDRET SER_fd_ReadData (T_suspendMode suspend,
263 void (readOutFunc (SYS_BOOL cldFromIrq,
264 T_reInstMode *reInstall,
265 SYS_UWORD8 nsource,
266 SYS_UWORD8 *source[],
267 SYS_UWORD16 size[],
268 SYS_UWORD32 state)));
269
270 C_EXTERN T_FDRET SER_fd_WriteData (T_suspendMode suspend,
271 void (writeInFunc (SYS_BOOL cldFromIrq,
272 T_reInstMode *reInstall,
273 SYS_UWORD8 ndest,
274 SYS_UWORD8 *dest[],
275 SYS_UWORD16 size[])));
276
277 C_EXTERN T_FDRET SER_fd_StopRec (void);
278
279 C_EXTERN T_FDRET SER_fd_StartRec (void);
280
281 C_EXTERN T_FDRET SER_fd_GetLineState (SYS_UWORD32 *state);
282
283 C_EXTERN T_FDRET SER_fd_SetLineState (SYS_UWORD32 state,
284 SYS_UWORD32 mask);
285
286 #if (DP==0)
287 C_EXTERN T_FDRET SER_fd_CheckXEmpty (void);
288 #endif
289
290 #ifdef BTEMOBILE
291 C_EXTERN T_HCI_RET SER_bt_Init (void);
292
293 C_EXTERN T_HCI_RET SER_bt_Start (void);
294
295 C_EXTERN T_HCI_RET SER_bt_Stop (void);
296
297 C_EXTERN T_HCI_RET SER_bt_Kill (void);
298
299 C_EXTERN T_HCI_RET SER_bt_SetBaudrate (UINT8 baudrate);
300
301 C_EXTERN T_HCI_RET SER_bt_TransmitPacket (void *uart_sco_tx_buffer);
302
303 C_EXTERN SYS_BOOL SER_bt_EnterSleep (void);
304
305 C_EXTERN void SER_bt_WakeUp (void);
306 #endif
307
308 #if ((CHIPSET == 2) || (CHIPSET == 3))
309 C_EXTERN void SER_uart_handler (void);
310 #elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12))
311 C_EXTERN void SER_uart_modem_handler (void);
312 C_EXTERN void SER_uart_irda_handler (void);
313 #endif
314 #if (CHIPSET == 12)
315 C_EXTERN void SER_uart_modem2_handler (void);
316 #endif
317
318 #if (DP==1)
319 T_FDRET UF_Init (int serial_data_flow);
320 T_FDRET UF_Enable (int serial_data_flow,
321 SYS_BOOL enable);
322 T_FDRET UF_SetComPar (int serial_data_flow,
323 T_baudrate baudrate,
324 T_bitsPerCharacter bpc,
325 T_stopBits sb,
326 T_parity parity);
327 T_FDRET UF_SetBuffer (int serial_data_flow,
328 SYS_UWORD16 bufSize,
329 SYS_UWORD16 rxThreshold,
330 SYS_UWORD16 txThreshold);
331 T_FDRET UF_SetFlowCtrl (int serial_data_flow,
332 T_flowCtrlMode fcMode,
333 SYS_UWORD8 XON,
334 SYS_UWORD8 XOFF);
335 T_FDRET UF_SetEscape (int serial_data_flow,
336 char escChar,
337 SYS_UWORD16 guardPeriod);
338 T_FDRET UF_InpAvail (int serial_data_flow);
339 T_FDRET UF_OutpAvail (int serial_data_flow);
340 T_FDRET UF_ReadData (int serial_data_flow,
341 T_suspendMode suspend,
342 void (readOutFunc (SYS_BOOL cldFromIrq,
343 T_reInstMode *reInstall,
344 SYS_UWORD8 nsource,
345 SYS_UWORD8 *source[],
346 SYS_UWORD16 size[],
347 SYS_UWORD32 state)));
348 T_FDRET UF_WriteData (int uartNo,
349 T_suspendMode suspend,
350 void (writeInFunc (SYS_BOOL cldFromIrq,
351 T_reInstMode *reInstall,
352 SYS_UWORD8 ndest,
353 SYS_UWORD8 *dest[],
354 SYS_UWORD16 size[])));
355 T_FDRET UF_StopRec (int serial_data_flow);
356 T_FDRET UF_StartRec (int serial_data_flow);
357 T_FDRET UF_GetLineState (int serial_data_flow,
358 SYS_UWORD32 *state);
359 T_FDRET UF_SetLineState (int serial_data_flow,
360 SYS_UWORD32 state,
361 SYS_UWORD32 mask);
362 T_FDRET UF_CheckXEmpty (int serial_data_flow);
363 T_FDRET UF_EnterSleep (int serial_data_flow);
364 T_FDRET UF_WakeUp (int serial_data_flow);
365 #endif //DP
366
367 /*
368 * Functions used for Dynamic Switch.
369 */
370
371 SYS_BOOL SER_WriteConfig (char *new_config,
372 SYS_BOOL write_to_flash);
373
374 SYS_BOOL SER_ImmediateSwitch (void);
375
376 /*
377 * Constants and macros used by Condat.
378 * Condat uses a serial device for the protocol stack trace.
379 */
380
381 #ifndef __SERIALSWITCH_C__
382
383 #define UT_DEVICE_0 (0)
384
385 #define UT_BAUD_406250 TR_BAUD_406250
386 #define UT_BAUD_115200 TR_BAUD_115200
387 #define UT_BAUD_57600 TR_BAUD_57600
388 #define UT_BAUD_38400 TR_BAUD_38400
389 #define UT_BAUD_33900 TR_BAUD_33900
390 #define UT_BAUD_28800 TR_BAUD_28800
391 #define UT_BAUD_19200 TR_BAUD_19200
392 #define UT_BAUD_14400 TR_BAUD_14400
393 #define UT_BAUD_9600 TR_BAUD_9600
394 #define UT_BAUD_4800 TR_BAUD_4800
395 #define UT_BAUD_2400 TR_BAUD_2400
396 #define UT_BAUD_1200 TR_BAUD_1200
397 #define UT_BAUD_600 TR_BAUD_600
398 #define UT_BAUD_300 TR_BAUD_300
399 #define UT_BAUD_150 TR_BAUD_150
400 #define UT_BAUD_75 TR_BAUD_75
401
402 #define UT_Init(A,B,C) SER_tr_Init (SER_PROTOCOL_STACK, B, C)
403
404 #define UT_ReadNChars(A,B,C) SER_tr_ReadNChars (SER_PROTOCOL_STACK, B, C)
405
406 #define UT_WriteNChars(A,B,C) SER_tr_WriteNChars (SER_PROTOCOL_STACK, B, C)
407
408 #define UT_WriteChar(A,B) SER_tr_WriteChar (SER_PROTOCOL_STACK, B)
409
410 #define UT_WriteString(A,B) SER_tr_WriteString (SER_PROTOCOL_STACK, B)
411
412 #if (DP==0)
413 #define UF_Init(A) SER_fd_Init ()
414
415 #define UF_Enable(A,B) SER_fd_Enable (B)
416
417 #define UF_SetComPar(A,B,C,D,E) SER_fd_SetComPar (B, C, D, E)
418
419 #define UF_SetBuffer(A,B,C,D) SER_fd_SetBuffer (B, C, D)
420
421 #define UF_SetFlowCtrl(A,B,C,D) SER_fd_SetFlowCtrl (B, C, D)
422
423 #define UF_SetEscape(A,B,C) SER_fd_SetEscape (B, C)
424
425 #define UF_InpAvail(A) SER_fd_InpAvail ()
426
427 #define UF_OutpAvail(A) SER_fd_OutpAvail ()
428
429 #define UF_ReadData(A,B,C) SER_fd_ReadData (B, C)
430
431 #define UF_WriteData(A,B,C) SER_fd_WriteData (B, C)
432
433 #define UF_StopRec(A) SER_fd_StopRec()
434
435 #define UF_StartRec(A) SER_fd_StartRec ()
436
437 #define UF_GetLineState(A,B) SER_fd_GetLineState (B)
438
439 #define UF_SetLineState(A,B,C) SER_fd_SetLineState (B, C)
440
441 #define UF_CheckXEmpty(A) SER_fd_CheckXEmpty ()
442 #endif //DP
443
444 #endif /* __SERIALSWITCH_C__ */
445
446 #endif /* __MONITOR__ */
447
448 #undef C_EXTERN
449
450 #endif /* __SERIALSWITCH_H__ */