FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/g23m-aci/aci/cmh_uarts.c @ 775:eedbf248bac0
gsm-fw/g23m-aci subtree: initial import from LoCosto source
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 12 Oct 2014 01:45:14 +0000 |
parents | |
children | c64bfc13292c |
comparison
equal
deleted
inserted
replaced
774:40a721fd9854 | 775:eedbf248bac0 |
---|---|
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 return (AT_FAIL); | |
155 } | |
156 | |
157 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId); | |
158 if (src_infos EQ NULL) | |
159 { | |
160 TRACE_EVENT_P1("[ERR] sAT_PlusCMUX(): srcId=%d not found", srcId) ; | |
161 return (AT_FAIL); | |
162 } | |
163 | |
164 /* | |
165 * AT+CMUX needs to get the answer OK before it sends the | |
166 * primitives to UART, because channel is then already closed. | |
167 */ | |
168 io_sendConfirm ( (UBYTE)srcId, cmdAtError ( atOk ), ATI_NORMAL_OUTPUT ); | |
169 cmdErrStr = NULL; | |
170 | |
171 ACI_MALLOC( src_infos ->MuxParms, sizeof(T_ACI_UART_MUX_PARMS) ); | |
172 | |
173 MuxParms = src_infos -> MuxParms; | |
174 /* memorize parameters */ | |
175 MuxParms->mode = mode; | |
176 MuxParms->subset = subset; | |
177 MuxParms->port_speed = port_speed; | |
178 MuxParms->N1 = N1; | |
179 MuxParms->T1 = T1; | |
180 MuxParms->N2 = N2; | |
181 MuxParms->T2 = T2; | |
182 MuxParms->T3 = T3; | |
183 | |
184 if ((src_infos->data_buffer.data_list EQ NULL) | |
185 AND (aci_src_dti_params[srcId].dtxState EQ READY) ) | |
186 { | |
187 uartEntcurCmd[srcId] = AT_CMD_NONE; | |
188 if ((cmhUART_CMUX (srcId)) EQ FALSE) | |
189 { | |
190 /* | |
191 * we already sent an OK according to GSM 27.010, but now the muxer is not ready ! | |
192 * this AT_FAIL results in a ATI_FAIL_NO_OUTPUT at function setatPlusCMUX(). | |
193 * so, what will the source do in this case ? | |
194 */ | |
195 TRACE_EVENT("[ERR] sAT_PlusCMUX()(): UART muxer not ready"); | |
196 return (AT_FAIL); | |
197 } | |
198 } | |
199 else | |
200 { | |
201 /*Now we wait for the dtx state to be ready and the multiplexer will be started | |
202 from function sig_dti_tx_buffer_ready_ind() after the data buffer of the source is | |
203 emptied*/ | |
204 uartEntcurCmd[srcId] = AT_CMD_CMUX; | |
205 } | |
206 return ( AT_EXCT ); | |
207 #else | |
208 return ( AT_FAIL ); | |
209 #endif /* DTI */ | |
210 | |
211 } | |
212 | |
213 GLOBAL T_ACI_RETURN qAT_PlusCMUX ( T_ACI_CMD_SRC srcId, | |
214 UBYTE *mode, | |
215 UBYTE *subset, | |
216 UBYTE *port_speed, | |
217 USHORT *N1, | |
218 UBYTE *T1, | |
219 UBYTE *N2, | |
220 UBYTE *T2, | |
221 UBYTE *T3 ) | |
222 { | |
223 TRACE_FUNCTION ("qAT_PlusCMUX()"); | |
224 | |
225 if ( (holdMuxParms.mode EQ 0) AND (holdMuxParms.subset EQ 0) AND | |
226 (holdMuxParms.port_speed EQ 0) AND (holdMuxParms.N1 EQ 0) AND | |
227 (holdMuxParms.T1 EQ 0) AND (holdMuxParms.N2 EQ 0) AND | |
228 (holdMuxParms.T2 EQ 0) AND (holdMuxParms.T3 EQ 0) ) | |
229 { | |
230 TRACE_FUNCTION("No Mux is enabled"); | |
231 return (AT_FAIL); | |
232 } | |
233 *mode = holdMuxParms.mode; | |
234 *subset = holdMuxParms.subset; | |
235 *port_speed = holdMuxParms.port_speed; | |
236 *N1 = holdMuxParms.N1; | |
237 *T1 = holdMuxParms.T1; | |
238 *N2 = holdMuxParms.N2; | |
239 *T2 = holdMuxParms.T2; | |
240 *T3 = holdMuxParms.T3; | |
241 | |
242 return ( AT_CMPL ); | |
243 } | |
244 | |
245 GLOBAL BOOL cmhUART_CMUX (T_ACI_CMD_SRC srcId) | |
246 { | |
247 T_ACI_DTI_PRC *src_infos = NULL; | |
248 T_ACI_BD_RATE speed = BD_RATE_NotPresent; | |
249 | |
250 TRACE_FUNCTION ("cmhUART_CMUX()"); | |
251 | |
252 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId); | |
253 | |
254 if (src_infos EQ NULL) | |
255 { | |
256 TRACE_EVENT_P1("[ERR] sAT_PlusCMUX(): srcId=%d not found", srcId) ; | |
257 return (FALSE); | |
258 } | |
259 | |
260 if (cmhUART_stopConnection ((UBYTE)srcId)) | |
261 { | |
262 if (src_infos->MuxParms) | |
263 { | |
264 speed = convert_mux_port_speed (src_infos->MuxParms->port_speed); | |
265 | |
266 if ( speed NEQ BD_RATE_NotPresent ) | |
267 { | |
268 /* | |
269 * at first we have to change the baud rate (primitive to UART) | |
270 */ | |
271 if (cmhUART_SetDataRate ((UBYTE)srcId, speed) EQ AT_EXCT) | |
272 { | |
273 return (TRUE); | |
274 } | |
275 else | |
276 { | |
277 TRACE_EVENT("[ERR] cmhUART_CMUX(): not able to change baud rate"); | |
278 return (FALSE); | |
279 } | |
280 } | |
281 /* | |
282 * void function, sends the UART_MUX_START_REQ primitive | |
283 * return value is handled by the confirmation | |
284 */ | |
285 psaUART_StartMux( src_infos->device, | |
286 src_infos->MuxParms->mode, | |
287 src_infos->MuxParms->subset, | |
288 src_infos->MuxParms->N1, | |
289 src_infos->MuxParms->T1, | |
290 src_infos->MuxParms->N2, | |
291 src_infos->MuxParms->T2, | |
292 src_infos->MuxParms->T3); | |
293 | |
294 memcpy( (CHAR *)&holdMuxParms, (CHAR *)src_infos->MuxParms, sizeof(T_ACI_UART_MUX_PARMS)); | |
295 ACI_MFREE( src_infos->MuxParms ); | |
296 src_infos->MuxParms = NULL; | |
297 return (TRUE); | |
298 } | |
299 else | |
300 { | |
301 TRACE_EVENT("[ERR] cmhUART_CMUX(): no muxer parameters available"); | |
302 } | |
303 } | |
304 else | |
305 { | |
306 TRACE_EVENT("[ERR] cmhUART_CMUX(): not able to stop UART connection"); | |
307 } | |
308 return (FALSE); | |
309 } | |
310 | |
311 /* | |
312 +-------------------------------------------------------------------+ | |
313 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIS | | |
314 | ROUTINE : cmhUART_getdata | | |
315 +-------------------------------------------------------------------+ | |
316 | |
317 PURPOSE : tell DTI that ACI is ready to receive more datas. | |
318 */ | |
319 GLOBAL void cmhUART_getdata ( T_ACI_CMD_SRC srcId ) | |
320 { | |
321 TRACE_FUNCTION ("cmhUART_getdata"); | |
322 | |
323 #ifdef RMV_01_04_03 | |
324 #ifdef FF_TWO_UART_PORTS | |
325 if (srcId NEQ UART_DATA_CHANNEL) | |
326 { | |
327 psaDTI_getdata ( (UBYTE)srcId, DTI_ENTITY_UART); | |
328 } | |
329 #else | |
330 psaDTI_getdata ( (UBYTE)srcId, DTI_ENTITY_UART); | |
331 #endif | |
332 #endif | |
333 | |
334 psaDTI_getdata ( (UBYTE)srcId, DTI_ENTITY_UART); | |
335 | |
336 } | |
337 | |
338 /* | |
339 +-------------------------------------------------------------------+ | |
340 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIS | | |
341 | ROUTINE : cmhUART_startConnection | | |
342 +-------------------------------------------------------------------+ | |
343 | |
344 PURPOSE : start a DTI connection with UART. | |
345 */ | |
346 | |
347 GLOBAL void cmhUART_startConnection (UBYTE srcId, | |
348 T_ACI_DEVICE_TYPE device_type) | |
349 { | |
350 T_ACI_DTI_PRC *src_infos; | |
351 T_ACI_DEVICE_ENTRY *device_entry; | |
352 T_ACI_DEVICE_TYPE curr_device_type; | |
353 T_DTI_ENTITY_ID entity_list[] = {DTI_ENTITY_ACI}; | |
354 | |
355 TRACE_FUNCTION ("cmhUART_startConnection ()"); | |
356 | |
357 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId); | |
358 if (src_infos EQ NULL) | |
359 { | |
360 TRACE_EVENT_P1("[ERR] cmhUART_startConnection: srcId=%d not found", | |
361 srcId) ; | |
362 return ; | |
363 } | |
364 | |
365 device_entry = cmhUART_GetDeviceParOverDevice( src_infos->device ); | |
366 | |
367 if ( device_entry EQ NULL ) | |
368 { | |
369 TRACE_EVENT_P1("[ERR] cmhUART_startConnection: device=%d not found", src_infos->device) ; | |
370 return; | |
371 } | |
372 | |
373 curr_device_type = cmhUART_GetDeviceType (srcId); | |
374 | |
375 switch (curr_device_type) | |
376 { | |
377 case DEVICE_TYPE_UNKNOWN: | |
378 /* register device to the DTI Control Manager */ | |
379 #ifdef DTI | |
380 dti_cntrl_new_device ( srcId, /* ATI source ID */ | |
381 DTI_ENTITY_UART, /* device ID */ | |
382 src_infos->device, /* device number */ | |
383 src_infos->dlci, /* sub-channel number */ | |
384 DTI_PORT_NUMBER_NOTPRESENT, /* ATI-RIV port number */ | |
385 DTI_CPBLTY_CMD | DTI_CPBLTY_SER, /* capabilities */ | |
386 DTI_DRIVER_ID_NOTPRESENT, | |
387 DTI_DIO_ID_NOTPRESENT); | |
388 | |
389 #endif /* DTI */ | |
390 /* set device type */ | |
391 cmhUART_ChangeDeviceType (srcId, device_type); | |
392 break; | |
393 | |
394 default: | |
395 break; | |
396 } /* switch */ | |
397 | |
398 if (device_type EQ DEVICE_TYPE_URT) | |
399 { | |
400 /* initialize UART */ | |
401 psaUART_SetParameters (src_infos->device, &device_entry->comPar); | |
402 /* has to wait for confirmation before setting DTI channel */ | |
403 return; | |
404 } | |
405 #ifdef DTI | |
406 /* request of a DTI channel to communicate with UART */ | |
407 dti_cntrl_est_dpath_indirect ( src_infos->srcId, | |
408 entity_list, | |
409 1, | |
410 SPLIT, | |
411 atiUART_dti_cb, | |
412 DTI_CPBLTY_CMD, | |
413 DTI_CID_NOTPRESENT); | |
414 #endif | |
415 } | |
416 /* | |
417 +-------------------------------------------------------------------+ | |
418 | PROJECT : GSM-PS (6147) MODULE : CMH_DTIS | | |
419 | ROUTINE : cmhUART_stopConnection | | |
420 +-------------------------------------------------------------------+ | |
421 | |
422 PURPOSE : stop a DTI connection with UART. | |
423 */ | |
424 GLOBAL BOOL cmhUART_stopConnection (UBYTE srcId) | |
425 { | |
426 T_ACI_DTI_PRC *src_infos; | |
427 | |
428 TRACE_FUNCTION ("cmhUART_stopConnection()"); | |
429 | |
430 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId); | |
431 if (src_infos EQ NULL) | |
432 { | |
433 TRACE_EVENT_P1("[ERR] cmhUART_stopConnection: srcId=%d not found", | |
434 srcId) ; | |
435 return (FALSE); | |
436 } | |
437 | |
438 src_infos->LineState = LINE_DISCONNECTED; | |
439 | |
440 if (cmhUART_ChangeDeviceType (src_infos->srcId, DEVICE_TYPE_UNKNOWN)) | |
441 { | |
442 #ifdef DTI | |
443 if (dti_cntrl_close_dpath_from_src_id( srcId )) | |
444 { | |
445 return (TRUE); | |
446 } | |
447 #endif | |
448 } | |
449 | |
450 return (FALSE); | |
451 } | |
452 | |
453 /* | |
454 +--------------------------------------------------------------------+ | |
455 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS | | |
456 | STATE : code ROUTINE : sAT_PlusIPR | | |
457 +--------------------------------------------------------------------+ | |
458 | |
459 PURPOSE : This is the functional counterpart to the +IPR AT command | |
460 which is responsible to set the data rate. | |
461 */ | |
462 | |
463 GLOBAL void cmhUART_init_ipr_params(void) | |
464 { | |
465 TRACE_FUNCTION ("cmhUART_init_ipr_params()"); | |
466 | |
467 uart_ipr_param.srcId = CMD_SRC_NONE; | |
468 uart_ipr_param.rate = BD_RATE_NotPresent; | |
469 } | |
470 | |
471 GLOBAL T_ACI_RETURN sAT_PlusIPR(T_ACI_CMD_SRC srcId, T_ACI_BD_RATE rate) | |
472 { | |
473 ULONG ipr_timer = 0; | |
474 | |
475 TRACE_FUNCTION ("sAT_PlusIPR()"); | |
476 | |
477 /* check command source */ | |
478 if(srcId EQ CMD_SRC_LCL) | |
479 { | |
480 TRACE_ERROR("This command is not supported for local command source"); | |
481 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotSupp ); | |
482 return AT_FAIL; | |
483 } | |
484 if(!cmh_IsVldCmdSrc (srcId)) | |
485 { | |
486 return AT_FAIL; | |
487 } | |
488 | |
489 /* parameter check */ | |
490 if ( rate < BD_RATE_AUTO OR rate > BD_RATE_115200 ) /* maximum supported value by UART */ | |
491 { | |
492 ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_OpNotSupp ); | |
493 return AT_FAIL; | |
494 } | |
495 | |
496 /* We need to sent the OK prior we switch to the new baudrate */ | |
497 io_sendConfirm((UBYTE)srcId, cmdAtError(atOk), ATI_NORMAL_OUTPUT); | |
498 cmdErrStr = NULL; | |
499 | |
500 uart_ipr_param.rate = rate; | |
501 uart_ipr_param.srcId = srcId; | |
502 | |
503 ipr_timer = 600; /* worst case calculation: 4 characters:OK<CR><LF> at 75bit/s | |
504 with 1 startbit, 1 paritybit and 1 stopbit (2 stopbits are only used for longer words) | |
505 4*(8+1+1+1)= 44 bits => 44/75 seconds = 586 msec*/ | |
506 | |
507 /* time for output "OK" then send changed parameter to UART */ | |
508 uartEntcurCmd[srcId] = AT_CMD_IPR; | |
509 TIMERSTART(ipr_timer, ACI_IPR); | |
510 | |
511 return AT_CMPL; | |
512 } | |
513 | |
514 | |
515 /* | |
516 +--------------------------------------------------------------------+ | |
517 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS | | |
518 | STATE : code ROUTINE : timeout_PlusIPR | | |
519 +--------------------------------------------------------------------+ | |
520 | |
521 PURPOSE : This function send the changed baudrate to UART after | |
522 the timer ACI_IPR is expired | |
523 */ | |
524 | |
525 GLOBAL void timeout_PlusIPR ( void) | |
526 { | |
527 #ifdef FF_PSI | |
528 T_ACI_DTI_PRC_PSI *src_infos = find_element (psi_src_params, | |
529 (UBYTE)uart_ipr_param.srcId, cmhPSItest_srcId); | |
530 #endif /*FF_PSI*/ | |
531 TRACE_FUNCTION ("timeout_PlusIPR()"); | |
532 #ifdef FF_PSI | |
533 if ( src_infos NEQ NULL ) | |
534 { | |
535 cmhPSI_SetDataRate((UBYTE)uart_ipr_param.srcId, uart_ipr_param.rate); | |
536 } | |
537 /* force parameter request */ | |
538 else | |
539 #endif /*FF_PSI*/ | |
540 cmhUART_SetDataRate((UBYTE)uart_ipr_param.srcId, uart_ipr_param.rate); | |
541 | |
542 cmhUART_init_ipr_params(); | |
543 uartEntcurCmd[uart_ipr_param.srcId] = AT_CMD_NONE; | |
544 } | |
545 | |
546 /* | |
547 +--------------------------------------------------------------------+ | |
548 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS | | |
549 | STATE : code ROUTINE : qAT_PlusIPR | | |
550 +--------------------------------------------------------------------+ | |
551 | |
552 PURPOSE : This is the functional counterpart to the +IPR? AT command | |
553 which returns the current setting for the data rate. | |
554 | |
555 */ | |
556 GLOBAL T_ACI_RETURN qAT_PlusIPR ( T_ACI_CMD_SRC srcId, T_ACI_BD_RATE *rate) | |
557 { | |
558 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( (UBYTE) srcId ); | |
559 #ifdef FF_PSI | |
560 T_ACI_DEVICE_DCB_ENTRY *device_dcb_entry; | |
561 U32 device_type;/* RM 26-05-04 Nice */ | |
562 #endif /*FF_PSI*/ | |
563 TRACE_FUNCTION ("qAT_PlusIPR()"); | |
564 | |
565 if ( device_entry EQ NULL ) | |
566 { | |
567 #ifdef FF_PSI | |
568 device_dcb_entry = cmhPSI_GetDeviceParOverSrcID( (UBYTE) srcId ); | |
569 if (device_dcb_entry EQ NULL) | |
570 #endif /*FF_PSI*/ | |
571 return AT_FAIL; | |
572 #ifdef FF_PSI | |
573 else | |
574 { | |
575 device_type = device_dcb_entry->devId & DIO_TYPE_DAT_MASK;/* RM 26-05-04 Nice */ | |
576 if (device_type EQ DIO_DATA_SER)/* RM 26-05-04 Nice */ | |
577 *rate = (T_ACI_BD_RATE)device_dcb_entry->dcbPar.dio_dcb_ser.baudrate; | |
578 if (device_type EQ DIO_DATA_MUX)/* RM 26-05-04 Nice */ | |
579 *rate = (T_ACI_BD_RATE)device_dcb_entry->dcbPar.dio_dcb_ser_mux.baudrate; | |
580 else if (device_type EQ DIO_DATA_PKT)/* RM 26-05-04 Nice */ | |
581 return AT_FAIL; | |
582 return( AT_CMPL ); | |
583 } | |
584 #endif /*FF_PSI*/ | |
585 } | |
586 /* | |
587 *------------------------------------------------------------------- | |
588 * fill in parameters | |
589 *------------------------------------------------------------------- | |
590 */ | |
591 *rate = (T_ACI_BD_RATE) device_entry->comPar.speed; | |
592 | |
593 return( AT_CMPL ); | |
594 } | |
595 | |
596 /* | |
597 +--------------------------------------------------------------------+ | |
598 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS | | |
599 | STATE : code ROUTINE : sAT_PlusICF | | |
600 +--------------------------------------------------------------------+ | |
601 | |
602 PURPOSE : This is the functional counterpart to the +ICF AT command | |
603 which is responsible to set the character framing. | |
604 */ | |
605 | |
606 GLOBAL T_ACI_RETURN sAT_PlusICF ( T_ACI_CMD_SRC srcId, | |
607 T_ACI_BS_FRM format, | |
608 T_ACI_BS_PAR parity) | |
609 { | |
610 #ifdef FF_PSI | |
611 T_ACI_DTI_PRC_PSI *src_infos = find_element (psi_src_params, | |
612 (UBYTE) srcId, cmhPSItest_srcId); | |
613 #endif /*FF_PSI*/ | |
614 TRACE_FUNCTION ("sAT_PlusICF()"); | |
615 | |
616 /* | |
617 *------------------------------------------------------------------- | |
618 * parameter check | |
619 *------------------------------------------------------------------- | |
620 */ | |
621 switch( format ) | |
622 { | |
623 case( BS_FRM_NotPresent ): | |
624 case( BS_FRM_Dat8_Par0_St2 ): | |
625 case( BS_FRM_Dat8_Par1_St1 ): | |
626 case( BS_FRM_Dat8_Par0_St1 ): | |
627 case( BS_FRM_Dat7_Par0_St2 ): | |
628 case( BS_FRM_Dat7_Par1_St1 ): | |
629 case( BS_FRM_Dat7_Par0_St1 ): | |
630 | |
631 break; | |
632 | |
633 default: | |
634 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
635 return( AT_FAIL ); | |
636 } | |
637 | |
638 switch( parity ) | |
639 { | |
640 case( BS_PAR_NotPresent ): | |
641 case( BS_PAR_Odd ): | |
642 case( BS_PAR_Even ): | |
643 case( BS_PAR_Mark ): | |
644 case( BS_PAR_Space ): | |
645 | |
646 break; | |
647 | |
648 default: | |
649 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
650 return( AT_FAIL ); | |
651 } | |
652 | |
653 /* | |
654 *------------------------------------------------------------------- | |
655 * force parameter request | |
656 *------------------------------------------------------------------- | |
657 */ | |
658 #ifdef FF_PSI | |
659 if ( src_infos NEQ NULL ) | |
660 { | |
661 if ( AT_EXCT EQ cmhPSI_SetCharacterFraming((UBYTE) srcId, format, parity) ) | |
662 { | |
663 uartEntcurCmd[srcId] = AT_CMD_ICF; | |
664 return AT_EXCT; | |
665 } | |
666 } | |
667 /* force parameter request */ | |
668 else | |
669 #endif /*FF_PSI*/ | |
670 { | |
671 if ( AT_EXCT EQ cmhUART_SetCharacterFraming((UBYTE) srcId, format, parity) ) | |
672 { | |
673 uartEntcurCmd[srcId] = AT_CMD_ICF; | |
674 return AT_EXCT; | |
675 } | |
676 } | |
677 return AT_FAIL; | |
678 } | |
679 | |
680 /* | |
681 +--------------------------------------------------------------------+ | |
682 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS | | |
683 | STATE : code ROUTINE : qAT_PlusICF | | |
684 +--------------------------------------------------------------------+ | |
685 | |
686 PURPOSE : This is the functional counterpart to the +ICF? AT command | |
687 which returns the current setting for character framing. | |
688 | |
689 */ | |
690 | |
691 GLOBAL T_ACI_RETURN qAT_PlusICF ( T_ACI_CMD_SRC srcId, | |
692 T_ACI_BS_FRM *format, | |
693 T_ACI_BS_PAR *parity) | |
694 { | |
695 T_ACI_DEVICE_ENTRY *device_entry = | |
696 cmhUART_GetDeviceParOverSrcID( (UBYTE) srcId ); | |
697 #ifdef FF_PSI | |
698 T_ACI_DEVICE_DCB_ENTRY *device_dcb_entry = | |
699 cmhPSI_GetDeviceParOverSrcID( (UBYTE) srcId ); | |
700 #endif /*FF_PSI*/ | |
701 TRACE_FUNCTION ("qAT_PlusICF()"); | |
702 #ifdef FF_PSI | |
703 if (device_entry EQ NULL AND device_dcb_entry EQ NULL) | |
704 #else | |
705 if (device_entry EQ NULL) | |
706 #endif /*FF_PSI*/ | |
707 { | |
708 return AT_FAIL; | |
709 } | |
710 #ifdef FF_PSI | |
711 if ( device_entry EQ NULL AND device_dcb_entry NEQ NULL ) | |
712 { | |
713 *format = cmhPSI_GetFktInterfaceFormat(device_dcb_entry); | |
714 *parity = cmhPSI_GetFktInterfaceParity(device_dcb_entry); | |
715 return( AT_CMPL ); | |
716 } | |
717 #endif /*FF_PSI*/ | |
718 | |
719 /* | |
720 *------------------------------------------------------------------- | |
721 * fill in parameters | |
722 *------------------------------------------------------------------- | |
723 */ | |
724 /*lint -e613 (Warning --Possible use of null pointer) */ | |
725 *format = cmhUART_GetFktInterfaceFormat(&(device_entry->comPar)); | |
726 | |
727 *parity = cmhUART_GetFktInterfaceParity(&(device_entry->comPar)); | |
728 /*lint +e613 (Warning --Possible use of null pointer) */ | |
729 | |
730 return( AT_CMPL ); | |
731 } | |
732 | |
733 /* | |
734 +--------------------------------------------------------------------+ | |
735 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS | | |
736 | STATE : code ROUTINE : sAT_PlusIFC | | |
737 +--------------------------------------------------------------------+ | |
738 | |
739 PURPOSE : This is the functional counterpart to the +IFC AT command | |
740 which is responsible to set the flow control. | |
741 */ | |
742 | |
743 GLOBAL T_ACI_RETURN sAT_PlusIFC ( T_ACI_CMD_SRC srcId, | |
744 T_ACI_RX_FLOW_CTRL DCE_by_DTE, | |
745 T_ACI_RX_FLOW_CTRL DTE_by_DCE ) | |
746 { | |
747 #ifdef FF_PSI | |
748 T_ACI_DTI_PRC_PSI *src_infos = find_element (psi_src_params, (UBYTE) srcId, cmhPSItest_srcId); | |
749 #endif /*FF_PSI*/ | |
750 T_ACI_RETURN result = AT_FAIL; | |
751 TRACE_FUNCTION ("sAT_PlusIFC()"); | |
752 | |
753 /* | |
754 *------------------------------------------------------------------- | |
755 * parameter check | |
756 *------------------------------------------------------------------- | |
757 */ | |
758 TRACE_EVENT_P2("sAT_PlusIFC: DCE_by_DTE=%d DTE_by_DCE=%d", DCE_by_DTE, DTE_by_DCE); | |
759 | |
760 if ( DCE_by_DTE < RX_FLOW_NotPresent OR DCE_by_DTE > RX_FLOW_HARDWARE ) | |
761 { | |
762 TRACE_EVENT("sAT_PlusIFC: err1"); | |
763 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
764 return AT_FAIL; | |
765 } | |
766 | |
767 if ( DTE_by_DCE < RX_FLOW_NotPresent OR DTE_by_DCE > RX_FLOW_HARDWARE) | |
768 { | |
769 TRACE_EVENT("sAT_PlusIFC: err2"); | |
770 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
771 return AT_FAIL; | |
772 } | |
773 | |
774 if ( DTE_by_DCE NEQ RX_FLOW_NotPresent AND DCE_by_DTE NEQ DTE_by_DCE ) | |
775 { | |
776 TRACE_EVENT("sAT_PlusIFC: err3"); | |
777 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
778 return AT_FAIL; | |
779 } | |
780 | |
781 /* | |
782 *------------------------------------------------------------------- | |
783 * force parameter request | |
784 *------------------------------------------------------------------- | |
785 */ | |
786 #ifdef FF_PSI | |
787 if (src_infos NEQ NULL) | |
788 result = cmhPSI_SetFlowControl((UBYTE) srcId, DCE_by_DTE); | |
789 else | |
790 #endif /*FF_PSI*/ | |
791 result = cmhUART_SetFlowControl((UBYTE) srcId, DCE_by_DTE); | |
792 switch (result) | |
793 { | |
794 case AT_EXCT: | |
795 uartEntcurCmd[srcId] = AT_CMD_IFC; | |
796 return AT_EXCT; | |
797 case AT_CMPL: | |
798 return AT_CMPL; | |
799 } | |
800 return result; | |
801 } | |
802 | |
803 /* | |
804 +--------------------------------------------------------------------+ | |
805 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS | | |
806 | STATE : code ROUTINE : qAT_PlusIFC | | |
807 +--------------------------------------------------------------------+ | |
808 | |
809 PURPOSE : This is the functional counterpart to the +ICF? AT command | |
810 which returns the current setting for character framing. | |
811 | |
812 */ | |
813 | |
814 GLOBAL T_ACI_RETURN qAT_PlusIFC ( T_ACI_CMD_SRC srcId, | |
815 T_ACI_RX_FLOW_CTRL *DCE_by_DTE, | |
816 T_ACI_RX_FLOW_CTRL *DTE_by_DCE ) | |
817 { | |
818 S32 flow_cntrl = RX_FLOW_NotPresent; | |
819 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( (UBYTE) srcId ); | |
820 #ifdef FF_PSI | |
821 T_ACI_DEVICE_DCB_ENTRY *device_dcb_entry = NULL; | |
822 U32 device_type;/* RM 26-05-04 Nice */ | |
823 #endif /*FF_PSI*/ | |
824 TRACE_FUNCTION ("qAT_PlusIFC()"); | |
825 | |
826 if ( device_entry EQ NULL ) | |
827 { | |
828 #ifdef FF_PSI | |
829 if ( (device_dcb_entry = cmhPSI_GetDeviceParOverSrcID( (UBYTE) srcId )) EQ NULL) | |
830 #endif /*FF_PSI*/ | |
831 return AT_FAIL; | |
832 #ifdef FF_PSI | |
833 device_type = device_dcb_entry->devId & DIO_TYPE_DAT_MASK;/* RM 26-05-04 Nice */ | |
834 if (device_type EQ DIO_DATA_PKT)/* RM 26-05-04 Nice */ | |
835 return AT_FAIL; | |
836 if (device_type EQ DIO_DATA_SER)/* RM 26-05-04 Nice */ | |
837 flow_cntrl = device_dcb_entry->dcbPar.dio_dcb_ser.flow_control; | |
838 if (device_type EQ DIO_DATA_MUX)/* RM 26-05-04 Nice */ | |
839 flow_cntrl = device_dcb_entry->dcbPar.dio_dcb_ser_mux.flow_control; | |
840 | |
841 switch ( flow_cntrl ) | |
842 { | |
843 case (DIO_FLOW_NONE): | |
844 default: | |
845 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_NONE; | |
846 break; | |
847 case (DIO_FLOW_XON_XOFF): | |
848 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_SOFTWARE; | |
849 break; | |
850 case ( DIO_FLOW_RTS_CTS): | |
851 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_HARDWARE; | |
852 break; | |
853 } | |
854 return( AT_CMPL ); | |
855 #endif /*FF_PSI*/ | |
856 } | |
857 | |
858 /* | |
859 *------------------------------------------------------------------- | |
860 * fill in parameters | |
861 *------------------------------------------------------------------- | |
862 */ | |
863 switch ( device_entry->comPar.flow_rx ) | |
864 { | |
865 case UART_IO_FC_RX_NONE: | |
866 default: | |
867 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_NONE; | |
868 break; | |
869 case UART_IO_FC_RX_XOFF: | |
870 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_SOFTWARE; | |
871 break; | |
872 case UART_IO_FC_RX_RTS: | |
873 *DCE_by_DTE = *DTE_by_DCE = RX_FLOW_HARDWARE; | |
874 break; | |
875 } | |
876 | |
877 return( AT_CMPL ); | |
878 } | |
879 | |
880 | |
881 /* | |
882 +--------------------------------------------------------------------+ | |
883 | PROJECT : GSM-PS (6147) MODULE : CMH_CCS | | |
884 | STATE : code ROUTINE : sAT_AndC | | |
885 +--------------------------------------------------------------------+ | |
886 | |
887 PURPOSE : set DCD behaviour | |
888 */ | |
889 | |
890 GLOBAL T_ACI_RETURN sAT_AndC ( T_ACI_CMD_SRC srcId, | |
891 T_ACI_DCD_MOD value ) | |
892 { | |
893 BOOL no_data_call_on_this_line = TRUE; | |
894 UBYTE i; | |
895 | |
896 TRACE_FUNCTION ("sAT_AndC()"); | |
897 | |
898 /* check command source */ | |
899 if(!cmh_IsVldCmdSrc (srcId)) | |
900 { | |
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(MNCC_BEARER_SERV_NOT_PRES): | |
935 case(MNCC_BEARER_SERV_SPEECH): | |
936 case(MNCC_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 return( AT_FAIL ); | |
974 } | |
975 | |
976 /* check parameter value */ | |
977 if( value EQ NULL ) | |
978 { | |
979 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
980 return( AT_FAIL ); | |
981 } | |
982 | |
983 /* query DCD behaviour */ | |
984 *value = cmhPrm[srcId ].ccCmdPrm.DCDmode; | |
985 | |
986 return( AT_CMPL ); | |
987 } | |
988 | |
989 | |
990 /* | |
991 +--------------------------------------------------------------------+ | |
992 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS | | |
993 | STATE : code ROUTINE : sAT_AndD | | |
994 +--------------------------------------------------------------------+ | |
995 | |
996 PURPOSE : set DTR behaviour. | |
997 */ | |
998 | |
999 GLOBAL T_ACI_RETURN sAT_AndD ( T_ACI_CMD_SRC srcId, UBYTE value) | |
1000 { | |
1001 #ifdef FF_PSI | |
1002 T_ACI_DTI_PRC_PSI *dti_prc=find_element (psi_src_params, | |
1003 (UBYTE)srcId, cmhPSItest_srcId); | |
1004 #endif /*FF_PSI*/ | |
1005 TRACE_FUNCTION ("sAT_AndD()"); | |
1006 /* | |
1007 *------------------------------------------------------------------- | |
1008 * check command source | |
1009 *------------------------------------------------------------------- | |
1010 */ | |
1011 if(!cmh_IsVldCmdSrc (srcId)) | |
1012 { | |
1013 return( AT_FAIL ); | |
1014 } | |
1015 | |
1016 switch( value ) | |
1017 { | |
1018 case( DTR_BEHAVIOUR_Ignore ): | |
1019 case( DTR_BEHAVIOUR_CommandMode ): | |
1020 case( DTR_BEHAVIOUR_ClearCall ): | |
1021 #ifdef FF_PSI | |
1022 if (dti_prc NEQ NULL) | |
1023 { | |
1024 psiShrdPrm.dtr_behaviour = (T_ACI_DTR_BEHAVIOUR)value; | |
1025 TRACE_EVENT("device entry is in PSI"); | |
1026 } | |
1027 else | |
1028 #endif /*FF_PSI*/ | |
1029 { | |
1030 uartShrdPrm.dtr_behaviour = (T_ACI_DTR_BEHAVIOUR)value; | |
1031 TRACE_EVENT("device entry is in UART"); | |
1032 } | |
1033 break; | |
1034 | |
1035 default: | |
1036 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1037 return( AT_FAIL ); | |
1038 } | |
1039 return( AT_CMPL ); | |
1040 } | |
1041 | |
1042 | |
1043 /* | |
1044 +--------------------------------------------------------------------+ | |
1045 | PROJECT : GSM-PS (6147) MODULE : CMH_UARTS | | |
1046 | STATE : code ROUTINE : qAT_AndD | | |
1047 +--------------------------------------------------------------------+ | |
1048 | |
1049 PURPOSE : query DTR behaviour. | |
1050 */ | |
1051 | |
1052 GLOBAL T_ACI_RETURN qAT_AndD ( T_ACI_CMD_SRC srcId, UBYTE *value) | |
1053 { | |
1054 #ifdef FF_PSI | |
1055 T_ACI_DTI_PRC_PSI *dti_prc=find_element (psi_src_params, (UBYTE)srcId, cmhPSItest_srcId); | |
1056 #endif /*FF_PSI*/ | |
1057 T_ACI_DTR_BEHAVIOUR dtr_behavior; | |
1058 TRACE_FUNCTION ("qAT_AndD()"); | |
1059 | |
1060 /* | |
1061 *------------------------------------------------------------------- | |
1062 * check command source | |
1063 *------------------------------------------------------------------- | |
1064 */ | |
1065 if(!cmh_IsVldCmdSrc (srcId)) | |
1066 { | |
1067 return( AT_FAIL ); | |
1068 } | |
1069 #ifdef FF_PSI | |
1070 if (dti_prc NEQ NULL) | |
1071 dtr_behavior = psiShrdPrm.dtr_behaviour; | |
1072 else | |
1073 #endif /*FF_PSI*/ | |
1074 dtr_behavior = uartShrdPrm.dtr_behaviour; | |
1075 switch( dtr_behavior ) | |
1076 { | |
1077 case( DTR_BEHAVIOUR_Ignore ): | |
1078 case( DTR_BEHAVIOUR_CommandMode ): | |
1079 case( DTR_BEHAVIOUR_ClearCall ): | |
1080 *value = dtr_behavior; | |
1081 break; | |
1082 | |
1083 default: | |
1084 ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter ); | |
1085 return( AT_FAIL ); | |
1086 } | |
1087 return( AT_CMPL ); | |
1088 } | |
1089 | |
1090 GLOBAL void cmhUART_lst_exit(void) | |
1091 { | |
1092 T_ACI_LIST *src_infos = NULL; | |
1093 | |
1094 while (1) | |
1095 { | |
1096 src_infos = (T_ACI_LIST *)remove_first_element (uart_src_params); | |
1097 | |
1098 if (src_infos EQ NULL) | |
1099 { | |
1100 break; | |
1101 } | |
1102 ACI_MFREE (src_infos); | |
1103 | |
1104 } | |
1105 } | |
1106 #endif /* ifdef UART */ |