comparison src/aci2/aci/cmh_uarts.c @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_UARTS
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose :
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifdef UART
22
23 #ifndef CMH_UARTS_C
24 #define CMH_UARTS_C
25 #endif
26
27 #include "aci_all.h"
28 /*==== INCLUDES ===================================================*/
29 #include "aci_cmh.h"
30 #include "ati_cmd.h"
31 #include "aci_cmd.h"
32 #include "dti.h" /* functionality of the dti library */
33
34 #include "aci.h"
35 #include "psa.h"
36 #include "aci_fd.h"
37 #include "cmh.h"
38
39 #include "aci_lst.h"
40
41 #include "dti_conn_mng.h"
42 #include "dti_cntrl_mng.h"
43 #include "psa_uart.h"
44 #include "cmh_uart.h"
45 #include "sap_dti.h"
46 #ifdef FF_PSI
47 #include "psa_psi.h"
48 #include "cmh_psi.h"
49 #endif /*FF_PSI*/
50 #include "aci_mem.h"
51 #include "aci_io.h"
52 #include "l4_tim.h"
53
54 #include "psa_cc.h"
55
56 typedef struct /* + IPR parameter */
57 {
58 T_ACI_BD_RATE rate;
59 T_ACI_CMD_SRC srcId;
60 }
61 T_ACI_IPR;
62
63 EXTERN T_ACI_LIST *ati_src_list;
64
65 /*==== CONSTANTS ==================================================*/
66
67 /*==== EXPORT =====================================================*/
68 EXTERN char *cmdErrStr; /* Error Message */
69 static T_ACI_IPR uart_ipr_param;
70 EXTERN CHAR *cmdAtError (AtErrCode e);
71
72 /*==== VARIABLES ==================================================*/
73
74 GLOBAL T_ACI_LIST *uart_src_params = NULL;
75 GLOBAL T_ACI_UART_MUX_PARMS holdMuxParms;
76
77 /*
78 * uart_com_par: Lists all COM parameter for every device.
79 *
80 * This list is only used so long as the UART SAP don't support parameter getting.
81 *
82 */
83 GLOBAL T_ACI_LIST *uart_com_par = NULL;
84
85 /*==== FUNCTIONS ==================================================*/
86
87 GLOBAL void cmhUART_lst_init (void)
88 {
89 TRACE_FUNCTION ("cmhUART_lst_init()");
90 uart_src_params = new_list ();
91 /*psi_src_params = new_list();*/
92
93 if ( !uart_com_par )
94 uart_com_par = new_list ();
95 /* if (!psi_dev_list)
96 psi_dev_list = new_list();*/
97 }
98
99
100 GLOBAL T_ACI_BD_RATE convert_mux_port_speed (UBYTE mux_port_speed)
101 {
102 switch (mux_port_speed)
103 {
104 case 1:
105 return (BD_RATE_9600);
106
107 case 2:
108 return (BD_RATE_19200);
109
110 case 3:
111 return (BD_RATE_38400);
112
113 case 4:
114 return (BD_RATE_57600);
115
116 case 5:
117 return (BD_RATE_115200);
118
119 default:
120 return (BD_RATE_NotPresent);
121 }
122 }
123
124 /*
125 +-------------------------------------------------------------------+
126 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBS |
127 | STATE : code ROUTINE : sAT_PlusCMUX |
128 +-------------------------------------------------------------------+
129
130 PURPOSE : This is the functional counterpart of the +CMUX
131 AT command which is responsible for starting multiplexing transactions.
132
133 */
134 GLOBAL T_ACI_RETURN sAT_PlusCMUX ( T_ACI_CMD_SRC srcId,
135 UBYTE mode,
136 UBYTE subset,
137 UBYTE port_speed,
138 USHORT N1,
139 UBYTE T1,
140 UBYTE N2,
141 UBYTE T2,
142 UBYTE T3 )
143 {
144
145 #ifdef DTI
146 T_ACI_DTI_PRC *src_infos = NULL;
147 T_ACI_UART_MUX_PARMS *MuxParms = NULL;
148 T_ATI_SRC_PARAMS *src_params = find_element (ati_src_list, (UBYTE)srcId, search_ati_src_id);
149
150 TRACE_FUNCTION ("sAT_PlusCMUX()");
151
152 if(!cmh_IsVldCmdSrc (srcId))
153 {
154 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
155 return (AT_FAIL);
156 }
157
158 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId);
159 if (src_infos EQ NULL)
160 {
161 TRACE_EVENT_P1("[ERR] sAT_PlusCMUX(): srcId=%d not found", srcId) ;
162 return (AT_FAIL);
163 }
164
165 /*
166 * AT+CMUX needs to get the answer OK before it sends the
167 * primitives to UART, because channel is then already closed.
168 */
169 io_sendConfirm ( (UBYTE)srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT );
170 cmdErrStr = NULL;
171
172 ACI_MALLOC( src_infos ->MuxParms, sizeof(T_ACI_UART_MUX_PARMS) );
173
174 MuxParms = src_infos -> MuxParms;
175 /* memorize parameters */
176 MuxParms->mode = mode;
177 MuxParms->subset = subset;
178 MuxParms->port_speed = port_speed;
179 MuxParms->N1 = N1;
180 MuxParms->T1 = T1;
181 MuxParms->N2 = N2;
182 MuxParms->T2 = T2;
183 MuxParms->T3 = T3;
184
185 if ((src_infos->data_buffer.data_list EQ NULL)
186 AND (aci_src_dti_params[srcId].dtxState EQ READY) )
187 {
188 uartEntcurCmd[srcId] = AT_CMD_NONE;
189 if ((cmhUART_CMUX (srcId)) EQ FALSE)
190 {
191 /*
192 * we already sent an OK according to GSM 27.010, but now the muxer is not ready !
193 * this AT_FAIL results in a ATI_FAIL_NO_OUTPUT at function setatPlusCMUX().
194 * so, what will the source do in this case ?
195 */
196 TRACE_EVENT("[ERR] sAT_PlusCMUX()(): UART muxer not ready");
197 return (AT_FAIL);
198 }
199 }
200 else
201 {
202 /*Now we wait for the dtx state to be ready and the multiplexer will be started
203 from function sig_dti_tx_buffer_ready_ind() after the data buffer of the source is
204 emptied*/
205 uartEntcurCmd[srcId] = AT_CMD_CMUX;
206 }
207 return ( AT_EXCT );
208 #else
209 return ( AT_FAIL );
210 #endif /* DTI */
211
212 }
213
214 GLOBAL T_ACI_RETURN qAT_PlusCMUX ( T_ACI_CMD_SRC srcId,
215 UBYTE *mode,
216 UBYTE *subset,
217 UBYTE *port_speed,
218 USHORT *N1,
219 UBYTE *T1,
220 UBYTE *N2,
221 UBYTE *T2,
222 UBYTE *T3 )
223 {
224 TRACE_FUNCTION ("qAT_PlusCMUX()");
225
226 if ( (holdMuxParms.mode EQ 0) AND (holdMuxParms.subset EQ 0) AND
227 (holdMuxParms.port_speed EQ 0) AND (holdMuxParms.N1 EQ 0) AND
228 (holdMuxParms.T1 EQ 0) AND (holdMuxParms.N2 EQ 0) AND
229 (holdMuxParms.T2 EQ 0) AND (holdMuxParms.T3 EQ 0) )
230 {
231 TRACE_FUNCTION("No Mux is enabled");
232 return (AT_FAIL);
233 }
234 *mode = holdMuxParms.mode;
235 *subset = holdMuxParms.subset;
236 *port_speed = holdMuxParms.port_speed;
237 *N1 = holdMuxParms.N1;
238 *T1 = holdMuxParms.T1;
239 *N2 = holdMuxParms.N2;
240 *T2 = holdMuxParms.T2;
241 *T3 = holdMuxParms.T3;
242
243 return ( AT_CMPL );
244 }
245
246 GLOBAL BOOL cmhUART_CMUX (T_ACI_CMD_SRC srcId)
247 {
248 T_ACI_DTI_PRC *src_infos = NULL;
249 T_ACI_BD_RATE speed = BD_RATE_NotPresent;
250
251 TRACE_FUNCTION ("cmhUART_CMUX()");
252
253 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId);
254
255 if (src_infos EQ NULL)
256 {
257 TRACE_EVENT_P1("[ERR] sAT_PlusCMUX(): srcId=%d not found", srcId) ;
258 return (FALSE);
259 }
260
261 if (cmhUART_stopConnection ((UBYTE)srcId))
262 {
263 if (src_infos->MuxParms)
264 {
265 speed = convert_mux_port_speed (src_infos->MuxParms->port_speed);
266
267 if ( speed NEQ BD_RATE_NotPresent )
268 {
269 /*
270 * at first we have to change the baud rate (primitive to UART)
271 */
272 if (cmhUART_SetDataRate ((UBYTE)srcId, speed) EQ AT_EXCT)
273 {
274 return (TRUE);
275 }
276 else
277 {
278 TRACE_EVENT("[ERR] cmhUART_CMUX(): not able to change baud rate");
279 return (FALSE);
280 }
281 }
282 /*
283 * void function, sends the UART_MUX_START_REQ primitive
284 * return value is handled by the confirmation
285 */
286 psaUART_StartMux( src_infos->device,
287 src_infos->MuxParms->mode,
288 src_infos->MuxParms->subset,
289 src_infos->MuxParms->N1,
290 src_infos->MuxParms->T1,
291 src_infos->MuxParms->N2,
292 src_infos->MuxParms->T2,
293 src_infos->MuxParms->T3);
294
295 memcpy( (CHAR *)&holdMuxParms, (CHAR *)src_infos->MuxParms, sizeof(T_ACI_UART_MUX_PARMS));
296 ACI_MFREE( src_infos->MuxParms );
297 src_infos->MuxParms = NULL;
298 return (TRUE);
299 }
300 else
301 {
302 TRACE_EVENT("[ERR] cmhUART_CMUX(): no muxer parameters available");
303 }
304 }
305 else
306 {
307 TRACE_EVENT("[ERR] cmhUART_CMUX(): not able to stop UART connection");
308 }
309 return (FALSE);
310 }
311
312 /*
313 +-------------------------------------------------------------------+
314 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIS |
315 | ROUTINE : cmhUART_getdata |
316 +-------------------------------------------------------------------+
317
318 PURPOSE : tell DTI that ACI is ready to receive more datas.
319 */
320 GLOBAL void cmhUART_getdata ( T_ACI_CMD_SRC srcId )
321 {
322 TRACE_FUNCTION ("cmhUART_getdata");
323
324 #ifdef RMV_01_04_03
325 #ifdef FF_TWO_UART_PORTS
326 if (srcId NEQ UART_DATA_CHANNEL)
327 {
328 psaDTI_getdata ( (UBYTE)srcId, DTI_ENTITY_UART);
329 }
330 #else
331 psaDTI_getdata ( (UBYTE)srcId, DTI_ENTITY_UART);
332 #endif
333 #endif
334
335 psaDTI_getdata ( (UBYTE)srcId, DTI_ENTITY_UART);
336
337 }
338
339 /*
340 +-------------------------------------------------------------------+
341 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIS |
342 | ROUTINE : cmhUART_startConnection |
343 +-------------------------------------------------------------------+
344
345 PURPOSE : start a DTI connection with UART.
346 */
347
348 GLOBAL void cmhUART_startConnection (UBYTE srcId,
349 T_ACI_DEVICE_TYPE device_type)
350 {
351 T_ACI_DTI_PRC *src_infos;
352 T_ACI_DEVICE_ENTRY *device_entry;
353 T_ACI_DEVICE_TYPE curr_device_type;
354 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI};
355
356 TRACE_FUNCTION ("cmhUART_startConnection ()");
357
358 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId);
359 if (src_infos EQ NULL)
360 {
361 TRACE_EVENT_P1("[ERR] cmhUART_startConnection: srcId=%d not found",
362 srcId) ;
363 return ;
364 }
365
366 device_entry = cmhUART_GetDeviceParOverDevice( src_infos->device );
367
368 if ( device_entry EQ NULL )
369 {
370 TRACE_EVENT_P1("[ERR] cmhUART_startConnection: device=%d not found", src_infos->device) ;
371 return;
372 }
373
374 curr_device_type = cmhUART_GetDeviceType (srcId);
375
376 switch (curr_device_type)
377 {
378 case DEVICE_TYPE_UNKNOWN:
379 /* register device to the DTI Control Manager */
380 #ifdef DTI
381 dti_cntrl_new_device ( srcId, /* ATI source ID */
382 DTI_ENTITY_UART, /* device ID */
383 src_infos->device, /* device number */
384 src_infos->dlci, /* sub-channel number */
385 DTI_PORT_NUMBER_NOTPRESENT, /* ATI-RIV port number */
386 DTI_CPBLTY_CMD | DTI_CPBLTY_SER, /* capabilities */
387 DTI_DRIVER_ID_NOTPRESENT,
388 DTI_DIO_ID_NOTPRESENT);
389
390 #endif /* DTI */
391 /* set device type */
392 cmhUART_ChangeDeviceType (srcId, device_type);
393 break;
394
395 default:
396 break;
397 } /* switch */
398
399 if (device_type EQ DEVICE_TYPE_URT)
400 {
401 /* initialize UART */
402 psaUART_SetParameters (src_infos->device, &device_entry->comPar);
403 /* has to wait for confirmation before setting DTI channel */
404 return;
405 }
406 #ifdef DTI
407 /* request of a DTI channel to communicate with UART */
408 dti_cntrl_est_dpath_indirect ( src_infos->srcId,
409 entity_list,
410 1,
411 SPLIT,
412 atiUART_dti_cb,
413 DTI_CPBLTY_CMD,
414 DTI_CID_NOTPRESENT);
415 #endif
416 }
417 /*
418 +-------------------------------------------------------------------+
419 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIS |
420 | ROUTINE : cmhUART_stopConnection |
421 +-------------------------------------------------------------------+
422
423 PURPOSE : stop a DTI connection with UART.
424 */
425 GLOBAL BOOL cmhUART_stopConnection (UBYTE srcId)
426 {
427 T_ACI_DTI_PRC *src_infos;
428
429 TRACE_FUNCTION ("cmhUART_stopConnection()");
430
431 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId);
432 if (src_infos EQ NULL)
433 {
434 TRACE_EVENT_P1("[ERR] cmhUART_stopConnection: srcId=%d not found",
435 srcId) ;
436 return (FALSE);
437 }
438
439 src_infos->LineState = LINE_DISCONNECTED;
440
441 if (cmhUART_ChangeDeviceType (src_infos->srcId, DEVICE_TYPE_UNKNOWN))
442 {
443 #ifdef DTI
444 if (dti_cntrl_close_dpath_from_src_id( srcId ))
445 {
446 return (TRUE);
447 }
448 #endif
449 }
450
451 return (FALSE);
452 }
453
454 /*
455 +--------------------------------------------------------------------+
456 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS |
457 | STATE : code ROUTINE : sAT_PlusIPR |
458 +--------------------------------------------------------------------+
459
460 PURPOSE : This is the functional counterpart to the +IPR AT command
461 which is responsible to set the data rate.
462 */
463
464 GLOBAL void cmhUART_init_ipr_params(void)
465 {
466 TRACE_FUNCTION ("cmhUART_init_ipr_params()");
467
468 uart_ipr_param.srcId = CMD_SRC_NONE;
469 uart_ipr_param.rate = BD_RATE_NotPresent;
470 }
471
472 GLOBAL T_ACI_RETURN sAT_PlusIPR(T_ACI_CMD_SRC srcId, T_ACI_BD_RATE rate)
473 {
474 ULONG ipr_timer = 0;
475
476 TRACE_FUNCTION ("sAT_PlusIPR()");
477
478 /* check command source */
479 if(srcId EQ CMD_SRC_LCL)
480 {
481 TRACE_ERROR("This command is not supported for local command source");
482 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotSupp );
483 return AT_FAIL;
484 }
485 if(!cmh_IsVldCmdSrc (srcId))
486 {
487 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
488 return AT_FAIL;
489 }
490
491 /* parameter check */
492 if ( rate < BD_RATE_AUTO OR rate > BD_RATE_115200 ) /* maximum supported value by UART */
493 {
494 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotSupp );
495 return AT_FAIL;
496 }
497
498 /* We need to sent the OK prior we switch to the new baudrate */
499 io_sendConfirm((UBYTE)srcId, cmdAtError(atOk), ATI_NORMAL_OUTPUT);
500 cmdErrStr = NULL;
501
502 uart_ipr_param.rate = rate;
503 uart_ipr_param.srcId = srcId;
504
505 ipr_timer = 600; /* worst case calculation: 4 characters:OK<CR><LF> at 75bit/s
506 with 1 startbit, 1 paritybit and 1 stopbit (2 stopbits are only used for longer words)
507 4*(8+1+1+1)= 44 bits => 44/75 seconds = 586 msec*/
508
509 /* time for output "OK" then send changed parameter to UART */
510 uartEntcurCmd[srcId] = AT_CMD_IPR;
511 TIMERSTART(ipr_timer, ACI_IPR);
512
513 return AT_CMPL;
514 }
515
516
517 /*
518 +--------------------------------------------------------------------+
519 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS |
520 | STATE : code ROUTINE : timeout_PlusIPR |
521 +--------------------------------------------------------------------+
522
523 PURPOSE : This function send the changed baudrate to UART after
524 the timer ACI_IPR is expired
525 */
526
527 GLOBAL void timeout_PlusIPR ( void)
528 {
529 #ifdef FF_PSI
530 T_ACI_DTI_PRC_PSI *src_infos = find_element (psi_src_params,
531 (UBYTE)uart_ipr_param.srcId, cmhPSItest_srcId);
532 #endif /*FF_PSI*/
533 TRACE_FUNCTION ("timeout_PlusIPR()");
534 #ifdef FF_PSI
535 if ( src_infos NEQ NULL )
536 {
537 cmhPSI_SetDataRate((UBYTE)uart_ipr_param.srcId, uart_ipr_param.rate);
538 }
539 /* force parameter request */
540 else
541 #endif /*FF_PSI*/
542 cmhUART_SetDataRate((UBYTE)uart_ipr_param.srcId, uart_ipr_param.rate);
543
544 cmhUART_init_ipr_params();
545 uartEntcurCmd[uart_ipr_param.srcId] = AT_CMD_NONE;
546 }
547
548 /*
549 +--------------------------------------------------------------------+
550 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS |
551 | STATE : code ROUTINE : qAT_PlusIPR |
552 +--------------------------------------------------------------------+
553
554 PURPOSE : This is the functional counterpart to the +IPR? AT command
555 which returns the current setting for the data rate.
556
557 */
558 GLOBAL T_ACI_RETURN qAT_PlusIPR ( T_ACI_CMD_SRC srcId, T_ACI_BD_RATE *rate)
559 {
560 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( (UBYTE) srcId );
561 #ifdef FF_PSI
562 T_ACI_DEVICE_DCB_ENTRY *device_dcb_entry;
563 U32 device_type;/* RM 26-05-04 Nice */
564 #endif /*FF_PSI*/
565 TRACE_FUNCTION ("qAT_PlusIPR()");
566
567 if ( device_entry EQ NULL )
568 {
569 #ifdef FF_PSI
570 device_dcb_entry = cmhPSI_GetDeviceParOverSrcID( (UBYTE) srcId );
571 if (device_dcb_entry EQ NULL)
572 #endif /*FF_PSI*/
573 return AT_FAIL;
574 #ifdef FF_PSI
575 else
576 {
577 device_type = device_dcb_entry->devId & DIO_TYPE_DAT_MASK;/* RM 26-05-04 Nice */
578 if (device_type EQ DIO_DATA_SER)/* RM 26-05-04 Nice */
579 *rate = (T_ACI_BD_RATE)device_dcb_entry->dcbPar.dio_dcb_ser.baudrate;
580 if (device_type EQ DIO_DATA_MUX)/* RM 26-05-04 Nice */
581 *rate = (T_ACI_BD_RATE)device_dcb_entry->dcbPar.dio_dcb_ser_mux.baudrate;
582 else if (device_type EQ DIO_DATA_PKT)/* RM 26-05-04 Nice */
583 return AT_FAIL;
584 return( AT_CMPL );
585 }
586 #endif /*FF_PSI*/
587 }
588 /*
589 *-------------------------------------------------------------------
590 * fill in parameters
591 *-------------------------------------------------------------------
592 */
593 *rate = (T_ACI_BD_RATE) device_entry->comPar.speed;
594
595 return( AT_CMPL );
596 }
597
598 /*
599 +--------------------------------------------------------------------+
600 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS |
601 | STATE : code ROUTINE : sAT_PlusICF |
602 +--------------------------------------------------------------------+
603
604 PURPOSE : This is the functional counterpart to the +ICF AT command
605 which is responsible to set the character framing.
606 */
607
608 GLOBAL T_ACI_RETURN sAT_PlusICF ( T_ACI_CMD_SRC srcId,
609 T_ACI_BS_FRM format,
610 T_ACI_BS_PAR parity)
611 {
612 #ifdef FF_PSI
613 T_ACI_DTI_PRC_PSI *src_infos = find_element (psi_src_params,
614 (UBYTE) srcId, cmhPSItest_srcId);
615 #endif /*FF_PSI*/
616 TRACE_FUNCTION ("sAT_PlusICF()");
617
618 /*
619 *-------------------------------------------------------------------
620 * parameter check
621 *-------------------------------------------------------------------
622 */
623 switch( format )
624 {
625 case( BS_FRM_NotPresent ):
626 case( BS_FRM_Dat8_Par0_St2 ):
627 case( BS_FRM_Dat8_Par1_St1 ):
628 case( BS_FRM_Dat8_Par0_St1 ):
629 case( BS_FRM_Dat7_Par0_St2 ):
630 case( BS_FRM_Dat7_Par1_St1 ):
631 case( BS_FRM_Dat7_Par0_St1 ):
632
633 break;
634
635 default:
636 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
637 return( AT_FAIL );
638 }
639
640 switch( parity )
641 {
642 case( BS_PAR_NotPresent ):
643 case( BS_PAR_Odd ):
644 case( BS_PAR_Even ):
645 case( BS_PAR_Mark ):
646 case( BS_PAR_Space ):
647
648 break;
649
650 default:
651 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
652 return( AT_FAIL );
653 }
654
655 /*
656 *-------------------------------------------------------------------
657 * force parameter request
658 *-------------------------------------------------------------------
659 */
660 #ifdef FF_PSI
661 if ( src_infos NEQ NULL )
662 {
663 if ( AT_EXCT EQ cmhPSI_SetCharacterFraming((UBYTE) srcId, format, parity) )
664 {
665 uartEntcurCmd[srcId] = AT_CMD_ICF;
666 return AT_EXCT;
667 }
668 }
669 /* force parameter request */
670 else
671 #endif /*FF_PSI*/
672 {
673 if ( AT_EXCT EQ cmhUART_SetCharacterFraming((UBYTE) srcId, format, parity) )
674 {
675 uartEntcurCmd[srcId] = AT_CMD_ICF;
676 return AT_EXCT;
677 }
678 }
679 return AT_FAIL;
680 }
681
682 /*
683 +--------------------------------------------------------------------+
684 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS |
685 | STATE : code ROUTINE : qAT_PlusICF |
686 +--------------------------------------------------------------------+
687
688 PURPOSE : This is the functional counterpart to the +ICF? AT command
689 which returns the current setting for character framing.
690
691 */
692
693 GLOBAL T_ACI_RETURN qAT_PlusICF ( T_ACI_CMD_SRC srcId,
694 T_ACI_BS_FRM *format,
695 T_ACI_BS_PAR *parity)
696 {
697 T_ACI_DEVICE_ENTRY *device_entry =
698 cmhUART_GetDeviceParOverSrcID( (UBYTE) srcId );
699 #ifdef FF_PSI
700 T_ACI_DEVICE_DCB_ENTRY *device_dcb_entry =
701 cmhPSI_GetDeviceParOverSrcID( (UBYTE) srcId );
702 #endif /*FF_PSI*/
703 TRACE_FUNCTION ("qAT_PlusICF()");
704 #ifdef FF_PSI
705 if (device_entry EQ NULL AND device_dcb_entry EQ NULL)
706 #else
707 if (device_entry EQ NULL)
708 #endif /*FF_PSI*/
709 {
710 return AT_FAIL;
711 }
712 #ifdef FF_PSI
713 if ( device_entry EQ NULL AND device_dcb_entry NEQ NULL )
714 {
715 *format = cmhPSI_GetFktInterfaceFormat(device_dcb_entry);
716 *parity = cmhPSI_GetFktInterfaceParity(device_dcb_entry);
717 return( AT_CMPL );
718 }
719 #endif /*FF_PSI*/
720
721 /*
722 *-------------------------------------------------------------------
723 * fill in parameters
724 *-------------------------------------------------------------------
725 */
726 *format = cmhUART_GetFktInterfaceFormat(&(device_entry->comPar));
727 *parity = cmhUART_GetFktInterfaceParity(&(device_entry->comPar));
728
729 return( AT_CMPL );
730 }
731
732 /*
733 +--------------------------------------------------------------------+
734 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS |
735 | STATE : code ROUTINE : sAT_PlusIFC |
736 +--------------------------------------------------------------------+
737
738 PURPOSE : This is the functional counterpart to the +IFC AT command
739 which is responsible to set the flow control.
740 */
741
742 GLOBAL T_ACI_RETURN sAT_PlusIFC ( T_ACI_CMD_SRC srcId,
743 T_ACI_RX_FLOW_CTRL DCE_by_DTE,
744 T_ACI_RX_FLOW_CTRL DTE_by_DCE )
745 {
746 #ifdef FF_PSI
747 T_ACI_DTI_PRC_PSI *src_infos = find_element (psi_src_params, (UBYTE) srcId, cmhPSItest_srcId);
748 #endif /*FF_PSI*/
749 T_ACI_RETURN result = AT_FAIL;
750 TRACE_FUNCTION ("sAT_PlusIFC()");
751
752 /*
753 *-------------------------------------------------------------------
754 * parameter check
755 *-------------------------------------------------------------------
756 */
757 TRACE_EVENT_P2("sAT_PlusIFC: DCE_by_DTE=%d DTE_by_DCE=%d", DCE_by_DTE, DTE_by_DCE);
758
759 if ( DCE_by_DTE < RX_FLOW_NotPresent || DCE_by_DTE > RX_FLOW_HARDWARE )
760 {
761 TRACE_EVENT("sAT_PlusIFC: err1");
762 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
763 return AT_FAIL;
764 }
765
766 if ( DTE_by_DCE < TX_FLOW_NotPresent || DTE_by_DCE > TX_FLOW_HARDWARE )
767 {
768 TRACE_EVENT("sAT_PlusIFC: err2");
769 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
770 return AT_FAIL;
771 }
772
773 if ( DTE_by_DCE NEQ TX_FLOW_NotPresent && DCE_by_DTE NEQ DTE_by_DCE )
774 {
775 TRACE_EVENT("sAT_PlusIFC: err3");
776 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
777 return AT_FAIL;
778 }
779
780 /*
781 *-------------------------------------------------------------------
782 * force parameter request
783 *-------------------------------------------------------------------
784 */
785 #ifdef FF_PSI
786 if (src_infos NEQ NULL)
787 result = cmhPSI_SetFlowControl((UBYTE) srcId, DCE_by_DTE);
788 else
789 #endif /*FF_PSI*/
790 result = cmhUART_SetFlowControl((UBYTE) srcId, DCE_by_DTE);
791 switch (result)
792 {
793 case AT_EXCT:
794 uartEntcurCmd[srcId] = AT_CMD_IFC;
795 return AT_EXCT;
796 case AT_CMPL:
797 return AT_CMPL;
798 }
799 return result;
800 }
801
802 /*
803 +--------------------------------------------------------------------+
804 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS |
805 | STATE : code ROUTINE : qAT_PlusIFC |
806 +--------------------------------------------------------------------+
807
808 PURPOSE : This is the functional counterpart to the +ICF? AT command
809 which returns the current setting for character framing.
810
811 */
812
813 GLOBAL T_ACI_RETURN qAT_PlusIFC ( T_ACI_CMD_SRC srcId,
814 T_ACI_RX_FLOW_CTRL *DCE_by_DTE,
815 T_ACI_RX_FLOW_CTRL *DTE_by_DCE )
816 {
817 T_ACI_RX_FLOW_CTRL flow_cntrl = RX_FLOW_NotPresent;
818 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( (UBYTE) srcId );
819 #ifdef FF_PSI
820 T_ACI_DEVICE_DCB_ENTRY *device_dcb_entry = NULL;
821 U32 device_type;/* RM 26-05-04 Nice */
822 #endif /*FF_PSI*/
823 TRACE_FUNCTION ("qAT_PlusIFC()");
824
825 if ( device_entry EQ NULL )
826 {
827 #ifdef FF_PSI
828 if ( (device_dcb_entry = cmhPSI_GetDeviceParOverSrcID( (UBYTE) srcId )) EQ NULL)
829 #endif /*FF_PSI*/
830 return AT_FAIL;
831 #ifdef FF_PSI
832 device_type = device_dcb_entry->devId & DIO_TYPE_DAT_MASK;/* RM 26-05-04 Nice */
833 if (device_type EQ DIO_DATA_PKT)/* RM 26-05-04 Nice */
834 return AT_FAIL;
835 if (device_type EQ DIO_DATA_SER)/* RM 26-05-04 Nice */
836 flow_cntrl = device_dcb_entry->dcbPar.dio_dcb_ser.flow_control;
837 if (device_type EQ DIO_DATA_MUX)/* RM 26-05-04 Nice */
838 flow_cntrl = device_dcb_entry->dcbPar.dio_dcb_ser_mux.flow_control;
839
840 switch ( flow_cntrl )
841 {
842 case DIO_FLOW_NONE:
843 default:
844 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_NONE;
845 break;
846 case DIO_FLOW_XON_XOFF:
847 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_SOFTWARE;
848 break;
849 case DIO_FLOW_RTS_CTS:
850 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_HARDWARE;
851 break;
852 }
853 return( AT_CMPL );
854 #endif /*FF_PSI*/
855 }
856
857 /*
858 *-------------------------------------------------------------------
859 * fill in parameters
860 *-------------------------------------------------------------------
861 */
862 switch ( device_entry->comPar.flow_rx )
863 {
864 case UART_IO_FC_RX_NONE:
865 default:
866 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_NONE;
867 break;
868 case UART_IO_FC_RX_XOFF:
869 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_SOFTWARE;
870 break;
871 case UART_IO_FC_RX_RTS:
872 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_HARDWARE;
873 break;
874 }
875
876 return( AT_CMPL );
877 }
878
879
880 /*
881 +--------------------------------------------------------------------+
882 | PROJECT : GSM-PS (6147) MODULE : CMH_CCS |
883 | STATE : code ROUTINE : sAT_AndC |
884 +--------------------------------------------------------------------+
885
886 PURPOSE : set DCD behaviour
887 */
888
889 GLOBAL T_ACI_RETURN sAT_AndC ( T_ACI_CMD_SRC srcId,
890 T_ACI_DCD_MOD value )
891 {
892 BOOL no_data_call_on_this_line = TRUE;
893 UBYTE i;
894
895 TRACE_FUNCTION ("sAT_AndC()");
896
897 /* check command source */
898 if(!cmh_IsVldCmdSrc (srcId))
899 {
900 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
901 return( AT_FAIL );
902 }
903
904 /* check parameter value */
905 switch(value)
906 {
907 case(DCD_ALWAYS_ON):
908 case(DCD_DISABLE_AFTER_CALL):
909 break;
910 default:
911 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
912 return( AT_FAIL );
913 }
914
915 /* set DCD behaviour */
916 cmhPrm[srcId ].ccCmdPrm.DCDmode = value;
917
918 /* set DCD */
919 if(value EQ DCD_ALWAYS_ON)
920 {
921 io_setDCD (srcId, IO_DCD_ON);
922 }
923 else if(value EQ DCD_DISABLE_AFTER_CALL)
924 {
925 for (i = 0; i < MAX_CALL_NR; i++)
926 {
927 T_CC_CALL_TBL *ctbx = ccShrdPrm.ctb[i];
928
929 if (ctbx NEQ NULL AND
930 ctbx->curSrc EQ srcId)
931 {
932 switch(ctbx->BC[ctbx->curBC].bearer_serv)
933 {
934 case(BEARER_SERV_NOT_PRES):
935 case(BEARER_SERV_SPEECH):
936 case(BEARER_SERV_AUX_SPEECH):
937 break;
938 default:
939 /* data call */
940 no_data_call_on_this_line = FALSE;
941 break;
942 }
943 }
944 }
945
946 if( no_data_call_on_this_line )
947 {
948 io_setDCD (srcId, IO_DCD_OFF);
949 }
950 }
951 return( AT_CMPL );
952 }
953
954
955 /*
956 +--------------------------------------------------------------------+
957 | PROJECT : GSM-PS (6147) MODULE : CMH_CCQ |
958 | STATE : code ROUTINE : qAT_AndC |
959 +--------------------------------------------------------------------+
960
961 PURPOSE : query DCD behaviour setting.
962 */
963
964 GLOBAL T_ACI_RETURN qAT_AndC ( T_ACI_CMD_SRC srcId,
965 T_ACI_DCD_MOD *value)
966 {
967
968 TRACE_FUNCTION ("qAT_AndC()");
969
970 /* check command source */
971 if(!cmh_IsVldCmdSrc (srcId))
972 {
973 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
974 return( AT_FAIL );
975 }
976
977 /* check parameter value */
978 if( value EQ NULL )
979 {
980 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
981 return( AT_FAIL );
982 }
983
984 /* query DCD behaviour */
985 *value = cmhPrm[srcId ].ccCmdPrm.DCDmode;
986
987 return( AT_CMPL );
988 }
989
990
991 /*
992 +--------------------------------------------------------------------+
993 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS |
994 | STATE : code ROUTINE : sAT_AndD |
995 +--------------------------------------------------------------------+
996
997 PURPOSE : set DTR behaviour.
998 */
999
1000 GLOBAL T_ACI_RETURN sAT_AndD ( T_ACI_CMD_SRC srcId, UBYTE value)
1001 {
1002 #ifdef FF_PSI
1003 T_ACI_DTI_PRC_PSI *dti_prc=find_element (psi_src_params,
1004 (UBYTE)srcId, cmhPSItest_srcId);
1005 #endif /*FF_PSI*/
1006 TRACE_FUNCTION ("sAT_AndD()");
1007 /*
1008 *-------------------------------------------------------------------
1009 * check command source
1010 *-------------------------------------------------------------------
1011 */
1012 if(!cmh_IsVldCmdSrc (srcId))
1013 {
1014 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1015 return( AT_FAIL );
1016 }
1017
1018 switch( value )
1019 {
1020 case( DTR_BEHAVIOUR_Ignore ):
1021 case( DTR_BEHAVIOUR_CommandMode ):
1022 case( DTR_BEHAVIOUR_ClearCall ):
1023 #ifdef FF_PSI
1024 if (dti_prc NEQ NULL)
1025 {
1026 psiShrdPrm.dtr_behaviour = value;
1027 TRACE_EVENT("device entry is in PSI");
1028 }
1029 else
1030 #endif /*FF_PSI*/
1031 {
1032 uartShrdPrm.dtr_behaviour = value;
1033 TRACE_EVENT("device entry is in UART");
1034 }
1035 break;
1036
1037 default:
1038 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1039 return( AT_FAIL );
1040 }
1041 return( AT_CMPL );
1042 }
1043
1044
1045 /*
1046 +--------------------------------------------------------------------+
1047 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS |
1048 | STATE : code ROUTINE : qAT_AndD |
1049 +--------------------------------------------------------------------+
1050
1051 PURPOSE : query DTR behaviour.
1052 */
1053
1054 GLOBAL T_ACI_RETURN qAT_AndD ( T_ACI_CMD_SRC srcId, UBYTE *value)
1055 {
1056 #ifdef FF_PSI
1057 T_ACI_DTI_PRC_PSI *dti_prc=find_element (psi_src_params, (UBYTE)srcId, cmhPSItest_srcId);
1058 #endif /*FF_PSI*/
1059 T_ACI_DTR_BEHAVIOUR dtr_behavior;
1060 TRACE_FUNCTION ("qAT_AndD()");
1061
1062 /*
1063 *-------------------------------------------------------------------
1064 * check command source
1065 *-------------------------------------------------------------------
1066 */
1067 if(!cmh_IsVldCmdSrc (srcId))
1068 {
1069 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1070 return( AT_FAIL );
1071 }
1072 #ifdef FF_PSI
1073 if (dti_prc NEQ NULL)
1074 dtr_behavior = psiShrdPrm.dtr_behaviour;
1075 else
1076 #endif /*FF_PSI*/
1077 dtr_behavior = uartShrdPrm.dtr_behaviour;
1078 switch( dtr_behavior )
1079 {
1080 case( DTR_BEHAVIOUR_Ignore ):
1081 case( DTR_BEHAVIOUR_CommandMode ):
1082 case( DTR_BEHAVIOUR_ClearCall ):
1083 *value = dtr_behavior;
1084 break;
1085
1086 default:
1087 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
1088 return( AT_FAIL );
1089 }
1090 return( AT_CMPL );
1091 }
1092
1093 GLOBAL void cmhUART_lst_exit(void)
1094 {
1095 T_ACI_LIST *src_infos = NULL;
1096
1097 while (1)
1098 {
1099 src_infos = (T_ACI_LIST *)remove_first_element (uart_src_params);
1100
1101 if (src_infos EQ NULL)
1102 {
1103 break;
1104 }
1105 ACI_MFREE (src_infos);
1106
1107 }
1108 }
1109 #endif /* ifdef UART */