comparison nuc-fw/serial/serialswitch.h @ 116:22c8199e08af

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