FreeCalypso > hg > fc-selenite
comparison src/cs/drivers/drv_app/uart/serialswitch.c @ 0:b6a5e36de839
src/cs: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:39:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:b6a5e36de839 |
---|---|
1 /******************************************************************************* | |
2 * | |
3 * SERIALSWITCH.C | |
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 #define __SERIALSWITCH_C__ | |
17 | |
18 #define __STANDARD_H__ /* Avoid to define UBYTE, SYS_UWORD16 and UINT32. */ | |
19 | |
20 #include "main/sys_types.h" | |
21 #include "nucleus.h" | |
22 | |
23 #include "traceswitch.h" | |
24 #include "faxdata.h" | |
25 #include "serialswitch.h" | |
26 | |
27 #include "uart/uart.h" | |
28 #include "uartfax.h" | |
29 | |
30 #include "memif/mem.h" | |
31 | |
32 #include "l1sw.cfg" | |
33 #if (!OP_L1_STANDALONE) | |
34 #include "rv.cfg" | |
35 #endif | |
36 #include "chipset.cfg" | |
37 #include "swconfig.cfg" | |
38 #ifdef BLUETOOTH_INCLUDED | |
39 #include "btemobile.cfg" | |
40 #endif | |
41 | |
42 #include <string.h> /* needed for memcmp & memset */ | |
43 | |
44 #ifdef SERIAL_DYNAMIC_SWITCH | |
45 #include "ffs/ffs.h" | |
46 #include "rvf/rvf_api.h" | |
47 #include "inth/iq.h" | |
48 #include "rvt/rvt_def_i.h" /* needed for Riviera/Layer1 Trace's callback function */ | |
49 #endif | |
50 | |
51 #if defined(BTEMOBILE) | |
52 #include "hci_ser.h" | |
53 #endif | |
54 | |
55 #define DUMMY_DEVICE (0) | |
56 | |
57 #define IIR (0x02) /* UART interrupt ident. register - Read only */ | |
58 #define SCR (0x10) /* UART suppl. control register - Read/Write */ | |
59 #define SSR (0x11) /* UART suppl. status register - Read only */ | |
60 | |
61 /* | |
62 * Interrupt identification register. | |
63 * Bit 0 is set to 0 if an IT is pending. | |
64 * Bits 1 and 2 are used to identify the IT. | |
65 */ | |
66 | |
67 #define IIR_BITS_USED (0x07) | |
68 #define IT_NOT_PENDING (0x01) | |
69 | |
70 /* | |
71 * Supplementary Control Register | |
72 */ | |
73 | |
74 #define RX_CTS_WAKE_UP_ENABLE_BIT (4) | |
75 | |
76 /* | |
77 * Supplementary Status Register | |
78 */ | |
79 | |
80 #define RX_CTS_WAKE_UP_STS (0x02) /* Wake-up interrupt occurred */ | |
81 | |
82 /* | |
83 * This macro allows to read an UART register. | |
84 */ | |
85 | |
86 #define READ_UART_REGISTER(UART,REG) \ | |
87 *((volatile SYS_UWORD8 *) ((UART)->base_address + (REG))) | |
88 | |
89 | |
90 /* | |
91 * This macro allows to disable the UART's wake-up interrupt. | |
92 */ | |
93 | |
94 #define DISABLE_WAKE_UP_INTERRUPT(UART) \ | |
95 *((volatile SYS_UWORD8 *) ((UART)->base_address + SCR)) &= \ | |
96 ~(1 << (RX_CTS_WAKE_UP_ENABLE_BIT)); | |
97 | |
98 /* | |
99 * Wake-up time duration in seconds and in number of TDMAs. | |
100 * 1 TDMA = (6 / 1300) s = 0.004615 s (= 4.615 ms). | |
101 */ | |
102 | |
103 #define WAKE_UP_TIME_DURATION (10) /* 10 seconds */ | |
104 #define WAKE_UP_TIME_IN_TDMA (WAKE_UP_TIME_DURATION * 1300 / 6) | |
105 | |
106 | |
107 /* | |
108 * Global uartswitch variable as read from FFS. | |
109 * It is supposed that NUMBER_OF_TR_UART, NUMBER_OF_FD_UART | |
110 * and NUMBER_OF_BT_UART have the same values. | |
111 */ | |
112 | |
113 #define DUMMY ('0') | |
114 #define G23_PANEL ('G') | |
115 #define RIVIERA_TRACE_MUX ('R') | |
116 #define FD_AT_COMMAND ('D') | |
117 #define BLUETOOTH_HCI ('B') | |
118 | |
119 #if (CHIPSET == 12) | |
120 char ser_cfg_info[NUMBER_OF_TR_UART] = {DUMMY, DUMMY, DUMMY}; | |
121 #else | |
122 char ser_cfg_info[NUMBER_OF_TR_UART] = {DUMMY, DUMMY}; | |
123 #endif | |
124 static SYS_UWORD16 serial_cfg = 0x0048; /* All dummies */ | |
125 | |
126 #ifdef SERIAL_DYNAMIC_SWITCH | |
127 /* | |
128 * Global variables used for Dynamic Switch. | |
129 */ | |
130 | |
131 static char ser_new_cfg[NUMBER_OF_TR_UART] = {DUMMY, DUMMY}; | |
132 const static char uart_config_file[] = "/sys/uartswitch"; | |
133 static SYS_BOOL dynamic_switch = 0; | |
134 | |
135 /* Import Serial Info structure. */ | |
136 extern T_AppliSerialInfo appli_ser_cfg_info; | |
137 #endif | |
138 | |
139 /* | |
140 * Types of flows supported. | |
141 */ | |
142 | |
143 typedef enum { | |
144 TRACE_FLOW, | |
145 FAX_DATA_FLOW, | |
146 BLUETOOTH_HCI_FLOW | |
147 } t_flow_type; | |
148 | |
149 /* | |
150 * For each serial data flow, a set of function pointers allows calling the | |
151 * functions associated to a serial device. | |
152 */ | |
153 | |
154 typedef struct s_tr_functions { | |
155 | |
156 T_tr_UartId device; | |
157 | |
158 void (*tr_Init) (T_tr_UartId device, | |
159 T_tr_Baudrate baudrate, | |
160 void (callback_function (void))); | |
161 | |
162 SYS_UWORD32 (*tr_ReadNChars) (T_tr_UartId device, | |
163 char *buffer, | |
164 SYS_UWORD32 chars_to_read); | |
165 | |
166 SYS_UWORD32 (*tr_ReadNBytes) (T_tr_UartId device, | |
167 char *buffer, | |
168 SYS_UWORD32 chars_to_read, | |
169 SYS_BOOL *eof_detected); | |
170 | |
171 SYS_UWORD32 (*tr_WriteNChars) (T_tr_UartId device, | |
172 char *buffer, | |
173 SYS_UWORD32 chars_to_write); | |
174 | |
175 SYS_UWORD32 (*tr_EncapsulateNChars) (T_tr_UartId device, | |
176 char *buffer, | |
177 SYS_UWORD32 chars_to_write); | |
178 | |
179 SYS_UWORD32 (*tr_WriteNBytes) (T_tr_UartId device, | |
180 SYS_UWORD8 *buffer, | |
181 SYS_UWORD32 chars_to_write); | |
182 | |
183 void (*tr_WriteChar) (T_tr_UartId device, | |
184 char character); | |
185 | |
186 void (*tr_WriteString) (T_tr_UartId device, | |
187 char *buffer); | |
188 | |
189 SYS_BOOL (*tr_EnterSleep) (T_tr_UartId device); | |
190 | |
191 void (*tr_WakeUp) (T_tr_UartId device); | |
192 | |
193 } t_tr_functions; | |
194 | |
195 /* | |
196 * Set of function pointers for fax & data functions. | |
197 */ | |
198 | |
199 typedef struct s_fd_functions { | |
200 | |
201 T_fd_UartId device; | |
202 | |
203 T_FDRET (*fd_Initialize) (T_fd_UartId device); | |
204 | |
205 T_FDRET (*fd_Enable) (T_fd_UartId device, | |
206 SYS_BOOL enable); | |
207 | |
208 T_FDRET (*fd_SetComPar) (T_fd_UartId device, | |
209 T_baudrate baudrate, | |
210 T_bitsPerCharacter bpc, | |
211 T_stopBits sb, | |
212 T_parity parity); | |
213 | |
214 T_FDRET (*fd_SetBuffer) (T_fd_UartId device, | |
215 SYS_UWORD16 bufSize, | |
216 SYS_UWORD16 rxThreshold, | |
217 SYS_UWORD16 txThreshold); | |
218 | |
219 T_FDRET (*fd_SetFlowCtrl) (T_fd_UartId device, | |
220 T_flowCtrlMode fcMode, | |
221 SYS_UWORD8 XON, | |
222 SYS_UWORD8 XOFF); | |
223 | |
224 T_FDRET (*fd_SetEscape) (T_fd_UartId device, | |
225 SYS_UWORD8 escChar, | |
226 SYS_UWORD16 guardPeriod); | |
227 | |
228 T_FDRET (*fd_InpAvail) (T_fd_UartId device); | |
229 | |
230 T_FDRET (*fd_OutpAvail) (T_fd_UartId device); | |
231 | |
232 T_FDRET (*fd_EnterSleep) (T_fd_UartId device); | |
233 | |
234 T_FDRET (*fd_WakeUp) (T_fd_UartId device); | |
235 | |
236 T_FDRET (*fd_ReadData) (T_fd_UartId device, | |
237 T_suspendMode suspend, | |
238 void (readOutFunc (SYS_BOOL cldFromIrq, | |
239 T_reInstMode *reInstall, | |
240 SYS_UWORD8 nsource, | |
241 SYS_UWORD8 *source[], | |
242 SYS_UWORD16 size[], | |
243 SYS_UWORD32 state))); | |
244 | |
245 T_FDRET (*fd_WriteData) (T_fd_UartId device, | |
246 T_suspendMode suspend, | |
247 void (writeInFunc (SYS_BOOL cldFromIrq, | |
248 T_reInstMode *reInstall, | |
249 SYS_UWORD8 ndest, | |
250 SYS_UWORD8 *dest[], | |
251 SYS_UWORD16 size[]))); | |
252 | |
253 T_FDRET (*fd_StopRec) (T_fd_UartId device); | |
254 | |
255 T_FDRET (*fd_StartRec) (T_fd_UartId device); | |
256 | |
257 T_FDRET (*fd_GetLineState) (T_fd_UartId device, | |
258 SYS_UWORD32 *state); | |
259 | |
260 T_FDRET (*fd_SetLineState) (T_fd_UartId device, | |
261 SYS_UWORD32 state, | |
262 SYS_UWORD32 mask); | |
263 | |
264 T_FDRET (*fd_CheckXEmpty) (T_fd_UartId device); | |
265 | |
266 } t_fd_functions; | |
267 | |
268 #ifdef BTEMOBILE | |
269 /* | |
270 * Set of function pointers for Bluetooth HCI functions. | |
271 */ | |
272 | |
273 typedef struct s_bt_functions { | |
274 | |
275 T_bt_UartId device; | |
276 | |
277 T_HCI_RET (*bt_Init) (T_bt_UartId uart_device); | |
278 | |
279 T_HCI_RET (*bt_Start) (void); | |
280 | |
281 T_HCI_RET (*bt_Stop) (void); | |
282 | |
283 T_HCI_RET (*bt_Kill) (void); | |
284 | |
285 T_HCI_RET (*bt_SetBaudrate) (UINT8 baudrate); | |
286 | |
287 T_HCI_RET (*bt_TransmitPacket) (void *uart_tx_buffer); | |
288 | |
289 SYS_BOOL (*bt_EnterSleep) (void); | |
290 | |
291 void (*bt_WakeUp) (void); | |
292 | |
293 } t_bt_functions; | |
294 #endif | |
295 | |
296 /* | |
297 * Prototypes of dummy functions. | |
298 * Dummy functions for Trace. | |
299 */ | |
300 | |
301 static void dummy_tr_Init (T_tr_UartId device, | |
302 T_tr_Baudrate baudrate, | |
303 void (callback_function (void))); | |
304 | |
305 static SYS_UWORD32 dummy_tr_ReadNChars (T_tr_UartId device, | |
306 char *buffer, | |
307 SYS_UWORD32 chars_to_read); | |
308 | |
309 static SYS_UWORD32 dummy_tr_ReadNBytes (T_tr_UartId device, | |
310 char *buffer, | |
311 SYS_UWORD32 chars_to_read, | |
312 SYS_BOOL *eof_detected); | |
313 | |
314 static SYS_UWORD32 dummy_tr_WriteNChars (T_tr_UartId device, | |
315 char *buffer, | |
316 SYS_UWORD32 chars_to_write); | |
317 | |
318 static SYS_UWORD32 dummy_tr_EncapsulateNChars (T_tr_UartId device, | |
319 char *buffer, | |
320 SYS_UWORD32 chars_to_write); | |
321 | |
322 static SYS_UWORD32 dummy_tr_WriteNBytes (T_tr_UartId device, | |
323 SYS_UWORD8 *buffer, | |
324 SYS_UWORD32 chars_to_write); | |
325 | |
326 static void dummy_tr_WriteChar (T_tr_UartId device, | |
327 char character); | |
328 | |
329 static void dummy_tr_WriteString (T_tr_UartId device, | |
330 char *buffer); | |
331 | |
332 static SYS_BOOL dummy_tr_EnterSleep (T_tr_UartId device); | |
333 | |
334 static void dummy_tr_WakeUp (T_tr_UartId device); | |
335 | |
336 /* | |
337 * Dummy functions for Fax & Data. | |
338 */ | |
339 | |
340 static T_FDRET dummy_fd_Init (T_fd_UartId device); | |
341 | |
342 static T_FDRET dummy_fd_Enable (T_fd_UartId device, | |
343 SYS_BOOL enable); | |
344 | |
345 static T_FDRET dummy_fd_SetComPar (T_fd_UartId device, | |
346 T_baudrate baudrate, | |
347 T_bitsPerCharacter bpc, | |
348 T_stopBits sb, | |
349 T_parity parity); | |
350 | |
351 static T_FDRET dummy_fd_SetBuffer (T_fd_UartId device, | |
352 SYS_UWORD16 bufSize, | |
353 SYS_UWORD16 rxThreshold, | |
354 SYS_UWORD16 txThreshold); | |
355 | |
356 static T_FDRET dummy_fd_SetFlowCtrl (T_fd_UartId device, | |
357 T_flowCtrlMode fcMode, | |
358 SYS_UWORD8 XON, | |
359 SYS_UWORD8 XOFF); | |
360 | |
361 static T_FDRET dummy_fd_SetEscape (T_fd_UartId device, | |
362 SYS_UWORD8 escChar, | |
363 SYS_UWORD16 guardPeriod); | |
364 | |
365 static T_FDRET dummy_fd_InpAvail (T_fd_UartId device); | |
366 | |
367 static T_FDRET dummy_fd_OutpAvail (T_fd_UartId device); | |
368 | |
369 static T_FDRET dummy_fd_EnterSleep (T_fd_UartId device); | |
370 | |
371 static T_FDRET dummy_fd_WakeUp (T_fd_UartId device); | |
372 | |
373 static T_FDRET dummy_fd_ReadData (T_fd_UartId device, | |
374 T_suspendMode suspend, | |
375 void (readOutFunc (SYS_BOOL cldFromIrq, | |
376 T_reInstMode *reInstall, | |
377 SYS_UWORD8 nsource, | |
378 SYS_UWORD8 *source[], | |
379 SYS_UWORD16 size[], | |
380 SYS_UWORD32 state))); | |
381 | |
382 static T_FDRET dummy_fd_WriteData (T_fd_UartId device, | |
383 T_suspendMode suspend, | |
384 void (writeInFunc (SYS_BOOL cldFromIrq, | |
385 T_reInstMode *reInstall, | |
386 SYS_UWORD8 ndest, | |
387 SYS_UWORD8 *dest[], | |
388 SYS_UWORD16 size[]))); | |
389 | |
390 static T_FDRET dummy_fd_StopRec (T_fd_UartId device); | |
391 | |
392 static T_FDRET dummy_fd_StartRec (T_fd_UartId device); | |
393 | |
394 static T_FDRET dummy_fd_GetLineState (T_fd_UartId device, | |
395 SYS_UWORD32 *state); | |
396 | |
397 static T_FDRET dummy_fd_SetLineState (T_fd_UartId device, | |
398 SYS_UWORD32 state, | |
399 SYS_UWORD32 mask); | |
400 | |
401 static T_FDRET dummy_fd_CheckXEmpty (T_fd_UartId device); | |
402 | |
403 #ifdef BTEMOBILE | |
404 /* | |
405 * Dummy functions for Bluetooth HCI. | |
406 */ | |
407 | |
408 static T_HCI_RET dummy_bt_Init (T_bt_UartId uart_device); | |
409 | |
410 static T_HCI_RET dummy_bt_Start (void); | |
411 | |
412 static T_HCI_RET dummy_bt_Stop (void); | |
413 | |
414 static T_HCI_RET dummy_bt_Kill (void); | |
415 | |
416 static T_HCI_RET dummy_bt_SetBaudrate (UINT8 baudrate); | |
417 | |
418 static T_HCI_RET dummy_bt_TransmitPacket (void *uart_tx_buffer); | |
419 | |
420 static SYS_BOOL dummy_bt_EnterSleep (void); | |
421 | |
422 static void dummy_bt_WakeUp (void); | |
423 | |
424 #endif | |
425 | |
426 /* | |
427 * Constants tables representing the various possible configurations | |
428 * for Trace, Fax & Data and Bluetooth HCI according to the different devices. | |
429 * Constant table for Trace using no device. | |
430 */ | |
431 | |
432 static const t_tr_functions dummy_trace = { | |
433 | |
434 DUMMY_DEVICE, | |
435 dummy_tr_Init, | |
436 dummy_tr_ReadNChars, | |
437 dummy_tr_ReadNBytes, | |
438 dummy_tr_WriteNChars, | |
439 dummy_tr_EncapsulateNChars, | |
440 dummy_tr_WriteNBytes, | |
441 dummy_tr_WriteChar, | |
442 dummy_tr_WriteString, | |
443 dummy_tr_EnterSleep, | |
444 dummy_tr_WakeUp | |
445 }; | |
446 | |
447 /* | |
448 * Constant table for Trace using UART IrDA. | |
449 */ | |
450 | |
451 static const t_tr_functions uart_irda_trace = { | |
452 | |
453 UA_UART_0, | |
454 UA_Init, | |
455 UA_ReadNChars, | |
456 UA_ReadNBytes, | |
457 UA_WriteNChars, | |
458 UA_EncapsulateNChars, | |
459 UA_WriteNBytes, | |
460 UA_WriteChar, | |
461 UA_WriteString, | |
462 UA_EnterSleep, | |
463 UA_WakeUp | |
464 }; | |
465 | |
466 /* | |
467 * Constant table for Trace using UART Modem. | |
468 */ | |
469 | |
470 static const t_tr_functions uart_modem_trace = { | |
471 | |
472 UA_UART_1, | |
473 UA_Init, | |
474 UA_ReadNChars, | |
475 UA_ReadNBytes, | |
476 UA_WriteNChars, | |
477 UA_EncapsulateNChars, | |
478 UA_WriteNBytes, | |
479 UA_WriteChar, | |
480 UA_WriteString, | |
481 UA_EnterSleep, | |
482 UA_WakeUp | |
483 }; | |
484 | |
485 #if (CHIPSET == 12) | |
486 /* | |
487 * Constant table for Trace using UART Modem2. | |
488 */ | |
489 | |
490 static const t_tr_functions uart_modem2_trace = { | |
491 | |
492 UA_UART_2, | |
493 UA_Init, | |
494 UA_ReadNChars, | |
495 UA_ReadNBytes, | |
496 UA_WriteNChars, | |
497 UA_EncapsulateNChars, | |
498 UA_WriteNBytes, | |
499 UA_WriteChar, | |
500 UA_WriteString, | |
501 UA_EnterSleep, | |
502 UA_WakeUp | |
503 }; | |
504 #endif | |
505 | |
506 /* | |
507 * Constant table for Fax & Data using no device. | |
508 */ | |
509 | |
510 static const t_fd_functions dummy_fax_data = { | |
511 | |
512 DUMMY_DEVICE, | |
513 dummy_fd_Init, | |
514 dummy_fd_Enable, | |
515 dummy_fd_SetComPar, | |
516 dummy_fd_SetBuffer, | |
517 dummy_fd_SetFlowCtrl, | |
518 dummy_fd_SetEscape, | |
519 dummy_fd_InpAvail, | |
520 dummy_fd_OutpAvail, | |
521 dummy_fd_EnterSleep, | |
522 dummy_fd_WakeUp, | |
523 dummy_fd_ReadData, | |
524 dummy_fd_WriteData, | |
525 dummy_fd_StopRec, | |
526 dummy_fd_StartRec, | |
527 dummy_fd_GetLineState, | |
528 dummy_fd_SetLineState, | |
529 dummy_fd_CheckXEmpty | |
530 }; | |
531 | |
532 /* | |
533 * Constant table for Fax & Data using UART Modem. | |
534 */ | |
535 | |
536 static const t_fd_functions uart_modem_fax_data = { | |
537 | |
538 UAF_UART_1, | |
539 UAF_Init, | |
540 UAF_Enable, | |
541 UAF_SetComPar, | |
542 UAF_SetBuffer, | |
543 UAF_SetFlowCtrl, | |
544 UAF_SetEscape, | |
545 UAF_InpAvail, | |
546 UAF_OutpAvail, | |
547 UAF_EnterSleep, | |
548 UAF_WakeUp, | |
549 UAF_ReadData, | |
550 UAF_WriteData, | |
551 UAF_StopRec, | |
552 UAF_StartRec, | |
553 UAF_GetLineState, | |
554 UAF_SetLineState, | |
555 UAF_CheckXEmpty | |
556 }; | |
557 | |
558 #ifdef BTEMOBILE | |
559 /* | |
560 * Constant table for BT HCI using no device. | |
561 */ | |
562 | |
563 static const t_bt_functions dummy_bt_hci = { | |
564 | |
565 DUMMY_DEVICE, | |
566 dummy_bt_Init, | |
567 dummy_bt_Start, | |
568 dummy_bt_Stop, | |
569 dummy_bt_Kill, | |
570 dummy_bt_SetBaudrate, | |
571 dummy_bt_TransmitPacket, | |
572 dummy_bt_EnterSleep, | |
573 dummy_bt_WakeUp | |
574 }; | |
575 | |
576 /* | |
577 * Constant table for BT HCI using UART IrDA. | |
578 */ | |
579 | |
580 static const t_bt_functions uart_irda_bt_hci = { | |
581 | |
582 UABT_UART_0, | |
583 hciu_init, | |
584 hciu_start, | |
585 hciu_stop, | |
586 hciu_kill, | |
587 hciu_set_baudrate, | |
588 hciu_transmit_packet, | |
589 hciu_enter_sleep, | |
590 hciu_wakeup | |
591 }; | |
592 | |
593 /* | |
594 * Constant table for BT HCI using UART Modem. | |
595 */ | |
596 | |
597 static const t_bt_functions uart_modem_bt_hci = { | |
598 | |
599 UABT_UART_1, | |
600 hciu_init, | |
601 hciu_start, | |
602 hciu_stop, | |
603 hciu_kill, | |
604 hciu_set_baudrate, | |
605 hciu_transmit_packet, | |
606 hciu_enter_sleep, | |
607 hciu_wakeup | |
608 }; | |
609 | |
610 #if (CHIPSET == 12) | |
611 /* | |
612 * Constant table for BT HCI using UART Modem2. | |
613 */ | |
614 | |
615 static const t_bt_functions uart_modem2_bt_hci = { | |
616 | |
617 UABT_UART_2, | |
618 hciu_init, | |
619 hciu_start, | |
620 hciu_stop, | |
621 hciu_kill, | |
622 hciu_set_baudrate, | |
623 hciu_transmit_packet, | |
624 hciu_go_to_sleep, | |
625 hciu_wakeup | |
626 }; | |
627 #endif | |
628 #endif | |
629 | |
630 #ifdef SERIAL_DYNAMIC_SWITCH | |
631 /* | |
632 * Structure used to store initialization parameters related to the AT-Cmd/F&D flow. | |
633 * Numbers of paramaters (in case of multiple calls) have been figured out from | |
634 * Condat AT-Command/F&D flow initialization. | |
635 */ | |
636 | |
637 typedef struct s_data_flow { | |
638 | |
639 /* | |
640 * Parameters related to SER_fd_SetComPar (2 calls) | |
641 */ | |
642 T_baudrate baudrate[2]; | |
643 T_bitsPerCharacter bpc[2]; | |
644 T_stopBits sb[2]; | |
645 T_parity parity[2]; | |
646 | |
647 /* | |
648 * Parameters related to SER_fd_SetBuffer | |
649 */ | |
650 SYS_WORD16 bufSize; | |
651 SYS_WORD16 rxThreshold; | |
652 SYS_WORD16 txThreshold; | |
653 | |
654 /* | |
655 * Parameters related to SER_fd_SetFlowCtrl (2 calls) | |
656 */ | |
657 T_flowCtrlMode fcMode[2]; | |
658 SYS_UWORD8 XON[2]; | |
659 SYS_UWORD8 XOFF[2]; | |
660 | |
661 /* | |
662 * Parameters related to SER_fd_SetEscape (2 calls) | |
663 */ | |
664 SYS_UWORD8 escChar[2]; | |
665 SYS_UWORD16 guardPeriod[2]; | |
666 | |
667 /* | |
668 * Parameters related to SER_fd_SetLineState (4 calls) | |
669 */ | |
670 SYS_UWORD32 state[4]; | |
671 SYS_UWORD32 mask[4]; | |
672 | |
673 /* | |
674 * Parameters related to SER_fd_ReadData | |
675 */ | |
676 T_suspendMode suspend_rd; | |
677 void (*readOutFunc) (SYS_BOOL cldFromIrq, | |
678 T_reInstMode *reInstall, | |
679 SYS_UWORD8 nsource, | |
680 SYS_UWORD8 *source[], | |
681 SYS_UWORD16 size[], | |
682 SYS_UWORD32 state); | |
683 /* | |
684 * Parameters related to SER_fd_WriteData | |
685 */ | |
686 T_suspendMode suspend_wr; | |
687 void (*writeInFunc) (SYS_BOOL cldFromIrq, | |
688 T_reInstMode *reInstall, | |
689 SYS_UWORD8 ndest, | |
690 SYS_UWORD8 *dest[], | |
691 SYS_UWORD16 size[]); | |
692 | |
693 } t_data_flow; | |
694 #endif /* (defined BTEMOBILE && (CHIPSET != 12)) */ | |
695 | |
696 /* | |
697 * UART structure used for UARTs. | |
698 */ | |
699 | |
700 typedef struct s_uart { | |
701 | |
702 SYS_UWORD32 base_address; | |
703 SYS_BOOL device_used; | |
704 SYS_BOOL deep_sleep_set_up; | |
705 t_flow_type flow_type; | |
706 SYS_WORD16 flow_id; | |
707 void (*interrupt_handler) (int uart_id, | |
708 SYS_UWORD8 interrupt_status); | |
709 | |
710 } t_uart; | |
711 | |
712 static const t_tr_functions *tr_functions[SER_MAX_NUMBER_OF_FLOWS]; | |
713 static const t_fd_functions *fd_functions; | |
714 | |
715 #ifdef BTEMOBILE | |
716 static const t_bt_functions *bt_functions; | |
717 #endif | |
718 | |
719 #ifdef SERIAL_DYNAMIC_SWITCH | |
720 static SYS_BOOL uart_fd_initialized = 0; | |
721 #endif | |
722 | |
723 static SYS_UWORD8 fd_buffer[FD_MAX_BUFFER_SIZE]; | |
724 static SYS_BOOL fd_driver_enabled; | |
725 | |
726 #ifdef SERIAL_DYNAMIC_SWITCH | |
727 static t_data_flow data_flow_parameters; | |
728 #else | |
729 static SYS_WORD16 bufSize; | |
730 #endif | |
731 | |
732 #ifdef SERIAL_DYNAMIC_SWITCH | |
733 /* | |
734 * Variables used to count calls to SER_fd_XXX functions. | |
735 */ | |
736 | |
737 static SYS_UWORD8 fd_UAF_SetBuffer = 0; | |
738 static SYS_UWORD8 fd_UAF_SetEscape = 0; | |
739 static SYS_UWORD8 fd_UAF_SetComPar = 0; | |
740 static SYS_UWORD8 fd_UAF_SetFlowCtrl = 0; | |
741 static SYS_UWORD8 fd_UAF_ReadData = 0; | |
742 static SYS_UWORD8 fd_UAF_SetLineState = 0; | |
743 static SYS_UWORD8 fd_UAF_WriteData = 0; | |
744 #endif | |
745 | |
746 /* | |
747 * Timer used for duration control when UARTs are waked up by an interrupt or | |
748 * each time any new incoming characters are received; This timer prevents the | |
749 * system to enter deep sleep mode. | |
750 */ | |
751 | |
752 static NU_TIMER uart_sleep_timer; | |
753 SYS_BOOL uart_sleep_timer_enabled; | |
754 | |
755 /* | |
756 * HISR used to reset and restart the sleep timer from an UART use by a Trace | |
757 * flow in case of incoming characters. | |
758 */ | |
759 | |
760 #define TIMER_HISR_PRIORITY (2) | |
761 #define TIMER_HISR_STACK_SIZE (512) /* Bytes. */ | |
762 | |
763 static NU_HISR timer_hisr_ctrl_block; | |
764 static char timer_hisr_stack[TIMER_HISR_STACK_SIZE]; | |
765 | |
766 /* | |
767 * For next arrays, it is supposed that NUMBER_OF_TR_UART, NUMBER_OF_FD_UART | |
768 * and NUMBER_OF_BT_UART have the same values. | |
769 * An index on an internal uart for trace, fax & data or bluetooth hci reffers | |
770 * to the same uart device. | |
771 */ | |
772 | |
773 static t_uart int_uart[NUMBER_OF_TR_UART]; | |
774 | |
775 #if ((CHIPSET == 2) || (CHIPSET == 3)) | |
776 static SYS_UWORD32 uart_spurious_interrupts; | |
777 #elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) | |
778 static SYS_UWORD32 uart_modem_spurious_interrupts; | |
779 static SYS_UWORD32 uart_irda_spurious_interrupts; | |
780 #endif | |
781 #if (CHIPSET == 12) | |
782 static SYS_UWORD32 uart_modem2_spurious_interrupts; | |
783 #endif | |
784 | |
785 static const SYS_UWORD32 uart_base_address[NUMBER_OF_TR_UART] = | |
786 { | |
787 MEM_UART_IRDA, | |
788 MEM_UART_MODEM | |
789 #if (CHIPSET == 12) | |
790 , MEM_UART_MODEM2 | |
791 #endif | |
792 }; | |
793 | |
794 | |
795 /******************************************************************************* | |
796 * | |
797 * dummy_tr_Init | |
798 * | |
799 * Purpose: No action. | |
800 * | |
801 * Parameters: See SER_tr_Init. | |
802 * | |
803 * Return: none | |
804 * | |
805 ******************************************************************************/ | |
806 | |
807 static void | |
808 dummy_tr_Init (T_tr_UartId device, | |
809 T_tr_Baudrate baudrate, | |
810 void (callback_function (void))) | |
811 { | |
812 /* | |
813 * No action. | |
814 */ | |
815 } | |
816 | |
817 /******************************************************************************* | |
818 * | |
819 * dummy_tr_ReadNChars | |
820 * | |
821 * Purpose: No action. | |
822 * | |
823 * Parameters: See SER_tr_ReadNChars. | |
824 * | |
825 * Return: 0 | |
826 * | |
827 ******************************************************************************/ | |
828 | |
829 static SYS_UWORD32 | |
830 dummy_tr_ReadNChars (T_tr_UartId device, | |
831 char *buffer, | |
832 SYS_UWORD32 chars_to_read) | |
833 { | |
834 return (0); | |
835 } | |
836 | |
837 /******************************************************************************* | |
838 * | |
839 * dummy_tr_ReadNBytes | |
840 * | |
841 * Purpose: No action. | |
842 * | |
843 * Parameters: See SER_tr_ReadNBytes. | |
844 * | |
845 * Return: 0 | |
846 * | |
847 ******************************************************************************/ | |
848 | |
849 static SYS_UWORD32 | |
850 dummy_tr_ReadNBytes (T_tr_UartId device, | |
851 char *buffer, | |
852 SYS_UWORD32 chars_to_read, | |
853 SYS_BOOL *eof_detected) | |
854 { | |
855 return (0); | |
856 } | |
857 | |
858 /******************************************************************************* | |
859 * | |
860 * dummy_tr_WriteNChars | |
861 * | |
862 * Purpose: No action. | |
863 * | |
864 * Parameters: See SER_tr_WriteNChars. | |
865 * | |
866 * Return: The number of character to write. | |
867 * | |
868 ******************************************************************************/ | |
869 | |
870 static SYS_UWORD32 | |
871 dummy_tr_WriteNChars (T_tr_UartId device, | |
872 char *buffer, | |
873 SYS_UWORD32 chars_to_write) | |
874 { | |
875 return (chars_to_write); | |
876 } | |
877 | |
878 /******************************************************************************* | |
879 * | |
880 * dummy_tr_EncapsulateNChars | |
881 * | |
882 * Purpose: No action. | |
883 * | |
884 * Parameters: See SER_tr_EncapsulateNChars. | |
885 * | |
886 * Return: The number of character to write. | |
887 * | |
888 ******************************************************************************/ | |
889 | |
890 static SYS_UWORD32 | |
891 dummy_tr_EncapsulateNChars (T_tr_UartId device, | |
892 char *buffer, | |
893 SYS_UWORD32 chars_to_write) | |
894 { | |
895 return (chars_to_write); | |
896 } | |
897 | |
898 /******************************************************************************* | |
899 * | |
900 * dummy_tr_WriteNBytes | |
901 * | |
902 * Purpose: No action. | |
903 * | |
904 * Parameters: See SER_tr_WriteNBytes. | |
905 * | |
906 * Return: The number of byte to write. | |
907 * | |
908 ******************************************************************************/ | |
909 | |
910 static SYS_UWORD32 | |
911 dummy_tr_WriteNBytes (T_tr_UartId device, | |
912 SYS_UWORD8 *buffer, | |
913 SYS_UWORD32 chars_to_write) | |
914 { | |
915 return (chars_to_write); | |
916 } | |
917 | |
918 /******************************************************************************* | |
919 * | |
920 * dummy_tr_WriteChar | |
921 * | |
922 * Purpose: No action. | |
923 * | |
924 * Parameters: See SER_tr_WriteChar. | |
925 * | |
926 * Return: none | |
927 * | |
928 ******************************************************************************/ | |
929 | |
930 static void | |
931 dummy_tr_WriteChar (T_tr_UartId device, | |
932 char character) | |
933 { | |
934 /* | |
935 * No action. | |
936 */ | |
937 } | |
938 | |
939 /******************************************************************************* | |
940 * | |
941 * dummy_tr_WriteString | |
942 * | |
943 * Purpose: No action. | |
944 * | |
945 * Parameters: See SER_tr_WriteString. | |
946 * | |
947 * Return: none | |
948 * | |
949 ******************************************************************************/ | |
950 | |
951 static void | |
952 dummy_tr_WriteString (T_tr_UartId device, | |
953 char *buffer) | |
954 { | |
955 /* | |
956 * No action. | |
957 */ | |
958 } | |
959 | |
960 /******************************************************************************* | |
961 * | |
962 * dummy_tr_EnterSleep | |
963 * | |
964 * Purpose: No action. | |
965 * | |
966 * Parameters: See SER_tr_EnterSleep. | |
967 * | |
968 * Return: 1 | |
969 * | |
970 ******************************************************************************/ | |
971 | |
972 static SYS_BOOL | |
973 dummy_tr_EnterSleep (T_tr_UartId device) | |
974 { | |
975 return (1); | |
976 } | |
977 | |
978 /******************************************************************************* | |
979 * | |
980 * dummy_tr_WakeUp | |
981 * | |
982 * Purpose: No action. | |
983 * | |
984 * Parameters: See SER_tr_WakeUp. | |
985 * | |
986 * Return: none | |
987 * | |
988 ******************************************************************************/ | |
989 | |
990 static void | |
991 dummy_tr_WakeUp (T_tr_UartId device) | |
992 { | |
993 /* | |
994 * No action. | |
995 */ | |
996 } | |
997 | |
998 /******************************************************************************* | |
999 * | |
1000 * dummy_fd_Init | |
1001 * | |
1002 * Purpose: Sets the size of the circular buffer to the maximum value and the | |
1003 * state of the driver to 'disabled'. | |
1004 * | |
1005 * Parameters: See SER_fd_Init. | |
1006 * | |
1007 * Return: FD_OK: Successful operation. | |
1008 * | |
1009 ******************************************************************************/ | |
1010 | |
1011 static T_FDRET | |
1012 dummy_fd_Init (T_fd_UartId device) | |
1013 { | |
1014 #ifdef SERIAL_DYNAMIC_SWITCH | |
1015 data_flow_parameters.bufSize = FD_MAX_BUFFER_SIZE; | |
1016 #else | |
1017 bufSize = FD_MAX_BUFFER_SIZE; | |
1018 #endif | |
1019 fd_driver_enabled = 0; | |
1020 | |
1021 return (FD_OK); | |
1022 } | |
1023 | |
1024 /******************************************************************************* | |
1025 * | |
1026 * dummy_fd_Enable | |
1027 * | |
1028 * Purpose: Stores the state of the driver. | |
1029 * | |
1030 * Parameters: See SER_fd_Enable. | |
1031 * | |
1032 * Return: FD_OK: Successful operation. | |
1033 * | |
1034 ******************************************************************************/ | |
1035 | |
1036 static T_FDRET | |
1037 dummy_fd_Enable (T_fd_UartId device, | |
1038 SYS_BOOL enable) | |
1039 { | |
1040 fd_driver_enabled = enable; | |
1041 | |
1042 return (FD_OK); | |
1043 } | |
1044 | |
1045 /******************************************************************************* | |
1046 * | |
1047 * dummy_fd_SetComPar | |
1048 * | |
1049 * Purpose: No action. | |
1050 * | |
1051 * Parameters: See SER_fd_SetComPar. | |
1052 * | |
1053 * Return: FD_OK: Successful operation. | |
1054 * | |
1055 ******************************************************************************/ | |
1056 | |
1057 static T_FDRET | |
1058 dummy_fd_SetComPar (T_fd_UartId device, | |
1059 T_baudrate baudrate, | |
1060 T_bitsPerCharacter bpc, | |
1061 T_stopBits sb, | |
1062 T_parity parity) | |
1063 { | |
1064 return (FD_OK); | |
1065 } | |
1066 | |
1067 /******************************************************************************* | |
1068 * | |
1069 * dummy_fd_SetBuffer | |
1070 * | |
1071 * Purpose: No action. | |
1072 * | |
1073 * Parameters: See SER_fd_SetBuffer. | |
1074 * | |
1075 * Return: FD_OK: Successful operation. | |
1076 * | |
1077 ******************************************************************************/ | |
1078 | |
1079 static T_FDRET | |
1080 dummy_fd_SetBuffer (T_fd_UartId device, | |
1081 SYS_UWORD16 bufSize, | |
1082 SYS_UWORD16 rxThreshold, | |
1083 SYS_UWORD16 txThreshold) | |
1084 { | |
1085 return (FD_OK); | |
1086 } | |
1087 | |
1088 /******************************************************************************* | |
1089 * | |
1090 * dummy_fd_SetFlowCtrl | |
1091 * | |
1092 * Purpose: No action. | |
1093 * | |
1094 * Parameters: See SER_fd_SetFlowCtrl. | |
1095 * | |
1096 * Return: FD_OK: Successful operation. | |
1097 * | |
1098 ******************************************************************************/ | |
1099 | |
1100 static T_FDRET | |
1101 dummy_fd_SetFlowCtrl (T_fd_UartId device, | |
1102 T_flowCtrlMode fcMode, | |
1103 SYS_UWORD8 XON, | |
1104 SYS_UWORD8 XOFF) | |
1105 { | |
1106 return (FD_OK); | |
1107 } | |
1108 | |
1109 /******************************************************************************* | |
1110 * | |
1111 * dummy_fd_SetEscape | |
1112 * | |
1113 * Purpose: No action. | |
1114 * | |
1115 * Parameters: See SER_fd_SetEscape. | |
1116 * | |
1117 * Return: FD_OK: Successful operation. | |
1118 * | |
1119 ******************************************************************************/ | |
1120 | |
1121 static T_FDRET | |
1122 dummy_fd_SetEscape (T_fd_UartId device, | |
1123 SYS_UWORD8 escChar, | |
1124 SYS_UWORD16 guardPeriod) | |
1125 { | |
1126 return (FD_OK); | |
1127 } | |
1128 | |
1129 /******************************************************************************* | |
1130 * | |
1131 * dummy_fd_InpAvail | |
1132 * | |
1133 * Purpose: No action. | |
1134 * | |
1135 * Parameters: See SER_fd_InpAvail. | |
1136 * | |
1137 * Return: The size of the circular buffer. | |
1138 * | |
1139 ******************************************************************************/ | |
1140 | |
1141 static T_FDRET | |
1142 dummy_fd_InpAvail (T_fd_UartId device) | |
1143 { | |
1144 #ifdef SERIAL_DYNAMIC_SWITCH | |
1145 return (data_flow_parameters.bufSize); | |
1146 #else | |
1147 return (bufSize); | |
1148 #endif | |
1149 } | |
1150 | |
1151 /******************************************************************************* | |
1152 * | |
1153 * dummy_fd_OutpAvail | |
1154 * | |
1155 * Purpose: No action. | |
1156 * | |
1157 * Parameters: See SER_fd_OutpAvail. | |
1158 * | |
1159 * Return: The size of the circular buffer. | |
1160 * | |
1161 ******************************************************************************/ | |
1162 | |
1163 static T_FDRET | |
1164 dummy_fd_OutpAvail (T_fd_UartId device) | |
1165 { | |
1166 #ifdef SERIAL_DYNAMIC_SWITCH | |
1167 return (data_flow_parameters.bufSize); | |
1168 #else | |
1169 return (bufSize); | |
1170 #endif | |
1171 } | |
1172 | |
1173 /******************************************************************************* | |
1174 * | |
1175 * dummy_fd_EnterSleep | |
1176 * | |
1177 * Purpose: No action. | |
1178 * | |
1179 * Parameters: See SER_tr_EnterSleep. | |
1180 * | |
1181 * Return: 1 | |
1182 * | |
1183 ******************************************************************************/ | |
1184 | |
1185 static T_FDRET | |
1186 dummy_fd_EnterSleep (T_fd_UartId device) | |
1187 { | |
1188 return (1); | |
1189 } | |
1190 | |
1191 /******************************************************************************* | |
1192 * | |
1193 * dummy_fd_WakeUp | |
1194 * | |
1195 * Purpose: No action. | |
1196 * | |
1197 * Parameters: See SER_tr_WakeUp. | |
1198 * | |
1199 * Return: FD_OK: Successful operation. | |
1200 * | |
1201 ******************************************************************************/ | |
1202 | |
1203 static T_FDRET | |
1204 dummy_fd_WakeUp (T_fd_UartId device) | |
1205 { | |
1206 return (FD_OK); | |
1207 } | |
1208 | |
1209 /******************************************************************************* | |
1210 * | |
1211 * dummy_fd_ReadData | |
1212 * | |
1213 * Purpose: No action. | |
1214 * | |
1215 * Parameters: See SER_fd_ReadData. | |
1216 * | |
1217 * Return: 0 if the suspend parameter is set to 'sm_noSuspend'. | |
1218 * FD_SUSPENDED if the suspend parameter is set to 'sm_suspend'. | |
1219 * | |
1220 ******************************************************************************/ | |
1221 | |
1222 static T_FDRET | |
1223 dummy_fd_ReadData (T_fd_UartId device, | |
1224 T_suspendMode suspend, | |
1225 void (readOutFunc (SYS_BOOL cldFromIrq, | |
1226 T_reInstMode *reInstall, | |
1227 SYS_UWORD8 nsource, | |
1228 SYS_UWORD8 *source[], | |
1229 SYS_UWORD16 size[], | |
1230 SYS_UWORD32 state))) | |
1231 { | |
1232 T_FDRET result; | |
1233 | |
1234 if (suspend == sm_noSuspend) | |
1235 result = 0; | |
1236 else | |
1237 result = FD_SUSPENDED; | |
1238 | |
1239 return (result); | |
1240 } | |
1241 | |
1242 /******************************************************************************* | |
1243 * | |
1244 * dummy_fd_WriteData | |
1245 * | |
1246 * Purpose: The user's function is called with: | |
1247 * - cldFromIrq = 0 | |
1248 * - ndest = 1 | |
1249 * - dest[0] is a SYS_UWORD8 pointer on the beginning address of a local | |
1250 * buffer | |
1251 * - size[0] is set to data_flow_parameters.bufSize. | |
1252 * | |
1253 * Parameters: See SER_fd_WriteData. | |
1254 * | |
1255 * Return: The number of bytes written in the local buffer. | |
1256 * | |
1257 ******************************************************************************/ | |
1258 | |
1259 static T_FDRET | |
1260 dummy_fd_WriteData (T_fd_UartId device, | |
1261 T_suspendMode suspend, | |
1262 void (writeInFunc (SYS_BOOL cldFromIrq, | |
1263 T_reInstMode *reInstall, | |
1264 SYS_UWORD8 ndest, | |
1265 SYS_UWORD8 *dest[], | |
1266 SYS_UWORD16 size[]))) | |
1267 { | |
1268 T_reInstMode dummyInstall; | |
1269 SYS_UWORD8 *destination[2]; | |
1270 SYS_UWORD16 buffer_size[2]; | |
1271 | |
1272 destination[0] = &(fd_buffer[0]); | |
1273 #ifdef SERIAL_DYNAMIC_SWITCH | |
1274 buffer_size[0] = data_flow_parameters.bufSize; | |
1275 #else | |
1276 buffer_size[0] = bufSize; | |
1277 #endif | |
1278 | |
1279 (*writeInFunc) (0, &dummyInstall, 1, &(destination[0]), &(buffer_size[0])); | |
1280 | |
1281 #ifdef SERIAL_DYNAMIC_SWITCH | |
1282 return ((T_FDRET) (data_flow_parameters.bufSize - buffer_size[0])); | |
1283 #else | |
1284 return ((T_FDRET) (bufSize - buffer_size[0])); | |
1285 #endif | |
1286 } | |
1287 | |
1288 /******************************************************************************* | |
1289 * | |
1290 * dummy_fd_StopRec | |
1291 * | |
1292 * Purpose: No action. | |
1293 * | |
1294 * Parameters: See SER_fd_StopRec. | |
1295 * | |
1296 * Return: FD_OK: Successful operation. | |
1297 * | |
1298 ******************************************************************************/ | |
1299 | |
1300 static T_FDRET | |
1301 dummy_fd_StopRec (T_fd_UartId device) | |
1302 { | |
1303 return (FD_OK); | |
1304 } | |
1305 | |
1306 /******************************************************************************* | |
1307 * | |
1308 * dummy_fd_StartRec | |
1309 * | |
1310 * Purpose: No action. | |
1311 * | |
1312 * Parameters: See SER_fd_StartRec. | |
1313 * | |
1314 * Return: FD_OK: Successful operation. | |
1315 * | |
1316 ******************************************************************************/ | |
1317 | |
1318 static T_FDRET | |
1319 dummy_fd_StartRec (T_fd_UartId device) | |
1320 { | |
1321 return (FD_OK); | |
1322 } | |
1323 | |
1324 /******************************************************************************* | |
1325 * | |
1326 * dummy_fd_GetLineState | |
1327 * | |
1328 * Purpose: Sets the RXBLEV field to the bufSize value. | |
1329 * | |
1330 * Parameters: See SER_fd_GetLineState. | |
1331 * | |
1332 * Return: FD_OK: Successful operation. | |
1333 * | |
1334 ******************************************************************************/ | |
1335 | |
1336 static T_FDRET | |
1337 dummy_fd_GetLineState (T_fd_UartId device, | |
1338 SYS_UWORD32 *state) | |
1339 { | |
1340 #ifdef SERIAL_DYNAMIC_SWITCH | |
1341 *state = data_flow_parameters.bufSize << RXBLEV; | |
1342 #else | |
1343 *state = bufSize << RXBLEV; | |
1344 #endif | |
1345 | |
1346 return (FD_OK); | |
1347 } | |
1348 | |
1349 /******************************************************************************* | |
1350 * | |
1351 * dummy_fd_SetLineState | |
1352 * | |
1353 * Purpose: No action. | |
1354 * | |
1355 * Parameters: See SER_fd_SetLineState. | |
1356 * | |
1357 * Return: FD_OK: Successful operation. | |
1358 * | |
1359 ******************************************************************************/ | |
1360 | |
1361 static T_FDRET | |
1362 dummy_fd_SetLineState (T_fd_UartId device, | |
1363 SYS_UWORD32 state, | |
1364 SYS_UWORD32 mask) | |
1365 { | |
1366 return (FD_OK); | |
1367 } | |
1368 | |
1369 /******************************************************************************* | |
1370 * | |
1371 * dummy_fd_CheckXEmpty | |
1372 * | |
1373 * Purpose: No action. | |
1374 * | |
1375 * Parameters: See SER_fd_CheckXEmpty. | |
1376 * | |
1377 * Return: FD_OK: Successful operation. | |
1378 * | |
1379 ******************************************************************************/ | |
1380 | |
1381 static T_FDRET | |
1382 dummy_fd_CheckXEmpty (T_fd_UartId device) | |
1383 { | |
1384 return (FD_OK); | |
1385 } | |
1386 | |
1387 #ifdef BTEMOBILE | |
1388 /******************************************************************************* | |
1389 * | |
1390 * dummy_bt_Init | |
1391 * | |
1392 * Purpose: No action. | |
1393 * | |
1394 * Parameters: See SER_bt_Init. | |
1395 * | |
1396 * Return: HCI_OK: Successful operation. | |
1397 * | |
1398 ******************************************************************************/ | |
1399 | |
1400 static T_HCI_RET | |
1401 dummy_bt_Init (T_bt_UartId uart_device) | |
1402 { | |
1403 return (HCI_OK); | |
1404 } | |
1405 | |
1406 /******************************************************************************* | |
1407 * | |
1408 * dummy_bt_Start | |
1409 * | |
1410 * Purpose: No action. | |
1411 * | |
1412 * Parameters: See SER_bt_Start. | |
1413 * | |
1414 * Return: HCI_OK: Successful operation. | |
1415 * | |
1416 ******************************************************************************/ | |
1417 | |
1418 static T_HCI_RET | |
1419 dummy_bt_Start (void) | |
1420 { | |
1421 return (HCI_OK); | |
1422 } | |
1423 | |
1424 /******************************************************************************* | |
1425 * | |
1426 * dummy_bt_Stop | |
1427 * | |
1428 * Purpose: No action. | |
1429 * | |
1430 * Parameters: See SER_bt_Stop. | |
1431 * | |
1432 * Return: HCI_OK: Successful operation. | |
1433 * | |
1434 ******************************************************************************/ | |
1435 | |
1436 static T_HCI_RET | |
1437 dummy_bt_Stop (void) | |
1438 { | |
1439 return (HCI_OK); | |
1440 } | |
1441 | |
1442 /******************************************************************************* | |
1443 * | |
1444 * dummy_bt_Kill | |
1445 * | |
1446 * Purpose: No action. | |
1447 * | |
1448 * Parameters: See SER_bt_Kill. | |
1449 * | |
1450 * Return: HCI_OK: Successful operation. | |
1451 * | |
1452 ******************************************************************************/ | |
1453 | |
1454 static T_HCI_RET | |
1455 dummy_bt_Kill (void) | |
1456 { | |
1457 return (HCI_OK); | |
1458 } | |
1459 | |
1460 /******************************************************************************* | |
1461 * | |
1462 * dummy_bt_SetBaudrate | |
1463 * | |
1464 * Purpose: No action. | |
1465 * | |
1466 * Parameters: See SER_bt_SetBaudrate. | |
1467 * | |
1468 * Return: HCI_OK: Successful operation. | |
1469 * | |
1470 ******************************************************************************/ | |
1471 | |
1472 static T_HCI_RET | |
1473 dummy_bt_SetBaudrate (UINT8 baudrate) | |
1474 { | |
1475 return (HCI_OK); | |
1476 } | |
1477 | |
1478 /******************************************************************************* | |
1479 * | |
1480 * dummy_bt_TransmitPacket | |
1481 * | |
1482 * Purpose: No action. | |
1483 * | |
1484 * Parameters: See SER_bt_TransmitPacket. | |
1485 * | |
1486 * Return: HCI_OK: Successful operation. | |
1487 * | |
1488 ******************************************************************************/ | |
1489 | |
1490 static T_HCI_RET dummy_bt_TransmitPacket (void *uart_tx_buffer) | |
1491 | |
1492 { | |
1493 return (HCI_OK); | |
1494 } | |
1495 | |
1496 /******************************************************************************* | |
1497 * | |
1498 * dummy_bt_EnterSleep | |
1499 * | |
1500 * Purpose: No action. | |
1501 * | |
1502 * Parameters: See SER_bt_EnterSleep. | |
1503 * | |
1504 * Return: TRUE. | |
1505 * | |
1506 ******************************************************************************/ | |
1507 | |
1508 static SYS_BOOL | |
1509 dummy_bt_EnterSleep (void) | |
1510 { | |
1511 return (TRUE); | |
1512 } | |
1513 | |
1514 /******************************************************************************* | |
1515 * | |
1516 * dummy_bt_WakeUp | |
1517 * | |
1518 * Purpose: No action. | |
1519 * | |
1520 * Parameters: See SER_bt_WakeUp | |
1521 * | |
1522 * Return: HCI_OK: none | |
1523 * | |
1524 ******************************************************************************/ | |
1525 | |
1526 static void | |
1527 dummy_bt_WakeUp (void) | |
1528 { | |
1529 /* | |
1530 * No action. | |
1531 */ | |
1532 } | |
1533 | |
1534 #endif /* BTEMOBILE */ | |
1535 | |
1536 /******************************************************************************* | |
1537 * | |
1538 * analyze_uart_sleep_timer_expiration | |
1539 * | |
1540 * Purpose : The timer has just expired. If requested, UARTs can again be set | |
1541 * up to enter Deep Sleep. | |
1542 * | |
1543 * Arguments: In : id: parameter not used. | |
1544 * Out: none | |
1545 * | |
1546 * Returns : none | |
1547 * | |
1548 ******************************************************************************/ | |
1549 | |
1550 static VOID | |
1551 analyze_uart_sleep_timer_expiration (UNSIGNED id) | |
1552 { | |
1553 /* | |
1554 * Timer has expired. | |
1555 * UARTs can again be set up for Deep Sleep. | |
1556 */ | |
1557 | |
1558 (void) NU_Control_Timer (&uart_sleep_timer, | |
1559 NU_DISABLE_TIMER); | |
1560 | |
1561 uart_sleep_timer_enabled = 0; | |
1562 } | |
1563 | |
1564 /******************************************************************************* | |
1565 * | |
1566 * start_uart_sleep_timer | |
1567 * | |
1568 * Purpose : Starts the sleep timer once UARTs have been waked-up by an | |
1569 * interrupt or if new incoming characters have been received. | |
1570 * | |
1571 * Arguments: In : none | |
1572 * Out: none | |
1573 * | |
1574 * Returns : none | |
1575 * | |
1576 ******************************************************************************/ | |
1577 | |
1578 static void | |
1579 start_uart_sleep_timer (void) | |
1580 { | |
1581 /* | |
1582 * UART sleep timer is started. | |
1583 * UARTs can't no more be set up for Deep Sleep until the timer expires. | |
1584 */ | |
1585 | |
1586 (void) NU_Reset_Timer (&uart_sleep_timer, | |
1587 &analyze_uart_sleep_timer_expiration, | |
1588 WAKE_UP_TIME_IN_TDMA, | |
1589 0, /* The timer expires once. */ | |
1590 NU_DISABLE_TIMER); | |
1591 | |
1592 (void) NU_Control_Timer (&uart_sleep_timer, | |
1593 NU_ENABLE_TIMER); | |
1594 } | |
1595 | |
1596 /******************************************************************************* | |
1597 * | |
1598 * set_flow_functions | |
1599 * | |
1600 * Purpose: Initializes a serial data flow functions set with the set of | |
1601 * functions of the selected device. | |
1602 * | |
1603 * Parameters: In : flow : index of the serial data flow | |
1604 * serial_driver: allows knowing which set of functions must | |
1605 * be selected | |
1606 * Out: none | |
1607 * | |
1608 * Return: none | |
1609 * | |
1610 ******************************************************************************/ | |
1611 | |
1612 static void | |
1613 set_flow_functions (int flow, | |
1614 T_SerialDriver serial_driver) | |
1615 { | |
1616 | |
1617 switch (serial_driver) { | |
1618 | |
1619 case UART_MODEM_FAX_DATA: | |
1620 | |
1621 fd_functions = &uart_modem_fax_data; | |
1622 int_uart[fd_functions->device].device_used = 1; | |
1623 int_uart[fd_functions->device].flow_type = FAX_DATA_FLOW; | |
1624 int_uart[fd_functions->device].flow_id = flow; | |
1625 int_uart[fd_functions->device].interrupt_handler = | |
1626 UAF_InterruptHandler; | |
1627 break; | |
1628 | |
1629 case DUMMY_FAX_DATA: | |
1630 | |
1631 fd_functions = &dummy_fax_data; | |
1632 break; | |
1633 | |
1634 | |
1635 case UART_IRDA_TRACE: | |
1636 case UART_MODEM_TRACE: | |
1637 #if (CHIPSET == 12) | |
1638 case UART_MODEM2_TRACE: | |
1639 #endif | |
1640 | |
1641 if (serial_driver == UART_IRDA_TRACE) | |
1642 tr_functions[flow] = &uart_irda_trace; | |
1643 else { | |
1644 #if (CHIPSET == 12) | |
1645 if (serial_driver == UART_MODEM2_TRACE) | |
1646 tr_functions[flow] = &uart_modem2_trace; | |
1647 else | |
1648 #endif | |
1649 tr_functions[flow] = &uart_modem_trace; | |
1650 } | |
1651 | |
1652 int_uart[tr_functions[flow]->device].device_used = 1; | |
1653 int_uart[tr_functions[flow]->device].flow_type = TRACE_FLOW; | |
1654 int_uart[tr_functions[flow]->device].flow_id = flow; | |
1655 int_uart[tr_functions[flow]->device].interrupt_handler = | |
1656 UA_InterruptHandler; | |
1657 break; | |
1658 | |
1659 case DUMMY_TRACE: | |
1660 | |
1661 tr_functions[flow] = &dummy_trace; | |
1662 break; | |
1663 | |
1664 case DUMMY_BT_HCI: | |
1665 | |
1666 /* | |
1667 * if serial_driver = DUMMY_BT_HCI & if BTEMOBILE is not defined | |
1668 * no action is performed. | |
1669 */ | |
1670 | |
1671 #ifdef BTEMOBILE | |
1672 bt_functions = &dummy_bt_hci; | |
1673 break; | |
1674 | |
1675 case UART_IRDA_BT_HCI: | |
1676 case UART_MODEM_BT_HCI: | |
1677 #if (CHIPSET == 12) | |
1678 case UART_MODEM2_BT_HCI: | |
1679 #endif | |
1680 | |
1681 if (serial_driver == UART_IRDA_BT_HCI) | |
1682 bt_functions = &uart_irda_bt_hci; | |
1683 else { | |
1684 #if (CHIPSET == 12) | |
1685 if (serial_driver == UART_MODEM2_BT_HCI) | |
1686 bt_functions = &uart_modem2_bt_hci; | |
1687 else | |
1688 #endif | |
1689 bt_functions = &uart_modem_bt_hci; | |
1690 } | |
1691 | |
1692 int_uart[bt_functions->device].device_used = 1; | |
1693 int_uart[bt_functions->device].flow_type = BLUETOOTH_HCI_FLOW; | |
1694 int_uart[bt_functions->device].flow_id = flow; | |
1695 int_uart[bt_functions->device].interrupt_handler = | |
1696 hciu_interrupt_handler; | |
1697 #endif /* BTEMOBILE */ | |
1698 break; | |
1699 } | |
1700 } | |
1701 | |
1702 /******************************************************************************* | |
1703 * | |
1704 * SER_InitSerialConfig | |
1705 * | |
1706 * Purpose: The parameter serial_info allows knowing all serial information | |
1707 * necessary to set up the serial configuration of an application. | |
1708 * From this information, the function is able to determine if the | |
1709 * current serial configuration read out from the flash memory is | |
1710 * valid. If it does not correspond to an allowed configuration, the | |
1711 * default configuration is selected. This function must be called at | |
1712 * the application's initialization, but never after. | |
1713 * | |
1714 * Parameters: In : serial_info: application serial information like the default | |
1715 * configuration and all allowed configurations. | |
1716 * Out: none | |
1717 * | |
1718 * Return: none | |
1719 * | |
1720 ******************************************************************************/ | |
1721 | |
1722 void | |
1723 SER_InitSerialConfig (T_AppliSerialInfo *serial_info) | |
1724 { | |
1725 int uart_id; | |
1726 int flow; | |
1727 SYS_UWORD16 serial_driver; | |
1728 SYS_UWORD16 *allowed_config; | |
1729 SYS_UWORD8 nb_allowed_config; | |
1730 SYS_BOOL valid_config_selected; | |
1731 SYS_BOOL uart_used; | |
1732 SYS_BOOL uart_used_for_trace; | |
1733 SYS_UWORD16 current_config; | |
1734 SYS_UWORD16 *pt_current_config = &(current_config); | |
1735 | |
1736 /* | |
1737 * Basic UARTs initializations. | |
1738 */ | |
1739 | |
1740 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { | |
1741 | |
1742 int_uart[uart_id].base_address = uart_base_address[uart_id]; | |
1743 int_uart[uart_id].device_used = 0; | |
1744 int_uart[uart_id].deep_sleep_set_up = 0; | |
1745 } | |
1746 | |
1747 #if ((CHIPSET == 2) || (CHIPSET == 3)) | |
1748 uart_spurious_interrupts = 0; | |
1749 #elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) | |
1750 uart_modem_spurious_interrupts = 0; | |
1751 uart_irda_spurious_interrupts = 0; | |
1752 #endif | |
1753 #if (CHIPSET == 12) | |
1754 uart_modem2_spurious_interrupts = 0; | |
1755 #endif | |
1756 uart_sleep_timer_enabled = 0; | |
1757 | |
1758 /* | |
1759 * Compute the current serial configuration. | |
1760 */ | |
1761 | |
1762 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { | |
1763 | |
1764 switch (ser_cfg_info[uart_id]) { | |
1765 | |
1766 case G23_PANEL: | |
1767 serial_cfg = serial_cfg + | |
1768 ((uart_id + 1) << (12 - (4 * SER_PROTOCOL_STACK))); | |
1769 break; | |
1770 | |
1771 case RIVIERA_TRACE_MUX: | |
1772 serial_cfg = serial_cfg + | |
1773 ((uart_id + 1) << (12 - (4 * SER_LAYER_1))); | |
1774 break; | |
1775 | |
1776 case FD_AT_COMMAND: | |
1777 serial_cfg = serial_cfg + | |
1778 ((uart_id + 1) << (12 - (4 * SER_FAX_DATA))); | |
1779 break; | |
1780 | |
1781 case BLUETOOTH_HCI: | |
1782 serial_cfg = serial_cfg + | |
1783 ((uart_id + 1) << (12 - (4 * SER_BLUETOOTH_HCI))); | |
1784 break; | |
1785 | |
1786 case DUMMY: | |
1787 break; | |
1788 } | |
1789 } | |
1790 | |
1791 current_config = serial_cfg; | |
1792 valid_config_selected = 0; | |
1793 nb_allowed_config = serial_info->num_config; | |
1794 | |
1795 /* | |
1796 * Checks if the current serial config is one of the allowed. | |
1797 */ | |
1798 | |
1799 while ((nb_allowed_config > 0) && !valid_config_selected) { | |
1800 | |
1801 nb_allowed_config--; | |
1802 allowed_config = (SYS_UWORD16 *) | |
1803 &(serial_info->allowed_config[nb_allowed_config]); | |
1804 | |
1805 if (*pt_current_config == *allowed_config) | |
1806 valid_config_selected = 1; | |
1807 } | |
1808 | |
1809 /* | |
1810 * If not, the default configuration is selected. | |
1811 */ | |
1812 | |
1813 if (!valid_config_selected) { | |
1814 | |
1815 pt_current_config = (SYS_UWORD16 *)&(serial_info->default_config); | |
1816 | |
1817 #if (defined BTEMOBILE && (CHIPSET != 12)) | |
1818 /* | |
1819 * Setup the global variable accordingly. | |
1820 * The following default value are identical to the ones defined at | |
1821 * the application initialization in init.c. | |
1822 */ | |
1823 | |
1824 #ifdef BT_UART_USED_MODEM | |
1825 memcpy (ser_cfg_info, "RB", NUMBER_OF_TR_UART); | |
1826 #else | |
1827 memcpy (ser_cfg_info, "BR", NUMBER_OF_TR_UART); | |
1828 #endif | |
1829 #endif | |
1830 } | |
1831 | |
1832 /* | |
1833 * The serial data flow functions set is initialized. | |
1834 */ | |
1835 | |
1836 flow = 0; | |
1837 while (flow < SER_MAX_NUMBER_OF_FLOWS) { | |
1838 | |
1839 serial_driver = (T_SerialDriver) | |
1840 (((*pt_current_config) >> (12 - flow * 4)) & 0x000F); | |
1841 | |
1842 set_flow_functions (flow, serial_driver); | |
1843 flow++; | |
1844 } | |
1845 | |
1846 /* | |
1847 * Checks if both UARTs are used. | |
1848 * If not, performs minimum initialization including Sleep Mode. | |
1849 * Checks also if at least one UART is used by a Trace flow. | |
1850 * If so, create a HISR in order to reset and restart the sleep timer | |
1851 * in case of incoming characters. | |
1852 */ | |
1853 | |
1854 uart_used = 0; | |
1855 uart_used_for_trace = 0; | |
1856 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { | |
1857 | |
1858 if (!(int_uart[uart_id].device_used)) | |
1859 initialize_uart_sleep (uart_id); | |
1860 | |
1861 else { /* if (int_uart[uart_id].device_used) */ | |
1862 | |
1863 uart_used = 1; /* At least one UART is used */ | |
1864 | |
1865 if (int_uart[uart_id].flow_type == TRACE_FLOW) { | |
1866 | |
1867 /* At least one UART used by a Trace flow */ | |
1868 uart_used_for_trace = 1; | |
1869 } | |
1870 } | |
1871 } | |
1872 | |
1873 /* | |
1874 * If at least one uart is used, create a timer to figure out if the system | |
1875 * can enter deep sleep mode regarding the UARTs. | |
1876 */ | |
1877 | |
1878 if (uart_used) { | |
1879 | |
1880 (void) NU_Create_Timer ( | |
1881 &uart_sleep_timer, | |
1882 "Sleep", | |
1883 &analyze_uart_sleep_timer_expiration, | |
1884 0, /* Parameter supplied to the routine: not used. */ | |
1885 WAKE_UP_TIME_IN_TDMA, | |
1886 0, /* The timer expires once. */ | |
1887 NU_DISABLE_TIMER); | |
1888 | |
1889 /* | |
1890 * If at least one uart is used by a Trace flow, create a HISR to reset | |
1891 * and restart the sleep timer. | |
1892 */ | |
1893 | |
1894 if (uart_used_for_trace) { | |
1895 | |
1896 /* | |
1897 * The stack is entirely filled with the pattern 0xFE. | |
1898 */ | |
1899 | |
1900 memset (&(timer_hisr_stack[0]), 0xFE, TIMER_HISR_STACK_SIZE); | |
1901 | |
1902 /* | |
1903 * The HISR entry function is the same function than the one called | |
1904 * by the Rx HISR of the UARTFAX, since the only aim is to reset | |
1905 * and restart the sleep timer in case of incoming characters on | |
1906 * the Trace UART. | |
1907 */ | |
1908 | |
1909 (void) NU_Create_HISR ( | |
1910 &timer_hisr_ctrl_block, | |
1911 "Tim_HISR", | |
1912 SER_restart_uart_sleep_timer, | |
1913 TIMER_HISR_PRIORITY, | |
1914 &(timer_hisr_stack[0]), | |
1915 TIMER_HISR_STACK_SIZE); | |
1916 } | |
1917 } | |
1918 } | |
1919 | |
1920 | |
1921 /******************************************************************************* | |
1922 * | |
1923 * SER_WriteConfig | |
1924 * | |
1925 * Purpose: TBD | |
1926 * | |
1927 * Parameters: In : new_config: TBD | |
1928 * write_to_flash: TBD | |
1929 * Out: none | |
1930 * | |
1931 * Return: 0 (FALSE) : In case of error while trying to write file in FFS | |
1932 * >= 1 (TRUE) : Successful operation. | |
1933 * | |
1934 ******************************************************************************/ | |
1935 | |
1936 SYS_BOOL | |
1937 SER_WriteConfig (char *new_config, | |
1938 SYS_BOOL write_to_flash) | |
1939 { | |
1940 #ifdef SERIAL_DYNAMIC_SWITCH | |
1941 int uart_id; | |
1942 SYS_BOOL status = 1; | |
1943 | |
1944 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) | |
1945 ser_new_cfg[uart_id] = *new_config++; | |
1946 | |
1947 /* | |
1948 * Write in flash the new serial configuration if requested. | |
1949 */ | |
1950 | |
1951 if (write_to_flash) { | |
1952 if (ffs_fwrite (uart_config_file, | |
1953 ser_new_cfg, | |
1954 NUMBER_OF_TR_UART) < EFFS_OK) { | |
1955 status = 0; | |
1956 } | |
1957 } | |
1958 | |
1959 return (status); | |
1960 #else | |
1961 /* | |
1962 * Real Dynamic Switch is only available with Bluetooth AND all chips but | |
1963 * Calypso+. | |
1964 */ | |
1965 | |
1966 return (1); | |
1967 #endif | |
1968 } | |
1969 | |
1970 /******************************************************************************* | |
1971 * | |
1972 * SER_ImmediateSwitch | |
1973 * | |
1974 * Purpose: TBD | |
1975 * | |
1976 * Parameters: In : none | |
1977 * Out: none | |
1978 * | |
1979 * Return: 0 (FALSE) : In case of error. | |
1980 * >= 1 (TRUE) : Successful operation. | |
1981 * | |
1982 ******************************************************************************/ | |
1983 | |
1984 SYS_BOOL | |
1985 SER_ImmediateSwitch (void) | |
1986 { | |
1987 #ifdef SERIAL_DYNAMIC_SWITCH | |
1988 int uart_id; | |
1989 SYS_BOOL valid_config = 0; | |
1990 T_AppliSerialInfo *serial_info = &appli_ser_cfg_info; | |
1991 SYS_UWORD8 nb_allowed_config = serial_info->num_config; | |
1992 SYS_UWORD16 *allowed_config; | |
1993 int flow; | |
1994 T_SerialDriver serial_flows[SER_MAX_NUMBER_OF_FLOWS]; | |
1995 T_tr_UartId uart_nb; | |
1996 | |
1997 /* | |
1998 * First check if the new serial configuration is actually different from | |
1999 * the previous one. A return is used to simplify the code. | |
2000 */ | |
2001 | |
2002 if (!memcmp (ser_new_cfg, | |
2003 ser_cfg_info, | |
2004 NUMBER_OF_TR_UART)) | |
2005 return (1); /* new config and old config are identical => nothing to do */ | |
2006 | |
2007 /* | |
2008 * Then check if the new serial config is valid or not. | |
2009 * At that point, we assume that a serial config is valid if and only if the | |
2010 * Bluetooth HCI flow is still enabled and still uses the same UART. | |
2011 * Reset the current serial config, and compute the new one. | |
2012 */ | |
2013 | |
2014 serial_cfg = 0x0048; /* All dummies */ | |
2015 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { | |
2016 | |
2017 switch (ser_new_cfg[uart_id]) { | |
2018 | |
2019 case G23_PANEL: | |
2020 serial_cfg = serial_cfg + | |
2021 ((uart_id + 1) << (12 - (4 * SER_PROTOCOL_STACK))); | |
2022 break; | |
2023 | |
2024 case RIVIERA_TRACE_MUX: | |
2025 serial_cfg = serial_cfg + | |
2026 ((uart_id + 1) << (12 - (4 * SER_LAYER_1))); | |
2027 break; | |
2028 | |
2029 case FD_AT_COMMAND: | |
2030 serial_cfg = serial_cfg + | |
2031 ((uart_id + 1) << (12 - (4 * SER_FAX_DATA))); | |
2032 break; | |
2033 | |
2034 case BLUETOOTH_HCI: | |
2035 serial_cfg = serial_cfg + | |
2036 ((uart_id + 1) << (12 - (4 * SER_BLUETOOTH_HCI))); | |
2037 | |
2038 #if 0 | |
2039 /* | |
2040 * Check if the Bluetooth HCI flow is enabled on the same UART. | |
2041 */ | |
2042 | |
2043 if (ser_cfg_info[uart_id] == BLUETOOTH_HCI) | |
2044 valid_config = 1; | |
2045 #endif | |
2046 | |
2047 break; | |
2048 | |
2049 case DUMMY: | |
2050 break; | |
2051 } | |
2052 } | |
2053 | |
2054 #if 0 | |
2055 if (!valid_config) | |
2056 return (0); /* Bluetooth HCI flow not enabled in the new serial config, | |
2057 or enabled but using a different UART. */ | |
2058 #endif | |
2059 | |
2060 /* | |
2061 * Finally check if the new serial config is allowed by the application. | |
2062 */ | |
2063 | |
2064 valid_config = 0; | |
2065 while ((nb_allowed_config > 0) && !valid_config) { | |
2066 | |
2067 nb_allowed_config--; | |
2068 allowed_config = (SYS_UWORD16 *) | |
2069 &(serial_info->allowed_config[nb_allowed_config]); | |
2070 | |
2071 if (serial_cfg == *allowed_config) | |
2072 valid_config = 1; | |
2073 } | |
2074 | |
2075 if (!valid_config) /* the new config is not allowed by the application */ | |
2076 return (0); | |
2077 | |
2078 /* | |
2079 * From now on, Dynamic Switch is being processed. | |
2080 */ | |
2081 | |
2082 dynamic_switch = 1; | |
2083 | |
2084 /* | |
2085 * Disable UART interrupts until new serial config setup is complete. | |
2086 */ | |
2087 | |
2088 #if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11)) | |
2089 IQ_Mask (IQ_UART_IRDA_IT); | |
2090 #endif | |
2091 IQ_Mask (IQ_UART_IT); | |
2092 | |
2093 /* | |
2094 * Reset UARTs set-up. | |
2095 */ | |
2096 | |
2097 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { | |
2098 | |
2099 int_uart[uart_id].device_used = 0; | |
2100 int_uart[uart_id].deep_sleep_set_up = 0; | |
2101 int_uart[uart_id].interrupt_handler = NULL; | |
2102 } | |
2103 | |
2104 /* | |
2105 * All function pointers are set to dummy functions. | |
2106 */ | |
2107 | |
2108 rvf_disable (21); /* beginning of the critical section */ | |
2109 | |
2110 for (flow = 0; flow < SER_MAX_NUMBER_OF_FLOWS; flow++) | |
2111 tr_functions[flow] = &dummy_trace; | |
2112 | |
2113 fd_functions = &dummy_fax_data; | |
2114 #ifdef BTEMOBILE | |
2115 bt_functions = &dummy_bt_hci; | |
2116 #endif | |
2117 | |
2118 rvf_enable (); /* end of the critical section */ | |
2119 | |
2120 /* | |
2121 * Calls the Exit function of the UARTFAX driver if it was previously used. | |
2122 */ | |
2123 | |
2124 if (uart_fd_initialized) { | |
2125 | |
2126 /* | |
2127 * UART IrDA can't be used for F&D/AT-Cmd flow => UART Modem was used | |
2128 * by the F&D/AT-Cmd flow. | |
2129 */ | |
2130 | |
2131 if (UAF_Exit (UAF_UART_1) == FD_OK) { | |
2132 uart_fd_initialized = 0; | |
2133 } | |
2134 } | |
2135 #if 0 | |
2136 else { | |
2137 | |
2138 /* | |
2139 * AT that point, since the Bluetooth HCI flow already uses one UART, | |
2140 * and since the second UART was not used by the F&D/AT-Cmd flow, we | |
2141 * assume it was used by a Trace flow. Therefore, the HISR used to | |
2142 * reset and restart the sleep timer is deleted. | |
2143 */ | |
2144 | |
2145 (void) NU_Delete_HISR (&timer_hisr_ctrl_block); | |
2146 } | |
2147 #endif | |
2148 | |
2149 /* | |
2150 * Initialization of the new flows (Only AT-Cmd/F&D or Riviera/Layer1 Trace) | |
2151 * and their associated UARTs HW (Irda or Modem) & SW (Trace or Fax&Data). | |
2152 */ | |
2153 | |
2154 for (flow = 0; flow < SER_MAX_NUMBER_OF_FLOWS; flow++) { | |
2155 | |
2156 serial_flows[flow] = (T_SerialDriver) | |
2157 ((serial_cfg >> (12 - flow * 4)) & 0x000F); | |
2158 | |
2159 switch (serial_flows[flow]) { | |
2160 | |
2161 /* | |
2162 * For Riviera/Layer1 Trace flow, default baudrate is 115200 bps | |
2163 * and callback function is defined in rvt_def_i.h. | |
2164 */ | |
2165 | |
2166 case UART_IRDA_TRACE: | |
2167 case UART_MODEM_TRACE: | |
2168 | |
2169 if (serial_flows[flow] == UART_IRDA_TRACE) | |
2170 uart_nb = UA_UART_0; | |
2171 else /* if (serial_flows[flow] == UART_MODEM_TRACE) */ | |
2172 uart_nb = UA_UART_1; | |
2173 | |
2174 if (flow == SER_LAYER_1) { | |
2175 | |
2176 UA_Init (uart_nb, | |
2177 TR_BAUD_CONFIG, | |
2178 rvt_activate_RX_HISR); | |
2179 | |
2180 #if 0 | |
2181 /* | |
2182 * Create the HISR used to reset and restart the sleep | |
2183 * timer in case of incoming characters on the Trace flow. | |
2184 * The stack is entirely filled with the pattern 0xFE. | |
2185 */ | |
2186 | |
2187 memset (&(timer_hisr_stack[0]), | |
2188 0xFE, | |
2189 TIMER_HISR_STACK_SIZE); | |
2190 | |
2191 (void) NU_Create_HISR ( | |
2192 &timer_hisr_ctrl_block, | |
2193 "Tim_HISR", | |
2194 SER_restart_uart_sleep_timer, | |
2195 TIMER_HISR_PRIORITY, | |
2196 &(timer_hisr_stack[0]), | |
2197 TIMER_HISR_STACK_SIZE); | |
2198 #endif | |
2199 } | |
2200 else /* Other Trace flows are disabled */ | |
2201 initialize_uart_sleep (uart_nb); | |
2202 break; | |
2203 | |
2204 /* | |
2205 * For At-Cmd/F&D flow, functions are called in the appropriate | |
2206 * order with the saved parameters. | |
2207 * This has been figured out from the G23 initialization. | |
2208 */ | |
2209 | |
2210 case UART_MODEM_FAX_DATA: | |
2211 | |
2212 /* Global Initialization */ | |
2213 if (UAF_Init (UAF_UART_1) == FD_OK) { | |
2214 uart_fd_initialized = 1; | |
2215 } | |
2216 | |
2217 /* Disable the driver */ | |
2218 UAF_Enable (UAF_UART_1, | |
2219 0); | |
2220 | |
2221 /* Set the SW Buffers parameters */ | |
2222 UAF_SetBuffer (UAF_UART_1, | |
2223 data_flow_parameters.bufSize, | |
2224 data_flow_parameters.rxThreshold, | |
2225 data_flow_parameters.txThreshold); | |
2226 | |
2227 /* Set the Escape Sequence parameters (1st call) */ | |
2228 UAF_SetEscape (UAF_UART_1, | |
2229 data_flow_parameters.escChar[0], | |
2230 data_flow_parameters.guardPeriod[0]); | |
2231 | |
2232 /* Set the Communication parameters (1st call) */ | |
2233 UAF_SetComPar (UAF_UART_1, | |
2234 data_flow_parameters.baudrate[0], | |
2235 data_flow_parameters.bpc[0], | |
2236 data_flow_parameters.sb[0], | |
2237 data_flow_parameters.parity[0]); | |
2238 | |
2239 /* Set the Flow Control parameters (1st call) */ | |
2240 UAF_SetFlowCtrl (UAF_UART_1, | |
2241 data_flow_parameters.fcMode[0], | |
2242 data_flow_parameters.XON[0], | |
2243 data_flow_parameters.XOFF[0]); | |
2244 | |
2245 /* Set the Communication parameters (2nd call) */ | |
2246 UAF_SetComPar (UAF_UART_1, | |
2247 data_flow_parameters.baudrate[1], | |
2248 data_flow_parameters.bpc[1], | |
2249 data_flow_parameters.sb[1], | |
2250 data_flow_parameters.parity[1]); | |
2251 | |
2252 /* Set the Flow Control parameters (2nd call) */ | |
2253 UAF_SetFlowCtrl (UAF_UART_1, | |
2254 data_flow_parameters.fcMode[1], | |
2255 data_flow_parameters.XON[1], | |
2256 data_flow_parameters.XOFF[1]); | |
2257 | |
2258 /* Set the Escape Sequence parameters (2nd call) */ | |
2259 UAF_SetEscape (UAF_UART_1, | |
2260 data_flow_parameters.escChar[1], | |
2261 data_flow_parameters.guardPeriod[1]); | |
2262 | |
2263 /* Enable the driver */ | |
2264 UAF_Enable (UAF_UART_1, | |
2265 1); | |
2266 | |
2267 /* Get the number of input bytes available */ | |
2268 UAF_InpAvail (UAF_UART_1); | |
2269 | |
2270 /* Set the readOutFunc and the suspend mode */ | |
2271 UAF_ReadData (UAF_UART_1, | |
2272 data_flow_parameters.suspend_rd, | |
2273 data_flow_parameters.readOutFunc); | |
2274 | |
2275 /* Get the number of output bytes available (1st call) */ | |
2276 UAF_OutpAvail (UAF_UART_1); | |
2277 | |
2278 /* Set the states of the V.24 status lines (1st call) */ | |
2279 UAF_SetLineState (UAF_UART_1, | |
2280 data_flow_parameters.state[0], | |
2281 data_flow_parameters.mask[0]); | |
2282 | |
2283 /* Set the states of the V.24 status lines (2nd call) */ | |
2284 UAF_SetLineState (UAF_UART_1, | |
2285 data_flow_parameters.state[1], | |
2286 data_flow_parameters.mask[1]); | |
2287 | |
2288 /* Set the states of the V.24 status lines (3rd call) */ | |
2289 UAF_SetLineState (UAF_UART_1, | |
2290 data_flow_parameters.state[2], | |
2291 data_flow_parameters.mask[2]); | |
2292 | |
2293 /* Set the states of the V.24 status lines (4th call) */ | |
2294 UAF_SetLineState (UAF_UART_1, | |
2295 data_flow_parameters.state[3], | |
2296 data_flow_parameters.mask[3]); | |
2297 | |
2298 /* Set the writeInFunc and the suspend mode */ | |
2299 UAF_WriteData (UAF_UART_1, | |
2300 data_flow_parameters.suspend_wr, | |
2301 data_flow_parameters.writeInFunc); | |
2302 | |
2303 /* Get the number of output bytes available (2nd call) */ | |
2304 UAF_OutpAvail (UAF_UART_1); | |
2305 | |
2306 break; | |
2307 | |
2308 case UART_IRDA_BT_HCI: | |
2309 case UART_MODEM_BT_HCI: | |
2310 /* | |
2311 * Nothing to initialize for Bluetooth HCI flow since it does | |
2312 * use the same UART. | |
2313 */ | |
2314 | |
2315 case DUMMY_TRACE: | |
2316 case DUMMY_FAX_DATA: | |
2317 case DUMMY_BT_HCI: | |
2318 /* | |
2319 * Of course nothing to perform for Dummy flows. | |
2320 */ | |
2321 | |
2322 break; | |
2323 } | |
2324 } | |
2325 | |
2326 /* | |
2327 * All function pointers are set to the appropriate functions set. | |
2328 */ | |
2329 | |
2330 for (flow = 0; flow < SER_MAX_NUMBER_OF_FLOWS; flow++){ | |
2331 | |
2332 /* | |
2333 * For Dummy flows, pointers to dummy functions are already set. | |
2334 */ | |
2335 | |
2336 if ((serial_flows[flow] != DUMMY_TRACE) && | |
2337 (serial_flows[flow] != DUMMY_FAX_DATA) && | |
2338 (serial_flows[flow] != DUMMY_BT_HCI)) { | |
2339 | |
2340 rvf_disable (21); /* beginning of the critical section */ | |
2341 set_flow_functions (flow, serial_flows[flow]); | |
2342 rvf_enable (); /* end of the critical section */ | |
2343 } | |
2344 } | |
2345 | |
2346 /* | |
2347 * Dynamic Switch has been processed. | |
2348 * The new serial config is actually stored. | |
2349 */ | |
2350 | |
2351 dynamic_switch = 0; | |
2352 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) | |
2353 ser_cfg_info[uart_id] = ser_new_cfg[uart_id]; | |
2354 | |
2355 /* | |
2356 * Re-enable UART interrupts. | |
2357 */ | |
2358 | |
2359 #if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11)) | |
2360 IQ_Unmask (IQ_UART_IRDA_IT); | |
2361 #endif | |
2362 IQ_Unmask (IQ_UART_IT); | |
2363 | |
2364 #endif | |
2365 /* | |
2366 * Real Dynamic Switch is only available with Bluetooth AND all chips but | |
2367 * Calypso+. | |
2368 */ | |
2369 | |
2370 return (1); | |
2371 } | |
2372 | |
2373 /******************************************************************************* | |
2374 * | |
2375 * All functions SER_tr_xxx and SER_fd_xxx call a function of the UART trace | |
2376 * driver or the UART fax & data driver. | |
2377 * All functions SER_bt_xxx call a function of the UART Bluetooth HCI driver. | |
2378 * See the function call for parameters and return values. | |
2379 * | |
2380 ******************************************************************************/ | |
2381 | |
2382 void | |
2383 SER_tr_Init (int serial_data_flow, | |
2384 T_tr_Baudrate baudrate, | |
2385 void (callback_function (void))) | |
2386 { | |
2387 tr_functions[serial_data_flow]->tr_Init ( | |
2388 tr_functions[serial_data_flow]->device, baudrate, callback_function); | |
2389 } | |
2390 | |
2391 SYS_UWORD32 | |
2392 SER_tr_ReadNChars (int serial_data_flow, | |
2393 char *buffer, | |
2394 SYS_UWORD32 chars_to_read) | |
2395 { | |
2396 return (tr_functions[serial_data_flow]->tr_ReadNChars ( | |
2397 tr_functions[serial_data_flow]->device, buffer, chars_to_read)); | |
2398 } | |
2399 | |
2400 SYS_UWORD32 | |
2401 SER_tr_ReadNBytes (int serial_data_flow, | |
2402 char *buffer, | |
2403 SYS_UWORD32 chars_to_read, | |
2404 SYS_BOOL *eof_detected) | |
2405 { | |
2406 return (tr_functions[serial_data_flow]->tr_ReadNBytes ( | |
2407 tr_functions[serial_data_flow]->device, buffer, chars_to_read, eof_detected)); | |
2408 } | |
2409 | |
2410 SYS_UWORD32 | |
2411 SER_tr_WriteNChars (int serial_data_flow, | |
2412 char *buffer, | |
2413 SYS_UWORD32 chars_to_write) | |
2414 { | |
2415 return (tr_functions[serial_data_flow]->tr_WriteNChars ( | |
2416 tr_functions[serial_data_flow]->device, buffer, chars_to_write)); | |
2417 } | |
2418 | |
2419 SYS_UWORD32 | |
2420 SER_tr_EncapsulateNChars (int serial_data_flow, | |
2421 char *buffer, | |
2422 SYS_UWORD32 chars_to_write) | |
2423 { | |
2424 return (tr_functions[serial_data_flow]->tr_EncapsulateNChars ( | |
2425 tr_functions[serial_data_flow]->device, buffer, chars_to_write)); | |
2426 } | |
2427 | |
2428 SYS_UWORD32 | |
2429 SER_tr_WriteNBytes (int serial_data_flow, | |
2430 SYS_UWORD8 *buffer, | |
2431 SYS_UWORD32 chars_to_write) | |
2432 { | |
2433 return (tr_functions[serial_data_flow]->tr_WriteNBytes ( | |
2434 tr_functions[serial_data_flow]->device, buffer, chars_to_write)); | |
2435 } | |
2436 | |
2437 void | |
2438 SER_tr_WriteChar (int serial_data_flow, | |
2439 char character) | |
2440 { | |
2441 tr_functions[serial_data_flow]->tr_WriteChar ( | |
2442 tr_functions[serial_data_flow]->device, character); | |
2443 } | |
2444 | |
2445 void | |
2446 SER_tr_WriteString (int serial_data_flow, | |
2447 char *buffer) | |
2448 { | |
2449 tr_functions[serial_data_flow]->tr_WriteString ( | |
2450 tr_functions[serial_data_flow]->device, buffer); | |
2451 } | |
2452 | |
2453 SYS_BOOL | |
2454 SER_tr_EnterSleep (int serial_data_flow) | |
2455 { | |
2456 return (tr_functions[serial_data_flow]->tr_EnterSleep ( | |
2457 tr_functions[serial_data_flow]->device)); | |
2458 } | |
2459 | |
2460 void | |
2461 SER_tr_WakeUp (int serial_data_flow) | |
2462 { | |
2463 tr_functions[serial_data_flow]->tr_WakeUp ( | |
2464 tr_functions[serial_data_flow]->device); | |
2465 } | |
2466 | |
2467 /* Dummy function for backward compatibility. */ | |
2468 T_FDRET | |
2469 SER_fd_Init (void) | |
2470 { | |
2471 return (FD_OK); | |
2472 } | |
2473 | |
2474 T_FDRET | |
2475 SER_fd_Initialize (void) | |
2476 { | |
2477 T_FDRET status; | |
2478 | |
2479 #ifdef SERIAL_DYNAMIC_SWITCH | |
2480 data_flow_parameters.bufSize = FD_MAX_BUFFER_SIZE; | |
2481 #else | |
2482 bufSize = FD_MAX_BUFFER_SIZE; | |
2483 #endif | |
2484 status = fd_functions->fd_Initialize (fd_functions->device); | |
2485 | |
2486 #ifdef SERIAL_DYNAMIC_SWITCH | |
2487 /* | |
2488 * Check if the UARTFAX driver has actually been initialized. | |
2489 */ | |
2490 | |
2491 if ((fd_functions->fd_Initialize == UAF_Init) && | |
2492 (status = FD_OK)) { | |
2493 | |
2494 uart_fd_initialized = 1; | |
2495 } | |
2496 #endif | |
2497 | |
2498 return (status); | |
2499 } | |
2500 | |
2501 T_FDRET | |
2502 SER_fd_Enable (SYS_BOOL enable) | |
2503 { | |
2504 return (fd_functions->fd_Enable (fd_functions->device, enable)); | |
2505 } | |
2506 | |
2507 T_FDRET | |
2508 SER_fd_SetComPar (T_baudrate baudrate, | |
2509 T_bitsPerCharacter bpc, | |
2510 T_stopBits sb, | |
2511 T_parity parity) | |
2512 { | |
2513 | |
2514 #ifdef SERIAL_DYNAMIC_SWITCH | |
2515 if (fd_UAF_SetComPar < 2) { | |
2516 | |
2517 /* | |
2518 * Stores the parameters in order to be able to retrieve them in case of | |
2519 * Dynamic Sitch. | |
2520 */ | |
2521 | |
2522 data_flow_parameters.baudrate[fd_UAF_SetComPar] = baudrate; | |
2523 data_flow_parameters.bpc[fd_UAF_SetComPar] = bpc; | |
2524 data_flow_parameters.sb[fd_UAF_SetComPar] = sb; | |
2525 data_flow_parameters.parity[fd_UAF_SetComPar] = parity; | |
2526 | |
2527 /* | |
2528 * Number of calls to SER_fd_SetComPar. | |
2529 */ | |
2530 | |
2531 fd_UAF_SetComPar++; | |
2532 } | |
2533 #endif | |
2534 | |
2535 return (fd_functions->fd_SetComPar ( | |
2536 fd_functions->device, baudrate, bpc, sb, parity)); | |
2537 } | |
2538 | |
2539 T_FDRET | |
2540 SER_fd_SetBuffer (SYS_UWORD16 bufSize, | |
2541 SYS_UWORD16 rxThreshold, | |
2542 SYS_UWORD16 txThreshold) | |
2543 { | |
2544 | |
2545 #ifdef SERIAL_DYNAMIC_SWITCH | |
2546 if (fd_UAF_SetBuffer < 1) { | |
2547 | |
2548 /* | |
2549 * Stores the parameters in order to be able to retrieve them in case of | |
2550 * Dynamic Sitch. | |
2551 */ | |
2552 | |
2553 data_flow_parameters.bufSize = bufSize; | |
2554 data_flow_parameters.rxThreshold = rxThreshold; | |
2555 data_flow_parameters.txThreshold = txThreshold; | |
2556 | |
2557 /* | |
2558 * Number of calls to SER_fd_SetBuffer. | |
2559 */ | |
2560 | |
2561 fd_UAF_SetBuffer++; | |
2562 } | |
2563 #endif | |
2564 | |
2565 return (fd_functions->fd_SetBuffer ( | |
2566 fd_functions->device, bufSize, rxThreshold, txThreshold)); | |
2567 } | |
2568 | |
2569 T_FDRET | |
2570 SER_fd_SetFlowCtrl (T_flowCtrlMode fcMode, | |
2571 SYS_UWORD8 XON, | |
2572 SYS_UWORD8 XOFF) | |
2573 { | |
2574 | |
2575 #ifdef SERIAL_DYNAMIC_SWITCH | |
2576 if (fd_UAF_SetFlowCtrl < 2) { | |
2577 | |
2578 /* | |
2579 * Stores the parameters in order to be able to retrieve them in case of | |
2580 * Dynamic Sitch. | |
2581 */ | |
2582 | |
2583 data_flow_parameters.fcMode[fd_UAF_SetFlowCtrl] = fcMode; | |
2584 data_flow_parameters.XON[fd_UAF_SetFlowCtrl] = XON; | |
2585 data_flow_parameters.XOFF[fd_UAF_SetFlowCtrl] = XOFF; | |
2586 | |
2587 /* | |
2588 * Number of calls to SER_fd_SetFlowCtrl. | |
2589 */ | |
2590 | |
2591 fd_UAF_SetFlowCtrl++; | |
2592 } | |
2593 #endif | |
2594 | |
2595 return (fd_functions->fd_SetFlowCtrl ( | |
2596 fd_functions->device, fcMode, XON, XOFF)); | |
2597 } | |
2598 | |
2599 T_FDRET | |
2600 SER_fd_SetEscape (char escChar, | |
2601 SYS_UWORD16 guardPeriod) | |
2602 { | |
2603 | |
2604 #ifdef SERIAL_DYNAMIC_SWITCH | |
2605 if (fd_UAF_SetEscape < 2) { | |
2606 | |
2607 /* | |
2608 * Stores the parameters in order to be able to retrieve them in case of | |
2609 * Dynamic Sitch. | |
2610 */ | |
2611 | |
2612 data_flow_parameters.escChar[fd_UAF_SetEscape] = escChar; | |
2613 data_flow_parameters.guardPeriod[fd_UAF_SetEscape] = guardPeriod; | |
2614 | |
2615 /* | |
2616 * Number of calls to SER_fd_SetEscape. | |
2617 */ | |
2618 | |
2619 fd_UAF_SetEscape++; | |
2620 } | |
2621 #endif | |
2622 | |
2623 return (fd_functions->fd_SetEscape ( | |
2624 fd_functions->device, escChar, guardPeriod)); | |
2625 } | |
2626 | |
2627 T_FDRET | |
2628 SER_fd_InpAvail (void) | |
2629 { | |
2630 return (fd_functions->fd_InpAvail (fd_functions->device)); | |
2631 } | |
2632 | |
2633 T_FDRET | |
2634 SER_fd_OutpAvail (void) | |
2635 { | |
2636 return (fd_functions->fd_OutpAvail (fd_functions->device)); | |
2637 } | |
2638 | |
2639 T_FDRET | |
2640 SER_fd_EnterSleep (void) | |
2641 { | |
2642 return (fd_functions->fd_EnterSleep (fd_functions->device)); | |
2643 } | |
2644 | |
2645 T_FDRET | |
2646 SER_fd_WakeUp (void) | |
2647 { | |
2648 return (fd_functions->fd_WakeUp (fd_functions->device)); | |
2649 } | |
2650 | |
2651 T_FDRET | |
2652 SER_fd_ReadData (T_suspendMode suspend, | |
2653 void (readOutFunc (SYS_BOOL cldFromIrq, | |
2654 T_reInstMode *reInstall, | |
2655 SYS_UWORD8 nsource, | |
2656 SYS_UWORD8 *source[], | |
2657 SYS_UWORD16 size[], | |
2658 SYS_UWORD32 state))) | |
2659 { | |
2660 | |
2661 #ifdef SERIAL_DYNAMIC_SWITCH | |
2662 if (fd_UAF_ReadData < 1) { | |
2663 | |
2664 /* | |
2665 * Stores the parameters in order to be able to retrieve them in case of | |
2666 * Dynamic Sitch. | |
2667 */ | |
2668 | |
2669 data_flow_parameters.suspend_rd = suspend; | |
2670 data_flow_parameters.readOutFunc = readOutFunc; | |
2671 | |
2672 /* | |
2673 * Number of calls to SER_fd_ReadData. | |
2674 */ | |
2675 | |
2676 fd_UAF_ReadData++; | |
2677 } | |
2678 #endif | |
2679 | |
2680 return (fd_functions->fd_ReadData ( | |
2681 fd_functions->device, suspend, readOutFunc)); | |
2682 } | |
2683 | |
2684 T_FDRET | |
2685 SER_fd_WriteData (T_suspendMode suspend, | |
2686 void (writeInFunc (SYS_BOOL cldFromIrq, | |
2687 T_reInstMode *reInstall, | |
2688 SYS_UWORD8 ndest, | |
2689 SYS_UWORD8 *dest[], | |
2690 SYS_UWORD16 size[]))) | |
2691 { | |
2692 | |
2693 #ifdef SERIAL_DYNAMIC_SWITCH | |
2694 if (fd_UAF_WriteData < 1) { | |
2695 | |
2696 /* | |
2697 * Stores the parameters in order to be able to retrieve them in case of | |
2698 * Dynamic Sitch. | |
2699 */ | |
2700 | |
2701 data_flow_parameters.suspend_wr = suspend; | |
2702 data_flow_parameters.writeInFunc = writeInFunc; | |
2703 | |
2704 /* | |
2705 * Number of calls to SER_fd_WriteData. | |
2706 */ | |
2707 | |
2708 fd_UAF_WriteData++; | |
2709 } | |
2710 #endif | |
2711 | |
2712 return (fd_functions->fd_WriteData ( | |
2713 fd_functions->device, suspend, writeInFunc)); | |
2714 } | |
2715 | |
2716 T_FDRET | |
2717 SER_fd_StopRec (void) | |
2718 { | |
2719 return (fd_functions->fd_StopRec (fd_functions->device)); | |
2720 } | |
2721 | |
2722 T_FDRET | |
2723 SER_fd_StartRec (void) | |
2724 { | |
2725 return (fd_functions->fd_StartRec (fd_functions->device)); | |
2726 } | |
2727 | |
2728 T_FDRET | |
2729 SER_fd_GetLineState (SYS_UWORD32 *state) | |
2730 { | |
2731 return (fd_functions->fd_GetLineState (fd_functions->device, state)); | |
2732 } | |
2733 | |
2734 T_FDRET | |
2735 SER_fd_SetLineState (SYS_UWORD32 state, | |
2736 SYS_UWORD32 mask) | |
2737 { | |
2738 | |
2739 #ifdef SERIAL_DYNAMIC_SWITCH | |
2740 if (fd_UAF_SetLineState < 4) { | |
2741 | |
2742 /* | |
2743 * Stores the parameters in order to be able to retrieve them in case of | |
2744 * Dynamic Sitch. | |
2745 */ | |
2746 | |
2747 data_flow_parameters.state[fd_UAF_SetLineState] = state; | |
2748 data_flow_parameters.mask[fd_UAF_SetLineState] = mask; | |
2749 | |
2750 /* | |
2751 * Number of calls to SER_fd_SetLineState. | |
2752 */ | |
2753 | |
2754 fd_UAF_SetLineState++; | |
2755 } | |
2756 #endif | |
2757 | |
2758 return (fd_functions->fd_SetLineState (fd_functions->device, state, mask)); | |
2759 } | |
2760 | |
2761 T_FDRET | |
2762 SER_fd_CheckXEmpty (void) | |
2763 { | |
2764 return (fd_functions->fd_CheckXEmpty (fd_functions->device)); | |
2765 } | |
2766 | |
2767 #ifdef BTEMOBILE | |
2768 T_HCI_RET | |
2769 SER_bt_Init (void) | |
2770 { | |
2771 return (bt_functions->bt_Init (bt_functions->device)); | |
2772 } | |
2773 | |
2774 T_HCI_RET | |
2775 SER_bt_Start (void) | |
2776 { | |
2777 return (bt_functions->bt_Start ()); | |
2778 } | |
2779 | |
2780 T_HCI_RET | |
2781 SER_bt_Stop (void) | |
2782 { | |
2783 return (bt_functions->bt_Stop ()); | |
2784 } | |
2785 | |
2786 T_HCI_RET | |
2787 SER_bt_Kill (void) | |
2788 { | |
2789 return (bt_functions->bt_Kill ()); | |
2790 } | |
2791 | |
2792 T_HCI_RET | |
2793 SER_bt_SetBaudrate (UINT8 baudrate) | |
2794 { | |
2795 return (bt_functions->bt_SetBaudrate (baudrate)); | |
2796 } | |
2797 | |
2798 T_HCI_RET SER_bt_TransmitPacket (void *uart_tx_buffer) | |
2799 { | |
2800 return (bt_functions->bt_TransmitPacket (uart_tx_buffer)); | |
2801 } | |
2802 | |
2803 SYS_BOOL SER_bt_EnterSleep (void) | |
2804 { | |
2805 return (bt_functions->bt_EnterSleep()); | |
2806 } | |
2807 | |
2808 void SER_bt_WakeUp (void) | |
2809 { | |
2810 bt_functions->bt_WakeUp(); | |
2811 } | |
2812 #endif /* BTEMOBILE */ | |
2813 | |
2814 /******************************************************************************* | |
2815 * | |
2816 * SER_UartSleepStatus | |
2817 * | |
2818 * Purpose: This function checks if both UARTs are ready to enter Deep Sleep. | |
2819 * | |
2820 * Parameters: In : none | |
2821 * Out: none | |
2822 * | |
2823 * Return: 0 : Deep Sleep is not possible. | |
2824 * >= 1 : Deep Sleep is possible. | |
2825 * | |
2826 ******************************************************************************/ | |
2827 | |
2828 SYS_BOOL | |
2829 SER_UartSleepStatus (void) | |
2830 { | |
2831 t_uart *uart; | |
2832 int uart_id; | |
2833 SYS_BOOL status; | |
2834 | |
2835 /* | |
2836 * Check first if the sleep timer is active or if a Dynamic Switch is | |
2837 * being processed. A return is used to simplify the code. | |
2838 */ | |
2839 | |
2840 #ifdef SERIAL_DYNAMIC_SWITCH | |
2841 if (uart_sleep_timer_enabled || dynamic_switch) | |
2842 #else | |
2843 if (uart_sleep_timer_enabled) | |
2844 #endif | |
2845 return (0); | |
2846 | |
2847 /* | |
2848 * Check if both UARTs are ready to enter Deep Sleep. | |
2849 */ | |
2850 | |
2851 status = 1; | |
2852 uart_id = 0; | |
2853 while ((uart_id < NUMBER_OF_TR_UART) && | |
2854 (status)) { | |
2855 | |
2856 uart = &(int_uart[uart_id]); | |
2857 | |
2858 /* | |
2859 * Check if the specified UART is actually used. | |
2860 */ | |
2861 | |
2862 if (uart->device_used) { | |
2863 | |
2864 /* | |
2865 * Check if the specified UART is used by a Trace or | |
2866 * by a Fax & Data flow. | |
2867 */ | |
2868 | |
2869 if (uart->flow_type == TRACE_FLOW) | |
2870 status = SER_tr_EnterSleep (uart->flow_id); | |
2871 | |
2872 else | |
2873 if (uart->flow_type == FAX_DATA_FLOW) | |
2874 status = (SYS_BOOL) SER_fd_EnterSleep (); | |
2875 #ifdef BTEMOBILE | |
2876 else | |
2877 if (uart->flow_type == BLUETOOTH_HCI_FLOW) | |
2878 status = SER_bt_EnterSleep(); | |
2879 #endif | |
2880 else | |
2881 status = 0; | |
2882 | |
2883 if (status) { | |
2884 | |
2885 /* | |
2886 * The specified UART is now set up for Deep Sleep. | |
2887 */ | |
2888 | |
2889 uart->deep_sleep_set_up = 1; | |
2890 | |
2891 } | |
2892 } | |
2893 | |
2894 uart_id++; | |
2895 } | |
2896 | |
2897 /* | |
2898 * Check if Deep Sleep is finally possible. | |
2899 * If not revert eventual Deep Sleep settings. | |
2900 */ | |
2901 | |
2902 if (!status) { | |
2903 | |
2904 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { | |
2905 | |
2906 uart = &(int_uart[uart_id]); | |
2907 | |
2908 /* | |
2909 * If the specified used UART has already been set up for | |
2910 * Deep Sleep, revert these settings. | |
2911 */ | |
2912 | |
2913 if ((uart->device_used) && | |
2914 (uart->deep_sleep_set_up)) { | |
2915 | |
2916 /* | |
2917 * Check if the specified UART is used by a Trace or | |
2918 * by a Fax & Data flow. | |
2919 * Bluetooth HCI can not yet handled Deep Sleep Mode. | |
2920 */ | |
2921 | |
2922 if (uart->flow_type == TRACE_FLOW) | |
2923 SER_tr_WakeUp (uart->flow_id); | |
2924 | |
2925 else | |
2926 if (uart->flow_type == FAX_DATA_FLOW) | |
2927 SER_fd_WakeUp (); | |
2928 #ifdef BTEMOBILE | |
2929 else | |
2930 if (uart->flow_type == BLUETOOTH_HCI_FLOW) | |
2931 SER_bt_WakeUp (); | |
2932 #endif | |
2933 uart->deep_sleep_set_up = 0; | |
2934 | |
2935 } | |
2936 } | |
2937 } | |
2938 | |
2939 return (status); | |
2940 } | |
2941 | |
2942 | |
2943 /******************************************************************************* | |
2944 * | |
2945 * SER_WakeUpUarts | |
2946 * | |
2947 * Purpose: This function wakes up used UARTs after Deep Sleep. | |
2948 * | |
2949 * Parameters: In : none | |
2950 * Out: none | |
2951 * | |
2952 * Return: none | |
2953 * | |
2954 ******************************************************************************/ | |
2955 | |
2956 void | |
2957 SER_WakeUpUarts (void) | |
2958 { | |
2959 t_uart *uart; | |
2960 int uart_id; | |
2961 | |
2962 if (uart_sleep_timer_enabled) | |
2963 start_uart_sleep_timer (); | |
2964 | |
2965 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { | |
2966 | |
2967 uart = &(int_uart[uart_id]); | |
2968 | |
2969 /* | |
2970 * Check if the specified UART is actually used, and has not yet | |
2971 * been waked up. | |
2972 */ | |
2973 | |
2974 if ((uart->device_used) && | |
2975 (uart->deep_sleep_set_up)) { | |
2976 | |
2977 /* | |
2978 * Check if the specified UART is used by a Trace or | |
2979 * by a Fax & Data flow. | |
2980 * Bluetooth HCI can not yet handled Deep Sleep Mode. | |
2981 */ | |
2982 | |
2983 if (uart->flow_type == TRACE_FLOW) | |
2984 SER_tr_WakeUp (uart->flow_id); | |
2985 | |
2986 else | |
2987 if (uart->flow_type == FAX_DATA_FLOW) | |
2988 SER_fd_WakeUp (); | |
2989 #ifdef BTEMOBILE | |
2990 else | |
2991 if (uart->flow_type == BLUETOOTH_HCI_FLOW) | |
2992 SER_bt_WakeUp (); | |
2993 #endif | |
2994 /* | |
2995 * The specified UART is no more set up for Deep Sleep. | |
2996 */ | |
2997 | |
2998 uart->deep_sleep_set_up = 0; | |
2999 | |
3000 } | |
3001 } | |
3002 } | |
3003 | |
3004 | |
3005 /******************************************************************************* | |
3006 * | |
3007 * SER_restart_uart_sleep_timer | |
3008 * | |
3009 * Purpose : Resets and restarts the sleep timer each time some characters are | |
3010 * received. | |
3011 * | |
3012 * Arguments: In : none | |
3013 * Out: none | |
3014 * | |
3015 * Returns : none | |
3016 * | |
3017 ******************************************************************************/ | |
3018 | |
3019 void | |
3020 SER_restart_uart_sleep_timer (void) | |
3021 { | |
3022 /* | |
3023 * First disable the timer. | |
3024 */ | |
3025 | |
3026 (void) NU_Control_Timer (&uart_sleep_timer, | |
3027 NU_DISABLE_TIMER); | |
3028 | |
3029 /* | |
3030 * Then start again this timer for a new period. | |
3031 */ | |
3032 | |
3033 start_uart_sleep_timer (); | |
3034 } | |
3035 | |
3036 | |
3037 /******************************************************************************* | |
3038 * | |
3039 * SER_activate_timer_hisr | |
3040 * | |
3041 * Purpose : Activates the timer HISR to reset and restart the sleep timer | |
3042 * each time some characters are received. | |
3043 * | |
3044 * Arguments: In : none | |
3045 * Out: none | |
3046 * | |
3047 * Returns : none | |
3048 * | |
3049 ******************************************************************************/ | |
3050 | |
3051 void | |
3052 SER_activate_timer_hisr (void) | |
3053 { | |
3054 (void) NU_Activate_HISR (&timer_hisr_ctrl_block); | |
3055 } | |
3056 | |
3057 | |
3058 #if ((CHIPSET == 2) || (CHIPSET == 3)) | |
3059 | |
3060 /******************************************************************************* | |
3061 * | |
3062 * SER_uart_handler | |
3063 * | |
3064 * Purpose : UART interrupt handler. | |
3065 * | |
3066 * Arguments: In : none | |
3067 * Out: none | |
3068 * | |
3069 * Returns : none | |
3070 * | |
3071 ******************************************************************************/ | |
3072 | |
3073 void | |
3074 SER_uart_handler (void) | |
3075 { | |
3076 SYS_UWORD8 interrupt_status; | |
3077 t_uart *uart; | |
3078 int uart_id; | |
3079 SYS_BOOL it_identified; | |
3080 | |
3081 it_identified = 0; | |
3082 | |
3083 /* | |
3084 * Check first for a wake-up interrupt. | |
3085 */ | |
3086 | |
3087 uart_id = 0; | |
3088 while ((uart_id < NUMBER_OF_TR_UART) && | |
3089 (!it_identified)) { | |
3090 | |
3091 uart = &(int_uart[uart_id]); | |
3092 interrupt_status = READ_UART_REGISTER (uart, SSR); | |
3093 | |
3094 if (interrupt_status & RX_CTS_WAKE_UP_STS) { /* Wake-up IT has occurred */ | |
3095 | |
3096 it_identified = 1; | |
3097 uart_sleep_timer_enabled = 1; | |
3098 DISABLE_WAKE_UP_INTERRUPT (uart); | |
3099 } | |
3100 | |
3101 uart_id++; | |
3102 } | |
3103 | |
3104 /* | |
3105 * If no wake-up interrupt has been detected, check then systematically | |
3106 * both UARTs for other interrupt causes. | |
3107 */ | |
3108 | |
3109 if (!it_identified) { | |
3110 | |
3111 for (uart_id = 0; uart_id < NUMBER_OF_TR_UART; uart_id++) { | |
3112 | |
3113 uart = &(int_uart[uart_id]); | |
3114 interrupt_status = READ_UART_REGISTER (uart, IIR) & IIR_BITS_USED; | |
3115 | |
3116 if (!(interrupt_status & IT_NOT_PENDING)) { | |
3117 | |
3118 it_identified = 1; | |
3119 (*(uart->interrupt_handler)) (uart_id, interrupt_status); | |
3120 | |
3121 } else { | |
3122 | |
3123 if ((uart_id == UA_UART_1) && (!it_identified)) | |
3124 uart_spurious_interrupts++; | |
3125 } | |
3126 } | |
3127 } | |
3128 } | |
3129 | |
3130 #elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) | |
3131 | |
3132 /******************************************************************************* | |
3133 * | |
3134 * SER_uart_modem_handler | |
3135 * | |
3136 * Purpose : UART MODEM interrupt handler. | |
3137 * | |
3138 * Arguments: In : none | |
3139 * Out: none | |
3140 * | |
3141 * Returns : none | |
3142 * | |
3143 ******************************************************************************/ | |
3144 | |
3145 void | |
3146 SER_uart_modem_handler (void) | |
3147 { | |
3148 SYS_UWORD8 interrupt_status; | |
3149 t_uart *uart; | |
3150 SYS_BOOL it_wakeup_identified; | |
3151 | |
3152 it_wakeup_identified = 0; | |
3153 uart = &(int_uart[UA_UART_1]); | |
3154 | |
3155 /* | |
3156 * Check first for a wake-up interrupt. | |
3157 */ | |
3158 | |
3159 interrupt_status = READ_UART_REGISTER (uart, SSR); | |
3160 | |
3161 if (interrupt_status & RX_CTS_WAKE_UP_STS) { /* Wake-up IT has occurred */ | |
3162 | |
3163 it_wakeup_identified = 1; | |
3164 uart_sleep_timer_enabled = 1; | |
3165 #ifdef BTEMOBILE | |
3166 if (uart->flow_type == BLUETOOTH_HCI_FLOW) | |
3167 { | |
3168 interrupt_status = READ_UART_REGISTER (uart, IIR) & IIR_BITS_USED; | |
3169 (*(uart->interrupt_handler)) (UA_UART_1, interrupt_status); | |
3170 } | |
3171 #endif /* BTEMOBILE */ | |
3172 DISABLE_WAKE_UP_INTERRUPT (uart); | |
3173 } | |
3174 | |
3175 /* | |
3176 * If no wake-up interrupt has been detected, check UART for other | |
3177 * interrupt causes. | |
3178 */ | |
3179 | |
3180 if (!it_wakeup_identified) { | |
3181 | |
3182 interrupt_status = READ_UART_REGISTER (uart, IIR) & IIR_BITS_USED; | |
3183 | |
3184 if (!(interrupt_status & IT_NOT_PENDING)) | |
3185 (*(uart->interrupt_handler)) (UA_UART_1, interrupt_status); | |
3186 | |
3187 else | |
3188 uart_modem_spurious_interrupts++; | |
3189 } | |
3190 } | |
3191 | |
3192 | |
3193 /******************************************************************************* | |
3194 * | |
3195 * SER_uart_irda_handler | |
3196 * | |
3197 * Purpose : UART IrDA interrupt handler. | |
3198 * | |
3199 * Arguments: In : none | |
3200 * Out: none | |
3201 * | |
3202 * Returns : none | |
3203 * | |
3204 ******************************************************************************/ | |
3205 | |
3206 void | |
3207 SER_uart_irda_handler (void) | |
3208 { | |
3209 SYS_UWORD8 interrupt_status; | |
3210 t_uart *uart; | |
3211 SYS_BOOL it_wakeup_identified; | |
3212 | |
3213 it_wakeup_identified = 0; | |
3214 uart = &(int_uart[UA_UART_0]); | |
3215 | |
3216 /* | |
3217 * Check first for a wake-up interrupt. | |
3218 */ | |
3219 | |
3220 interrupt_status = READ_UART_REGISTER (uart, SSR); | |
3221 | |
3222 if (interrupt_status & RX_CTS_WAKE_UP_STS) { /* Wake-up IT has occurred */ | |
3223 | |
3224 it_wakeup_identified = 1; | |
3225 uart_sleep_timer_enabled = 1; | |
3226 #ifdef BTEMOBILE | |
3227 if (uart->flow_type == BLUETOOTH_HCI_FLOW) | |
3228 { | |
3229 interrupt_status = READ_UART_REGISTER (uart, IIR) & IIR_BITS_USED; | |
3230 (*(uart->interrupt_handler)) (UA_UART_0, interrupt_status); | |
3231 } | |
3232 #endif /* BTEMOBILE */ | |
3233 DISABLE_WAKE_UP_INTERRUPT (uart); | |
3234 } | |
3235 | |
3236 /* | |
3237 * If no wake-up interrupt has been detected, check UART for other | |
3238 * interrupt causes. | |
3239 */ | |
3240 | |
3241 if (!it_wakeup_identified) { | |
3242 | |
3243 interrupt_status = READ_UART_REGISTER (uart, IIR) & IIR_BITS_USED; | |
3244 | |
3245 if (!(interrupt_status & IT_NOT_PENDING)) | |
3246 (*(uart->interrupt_handler)) (UA_UART_0, interrupt_status); | |
3247 | |
3248 else | |
3249 uart_irda_spurious_interrupts++; | |
3250 } | |
3251 } | |
3252 | |
3253 #endif | |
3254 | |
3255 #if (CHIPSET == 12) | |
3256 /******************************************************************************* | |
3257 * | |
3258 * SER_uart_modem2_handler | |
3259 * | |
3260 * Purpose : UART IrDA interrupt handler. | |
3261 * | |
3262 * Arguments: In : none | |
3263 * Out: none | |
3264 * | |
3265 * Returns : none | |
3266 * | |
3267 ******************************************************************************/ | |
3268 | |
3269 void | |
3270 SER_uart_modem2_handler (void) | |
3271 { | |
3272 SYS_UWORD8 interrupt_status; | |
3273 t_uart *uart; | |
3274 SYS_BOOL it_wakeup_identified; | |
3275 | |
3276 it_wakeup_identified = 0; | |
3277 uart = &(int_uart[UA_UART_2]); | |
3278 | |
3279 /* | |
3280 * Check first for a wake-up interrupt. | |
3281 */ | |
3282 | |
3283 interrupt_status = READ_UART_REGISTER (uart, SSR); | |
3284 | |
3285 if (interrupt_status & RX_CTS_WAKE_UP_STS) { /* Wake-up IT has occurred */ | |
3286 | |
3287 it_wakeup_identified = 1; | |
3288 uart_sleep_timer_enabled = 1; | |
3289 #ifdef BTEMOBILE | |
3290 if (uart->flow_type == BLUETOOTH_HCI_FLOW) | |
3291 { | |
3292 interrupt_status = READ_UART_REGISTER (uart, IIR) & IIR_BITS_USED; | |
3293 (*(uart->interrupt_handler)) (UA_UART_2, interrupt_status); | |
3294 } | |
3295 #endif /* BTEMOBILE */ | |
3296 DISABLE_WAKE_UP_INTERRUPT (uart); | |
3297 } | |
3298 | |
3299 /* | |
3300 * If no wake-up interrupt has been detected, check UART for other | |
3301 * interrupt causes. | |
3302 */ | |
3303 | |
3304 if (!it_wakeup_identified) { | |
3305 | |
3306 interrupt_status = READ_UART_REGISTER (uart, IIR) & IIR_BITS_USED; | |
3307 | |
3308 if (!(interrupt_status & IT_NOT_PENDING)) | |
3309 (*(uart->interrupt_handler)) (UA_UART_2, interrupt_status); | |
3310 | |
3311 else | |
3312 uart_modem2_spurious_interrupts++; | |
3313 } | |
3314 } | |
3315 | |
3316 #endif | |
3317 | |
3318 /* | |
3319 * Temporary functions. | |
3320 */ | |
3321 | |
3322 void | |
3323 UT_Init (int device_id, | |
3324 int baudrate, | |
3325 void (callback_function (void))) | |
3326 { | |
3327 SER_tr_Init (SER_PROTOCOL_STACK, baudrate, callback_function); | |
3328 } | |
3329 | |
3330 SYS_UWORD32 | |
3331 UT_ReadNChars (int device_id, | |
3332 char *buffer, | |
3333 SYS_UWORD32 chars_to_read) | |
3334 { | |
3335 return (SER_tr_ReadNChars (SER_PROTOCOL_STACK, buffer, chars_to_read)); | |
3336 } | |
3337 | |
3338 SYS_UWORD32 | |
3339 UT_WriteNChars (int device_id, | |
3340 char *buffer, | |
3341 SYS_UWORD32 chars_to_write) | |
3342 { | |
3343 return (SER_tr_WriteNChars (SER_PROTOCOL_STACK, buffer, chars_to_write)); | |
3344 } | |
3345 | |
3346 void | |
3347 UT_WriteChar (int device_id, | |
3348 char character) | |
3349 { | |
3350 SER_tr_WriteChar (SER_PROTOCOL_STACK, character); | |
3351 } | |
3352 | |
3353 void | |
3354 UT_WriteString (int device_id, | |
3355 char *buffer) | |
3356 { | |
3357 SER_tr_WriteString (SER_PROTOCOL_STACK, buffer); | |
3358 } | |
3359 | |
3360 short | |
3361 UF_Init (SYS_UWORD8 deviceNo) | |
3362 { | |
3363 return (SER_fd_Init ()); | |
3364 } | |
3365 | |
3366 short | |
3367 UF_Enable (SYS_UWORD8 deviceNo, | |
3368 SYS_BOOL enable) | |
3369 { | |
3370 return (SER_fd_Enable (enable)); | |
3371 } | |
3372 | |
3373 short | |
3374 UF_SetComPar (SYS_UWORD8 deviceNo, | |
3375 T_baudrate baudrate, | |
3376 T_bitsPerCharacter bpc, | |
3377 T_stopBits sb, | |
3378 T_parity parity) | |
3379 { | |
3380 return (SER_fd_SetComPar (baudrate, | |
3381 bpc, | |
3382 sb, | |
3383 parity)); | |
3384 } | |
3385 | |
3386 short | |
3387 UF_SetBuffer (SYS_UWORD8 deviceNo, | |
3388 SYS_UWORD16 bufSize, | |
3389 SYS_UWORD16 rxThreshold, | |
3390 SYS_UWORD16 txThreshold) | |
3391 { | |
3392 return (SER_fd_SetBuffer (bufSize, rxThreshold, txThreshold)); | |
3393 } | |
3394 | |
3395 short | |
3396 UF_SetFlowCtrl (SYS_UWORD8 deviceNo, | |
3397 T_flowCtrlMode fcMode, | |
3398 SYS_UWORD8 XON, | |
3399 SYS_UWORD8 XOFF) | |
3400 { | |
3401 return (SER_fd_SetFlowCtrl (fcMode, XON, XOFF)); | |
3402 } | |
3403 | |
3404 short | |
3405 UF_SetEscape (SYS_UWORD8 deviceNo, | |
3406 SYS_UWORD8 escChar, | |
3407 SYS_UWORD16 guardPeriod) | |
3408 { | |
3409 return (SER_fd_SetEscape (escChar, guardPeriod)); | |
3410 } | |
3411 | |
3412 short | |
3413 UF_InpAvail (SYS_UWORD8 deviceNo) | |
3414 { | |
3415 return (SER_fd_InpAvail ()); | |
3416 } | |
3417 | |
3418 short | |
3419 UF_OutpAvail (SYS_UWORD8 deviceNo) | |
3420 { | |
3421 return (SER_fd_OutpAvail ()); | |
3422 } | |
3423 | |
3424 short | |
3425 UF_ReadData (SYS_UWORD8 deviceNo, | |
3426 T_suspendMode suspend, | |
3427 void (readOutFunc (SYS_BOOL cldFromIrq, | |
3428 T_reInstMode *reInstall, | |
3429 SYS_UWORD8 nsource, | |
3430 SYS_UWORD8 *source[], | |
3431 SYS_UWORD16 size[], | |
3432 SYS_UWORD32 state))) | |
3433 { | |
3434 return (SER_fd_ReadData (suspend, readOutFunc)); | |
3435 } | |
3436 | |
3437 short | |
3438 UF_WriteData (SYS_UWORD8 deviceNo, | |
3439 T_suspendMode suspend, | |
3440 void (writeInFunc (SYS_BOOL cldFromIrq, | |
3441 T_reInstMode *reInstall, | |
3442 SYS_UWORD8 ndest, | |
3443 SYS_UWORD8 *dest[], | |
3444 SYS_UWORD16 size[]))) | |
3445 { | |
3446 return (SER_fd_WriteData (suspend, writeInFunc)); | |
3447 } | |
3448 | |
3449 short | |
3450 UF_StopRec (SYS_UWORD8 deviceNo) | |
3451 { | |
3452 return (SER_fd_StopRec ()); | |
3453 } | |
3454 | |
3455 short | |
3456 UF_StartRec (SYS_UWORD8 deviceNo) | |
3457 { | |
3458 return (SER_fd_StartRec ()); | |
3459 } | |
3460 | |
3461 short | |
3462 UF_GetLineState (SYS_UWORD8 deviceNo, | |
3463 SYS_UWORD32 *state) | |
3464 { | |
3465 return (SER_fd_GetLineState (state)); | |
3466 } | |
3467 | |
3468 short | |
3469 UF_SetLineState (SYS_UWORD8 deviceNo, | |
3470 SYS_UWORD32 state, | |
3471 SYS_UWORD32 mask) | |
3472 { | |
3473 return (SER_fd_SetLineState (state, mask)); | |
3474 } | |
3475 | |
3476 short | |
3477 UF_CheckXEmpty (SYS_UWORD8 deviceNo) | |
3478 { | |
3479 return (SER_fd_CheckXEmpty ()); | |
3480 } |