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