comparison g23m-aci/aci/cmh_uartf.c @ 0:75a11d740a02

initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 09 Jun 2016 00:02:41 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:75a11d740a02
1 /*
2 +-----------------------------------------------------------------------------
3 | Project : GSM-PS (6147)
4 | Modul : CMH_UARTF
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 : This module defines the functions used by the command
18 | handler for the UART module.
19 +-----------------------------------------------------------------------------
20 */
21
22 #include "config.h"
23 #include "fixedconf.h"
24 #include "condat-features.h"
25 #include "aci_conf.h"
26
27 #ifdef UART
28
29 #ifndef CMH_UARTF_C
30 #define CMH_UARTF_C
31 #endif
32
33 #include "aci_all.h"
34 /*==== INCLUDES ===================================================*/
35 #include "aci_cmh.h"
36 #include "ati_cmd.h"
37 #include "aci_cmd.h"
38 #include "dti.h" /* functionality of the dti library */
39
40 #include "aci_lst.h"
41
42 #include "dti_conn_mng.h"
43 #include "psa_uart.h"
44 #include "cmh_uart.h"
45 #include "aci_mem.h"
46
47 /*
48 +--------------------------------------------------------------------+
49 | PROJECT : GSM-F&D (8411) MODULE : ACI_LST |
50 | STATE : code ROUTINE : cmhUARTtest_srcId |
51 +--------------------------------------------------------------------+
52
53 PURPOSE : search function for source Id in the structure T_ACI_DTI_PRC.
54
55 */
56
57 GLOBAL BOOL cmhUARTtest_srcId( UBYTE srcId, void *elem)
58 {
59 T_ACI_DTI_PRC *compared = (T_ACI_DTI_PRC *)elem;
60
61 if (compared -> srcId EQ srcId )
62 return TRUE;
63 else
64 return FALSE;
65 }
66
67 /*
68 +--------------------------------------------------------------------+
69 | PROJECT : GSM-F&D (8411) MODULE : ACI_LST |
70 | STATE : code ROUTINE : cmhUARTtest_device |
71 +--------------------------------------------------------------------+
72
73 PURPOSE : search function for device number in the structure T_ACI_DTI_PRC.
74
75 */
76
77 GLOBAL BOOL cmhUARTtest_device (UBYTE device, void *elem)
78 {
79 T_ACI_DTI_PRC *compared = (T_ACI_DTI_PRC *)elem;
80
81 if (compared -> device EQ device )
82 return TRUE;
83 else
84 return FALSE;
85 }
86
87 /*
88 +--------------------------------------------------------------------+
89 | PROJECT : GSM-F&D (8411) MODULE : ACI_LST |
90 | STATE : code ROUTINE : cmhUART_find_dlci |
91 +--------------------------------------------------------------------+
92
93 PURPOSE : returns element with corresponding dlci and device.
94
95 If called dlci=UART_DLCI_NOT_MULTIPLEXED (UART entity
96 value for device not multiplexed) then function returns
97 element with corresponding device...
98
99 */
100 GLOBAL T_ACI_DTI_PRC *cmhUART_find_dlci (T_ACI_LIST *search_list,
101 UBYTE device, UBYTE dlci)
102 {
103 T_ACI_DTI_PRC *content = NULL;
104
105 if (search_list EQ NULL)
106 return NULL;
107
108 do
109 {
110 content = find_next_element (search_list, content, device,
111 cmhUARTtest_device);
112 if (content EQ NULL)
113 return NULL;
114
115 if( dlci EQ UART_DLCI_NOT_MULTIPLEXED OR
116 content->dlci EQ UART_DLCI_NOT_MULTIPLEXED OR
117 content->dlci EQ dlci)
118 return content;
119 }
120 while (content NEQ NULL);
121
122 return NULL;
123 }
124
125 /*
126 +--------------------------------------------------------------------+
127 | PROJECT : GSM-F&D (8411) MODULE : ACI_LST |
128 | STATE : code ROUTINE : cmhUART_erase_elem_received_cmd |
129 +--------------------------------------------------------------------+
130
131 PURPOSE : erase an entry element from the uart_src_params list.
132
133 */
134
135 GLOBAL void cmhUART_erase_elem_received_cmd (UBYTE srcId)
136 {
137 T_ACI_DTI_PRC *content;
138
139 /* find element to be erased */
140 content = remove_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId);
141
142 ACI_MFREE (content);
143 }
144
145 /*********************************************************
146 //////////////////////////////////////////////////////////
147 TEMP: rests from aci_urt.c
148
149 ready for remove? */
150
151 GLOBAL BOOL atiViaTif = FALSE;
152
153 /********************************************************
154 ///////////////////////////////////////////////////////// */
155
156 /*
157 +--------------------------------------------------------------------+
158 | PROJECT : GSM-F&D (8411) MODULE : ACI_URT |
159 | STATE : code ROUTINE : urt_init |
160 +--------------------------------------------------------------------+
161
162 PURPOSE : initialize the module and the UART
163
164 */
165
166 GLOBAL void urt_init (void)
167 {
168 TRACE_FUNCTION ("urt_init()");
169
170 }
171
172 /*
173 +--------------------------------------------------------------------------------------------+
174 | PROJECT : GSM-F&D (8411) MODULE : ACI_URT |
175 | STATE : code ROUTINE : cmhUART_translateBD_RATE_to_UART_IO_SPEED |
176 +--------------------------------------------------------------------------------------------+
177
178 PURPOSE:
179 */
180
181 LOCAL UBYTE cmhUART_translateBD_RATE_to_UART_IO_SPEED ( T_ACI_BD_RATE rate )
182 {
183
184 switch ( rate )
185 {
186 case BD_RATE_AUTO: return UART_IO_SPEED_AUTO;
187 case BD_RATE_75: return UART_IO_SPEED_75;
188 case BD_RATE_150: return UART_IO_SPEED_150;
189 case BD_RATE_300: return UART_IO_SPEED_300;
190 case BD_RATE_600: return UART_IO_SPEED_600;
191 case BD_RATE_1200: return UART_IO_SPEED_1200;
192 case BD_RATE_2400: return UART_IO_SPEED_2400;
193 case BD_RATE_4800: return UART_IO_SPEED_4800;
194 case BD_RATE_7200: return UART_IO_SPEED_7200;
195 case BD_RATE_9600: return UART_IO_SPEED_9600;
196 case BD_RATE_14400: return UART_IO_SPEED_14400;
197 case BD_RATE_19200: return UART_IO_SPEED_19200;
198 case BD_RATE_28800: return UART_IO_SPEED_28800;
199 case BD_RATE_33900: return UART_IO_SPEED_33900;
200 case BD_RATE_38400: return UART_IO_SPEED_38400;
201 case BD_RATE_57600: return UART_IO_SPEED_57600;
202 case BD_RATE_115200: return UART_IO_SPEED_115200;
203 case BD_RATE_203125: return UART_IO_SPEED_203125;
204 case BD_RATE_406250: return UART_IO_SPEED_406250;
205 case BD_RATE_812500: return UART_IO_SPEED_812500;
206 default: return UART_IO_SPEED_UNDEF;
207 }
208 }
209
210 /*
211 +-----------------------------------------------------------------------------+
212 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
213 | STATE : code ROUTINE : cmhUART_comParFindDevice |
214 +-----------------------------------------------------------------------------+
215
216 PURPOSE: Finding the device entry in the 'uart_com_par' table
217
218 */
219 LOCAL BOOL cmhUART_comParFindDevice (UBYTE criterium, void *elem)
220 {
221 if ( criterium EQ ((T_ACI_DEVICE_ENTRY*)elem)->device )
222 return TRUE;
223
224 return FALSE;
225 }
226
227 /*
228 +-----------------------------------------------------------------------------+
229 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
230 | STATE : code ROUTINE : cmhUART_FindAll |
231 +-----------------------------------------------------------------------------+
232
233 PURPOSE: Find every entry
234
235 */
236 LOCAL BOOL cmhUART_FindAll (UBYTE criterium, void *elem)
237 {
238 return TRUE;
239 }
240
241 LOCAL T_ACI_UART_COM_PAR cmhUART_getDefaultUARTParameter(void)
242 {
243 T_ACI_UART_COM_PAR comPar =
244 {
245 UART_IO_SPEED_115200,
246 UART_IO_BPC_8,
247 UART_IO_SB_1,
248 UART_IO_PA_NONE,
249 UART_IO_FC_RX_RTS,
250 UART_IO_FC_TX_RTS,
251 UART_IO_XON_VALID,
252 UART_IO_XON_DEFAULT,
253 UART_IO_XOFF_VALID,
254 UART_IO_XOFF_DEFAULT,
255 };
256
257 return comPar;
258 }
259 /*
260 +----------------------------------------------------------------------------------+
261 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
262 | STATE : code ROUTINE : cmhUART_AddDeviceToComParameter |
263 +----------------------------------------------------------------------------------+
264
265 PURPOSE: add COM parameter for a new device
266
267 */
268 GLOBAL void cmhUART_AddDeviceToComParameter( UBYTE device )
269 {
270 T_ACI_DEVICE_ENTRY *device_entry;
271
272 TRACE_FUNCTION("cmhUART_AddDeviceToComParameter");
273
274 /*
275 * try to find the device
276 */
277 device_entry = find_element(uart_com_par, device, cmhUART_comParFindDevice);
278
279 /*
280 * if the device is new add it to the list
281 */
282 if ( device_entry EQ NULL )
283 {
284 ACI_MALLOC (device_entry, sizeof (T_ACI_DEVICE_ENTRY));
285
286 device_entry->device = device;
287 /*
288 * Default values by adding a new device
289 */
290 device_entry->comPar = cmhUART_getDefaultUARTParameter();
291
292 insert_list (uart_com_par, device_entry);
293 }
294 }
295
296 /*
297 +---------------------------------------------------------------------------------------+
298 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
299 | STATE : code ROUTINE : cmhUART_RemoveDeviceFromComParameter |
300 +---------------------------------------------------------------------------------------+
301
302 PURPOSE: remove COM parameter for a device from 'uart_com_par' table
303
304 */
305 GLOBAL void cmhUART_RemoveDeviceFromComParameter( UBYTE device )
306 {
307 T_ACI_DEVICE_ENTRY *device_entry;
308
309 TRACE_FUNCTION("cmhUART_RemoveDeviceFromComParameter");
310
311 /*
312 * Find the device and remove it.
313 */
314 device_entry = remove_element(uart_com_par, device, cmhUART_comParFindDevice);
315
316 if ( device_entry NEQ NULL )
317 {
318 ACI_MFREE ( device_entry );
319 }
320 }
321
322 /*
323 +---------------------------------------------------------------------------------------+
324 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
325 | STATE : code ROUTINE : cmhUART_RemoveDeviceFromComParameter |
326 +---------------------------------------------------------------------------------------+
327
328 PURPOSE: clean the 'uart_com_par' table
329
330 */
331 GLOBAL void cmhUART_CleanComParameterList( void )
332 {
333 T_ACI_DEVICE_ENTRY *device_entry;
334
335 TRACE_FUNCTION("cmhUART_CleanComParameterList");
336
337 /*
338 * Find the device and remove it.
339 */
340 while ( NULL NEQ (device_entry = remove_element(uart_com_par, 0, cmhUART_FindAll)) )
341 {
342 ACI_MFREE ( device_entry );
343 }
344 }
345
346 /*
347 +---------------------------------------------------------------------------------+
348 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
349 | STATE : code ROUTINE : cmhUART_GetDeviceParOverDevice |
350 +---------------------------------------------------------------------------------+
351
352 PURPOSE: returns the COM parameter for this device
353
354 */
355 GLOBAL T_ACI_DEVICE_ENTRY* cmhUART_GetDeviceParOverDevice( UBYTE device )
356 {
357 T_ACI_DEVICE_ENTRY *device_entry;
358
359 TRACE_FUNCTION("cmhUART_GetDeviceParOverDevice");
360
361 /*
362 * return COM parameter for device
363 */
364 device_entry = find_element(uart_com_par, device, cmhUART_comParFindDevice);
365
366 if ( device_entry EQ NULL )
367 {
368 TRACE_EVENT_P1("[ERR] cmhUART_GetDeviceParOverDevice: device=%d not found", device) ;
369 return NULL;
370 }
371
372 return device_entry;
373 }
374
375 /*
376 +---------------------------------------------------------------------------------+
377 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
378 | STATE : code ROUTINE : cmhUART_GetDeviceParOverDevice |
379 +---------------------------------------------------------------------------------+
380
381 PURPOSE:
382
383 */
384 GLOBAL T_ACI_DEVICE_TYPE cmhUART_GetDeviceType( UBYTE srcId )
385 {
386 T_ACI_DTI_PRC *src_infos;
387
388 TRACE_FUNCTION("cmhUART_GetDeviceType");
389
390 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId);
391
392 if (src_infos NEQ NULL)
393 {
394 return src_infos->device_type;
395 }
396 else
397 {
398 return DEVICE_TYPE_UNKNOWN;
399 }
400 }
401
402 /*
403 +---------------------------------------------------------------------------------+
404 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
405 | STATE : code ROUTINE : cmhUART_ChangeDeviceParOverDevice |
406 +---------------------------------------------------------------------------------+
407
408 PURPOSE:
409
410 */
411 GLOBAL BOOL cmhUART_ChangeDeviceType( UBYTE srcId,
412 T_ACI_DEVICE_TYPE device_type )
413 {
414 T_ACI_DTI_PRC *src_infos;
415
416 TRACE_FUNCTION("cmhUART_ChangeDeviceType");
417
418 src_infos = find_element (uart_src_params, (UBYTE)srcId, cmhUARTtest_srcId);
419
420 if (src_infos NEQ NULL)
421 {
422 src_infos->device_type = device_type;
423
424 switch (device_type)
425 {
426 case DEVICE_TYPE_UNKNOWN:
427 TRACE_EVENT_P1("Device type of src %u is DEVICE_TYPE_UNKNOWN", srcId);
428 break;
429 case DEVICE_TYPE_URT:
430 TRACE_EVENT_P1("Device type of src %u is DEVICE_TYPE_URT", srcId);
431 break;
432 case DEVICE_TYPE_MUX:
433 TRACE_EVENT_P1("Device type of src %u is DEVICE_TYPE_MUX", srcId);
434 break;
435 default:
436 TRACE_EVENT_P1("Device type of src %u has invalid value", srcId);
437 break;
438 }
439
440 return TRUE;
441 }
442 else
443 {
444 return FALSE;
445 }
446 }
447
448 /*
449 +---------------------------------------------------------------------------------+
450 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
451 | STATE : code ROUTINE : cmhUART_GetDeviceParOverSrcID |
452 +---------------------------------------------------------------------------------+
453
454 PURPOSE: returns the COM parameter for this source ID
455
456 */
457 GLOBAL T_ACI_DEVICE_ENTRY* cmhUART_GetDeviceParOverSrcID( UBYTE srcId )
458 {
459 T_ACI_DEVICE_ENTRY *device_entry;
460 T_ACI_DTI_PRC *cmd_struct;
461
462 TRACE_FUNCTION("cmhUART_GetDeviceParOverSrcID()");
463
464 if( !ati_is_src_type(srcId, ATI_SRC_TYPE_UART) )
465 {
466 /* not a UART source */
467 return(NULL);
468 }
469
470 /*
471 * find the device connected to this source ID
472 */
473 cmd_struct = find_element (uart_src_params, srcId, cmhUARTtest_srcId);
474
475 if (cmd_struct EQ NULL)
476 {
477 TRACE_EVENT_P1("[ERR] cmhUART_GetDeviceParOverSrcID: srcId=%d not found", srcId) ;
478 return NULL;
479 }
480
481 /*
482 * return COM parameter for device
483 */
484 device_entry = find_element(uart_com_par, cmd_struct->device, cmhUART_comParFindDevice);
485
486 if ( device_entry EQ NULL )
487 {
488 TRACE_EVENT_P1("[ERR] cmhUART_GetDeviceParOverSrcID: device=%d not found", cmd_struct->device) ;
489 return NULL;
490 }
491
492 return device_entry;
493 }
494
495 GLOBAL UBYTE cmhUART_GetParityOverSrcID( UBYTE srcId )
496 {
497 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( (UBYTE) srcId );
498
499 if ( device_entry EQ NULL )
500 {
501 return cmhUART_getDefaultUARTParameter().parity;
502 }
503
504 return device_entry->comPar.parity;
505 }
506
507 GLOBAL UBYTE cmhUART_GetDataBitOverSrcID( UBYTE srcId )
508 {
509 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( (UBYTE) srcId );
510
511 if ( device_entry EQ NULL )
512 {
513 return cmhUART_getDefaultUARTParameter().bpc;
514 }
515
516 return device_entry->comPar.bpc;
517 }
518
519 GLOBAL UBYTE cmhUART_GetStopBitOverSrcID( UBYTE srcId )
520 {
521 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( (UBYTE) srcId );
522
523 if ( device_entry EQ NULL )
524 {
525 return cmhUART_getDefaultUARTParameter().nsb;
526 }
527
528 return device_entry->comPar.nsb;
529 }
530
531 /*
532 +------------------------------------------------------------------------------+
533 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
534 | STATE : code ROUTINE : cmhUART_SetComParToUnchanged |
535 +------------------------------------------------------------------------------+
536
537 PURPOSE: set the UART COM parameter to unchanged
538
539 */
540 GLOBAL void cmhUART_SetComParToUnchanged( T_comPar *comPar )
541 {
542 comPar->speed = UART_IO_SPEED_UNDEF; /* baud rate */
543 comPar->bpc = UART_IO_BPC_UNDEF; /* bits per character */
544 comPar->nsb = UART_IO_SB_UNDEF; /* stop bits */
545 comPar->parity = UART_IO_PA_UNDEF; /* parity of serial link */
546 comPar->flow_rx = UART_IO_FC_RX_UNDEF; /* flow control mode RX */
547 comPar->flow_tx = UART_IO_FC_TX_UNDEF; /* flow control mode TX */
548 comPar->xon_valid = UART_IO_XON_UNDEF; /* indicator whether xon is valid */
549 comPar->xoff_valid = UART_IO_XOFF_UNDEF; /* indicator whether xoff is valid */
550
551 comPar->xon = UART_IO_XON_DEFAULT;
552 comPar->xoff = UART_IO_XOFF_DEFAULT;
553
554 /*
555 * Set escape parameters
556 */
557 comPar->esc_valid = UART_IO_ESC_VALID;
558 comPar->esc_char = UART_IO_ESC_CHAR_DEFAULT;
559 comPar->esc_gp = UART_IO_ESC_GP_DEFAULT;
560 }
561
562 /*
563 +------------------------------------------------------------------------------+
564 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
565 | STATE : code ROUTINE : cmhUART_SetDataRate |
566 +------------------------------------------------------------------------------+
567
568 PURPOSE: set the UART data rate
569
570 */
571 GLOBAL T_ACI_RETURN cmhUART_SetDataRate ( UBYTE srcId, T_ACI_BD_RATE rate)
572 {
573 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( srcId );
574 T_comPar newComPar;
575
576 if ( device_entry EQ NULL )
577 {
578 TRACE_EVENT_P1("[ERR] cmhUART_SetDataRate: device for source ID = %d not found", srcId);
579 return AT_FAIL;
580 }
581
582 cmhUART_SetComParToUnchanged( &newComPar );
583
584 device_entry->comPar.speed = newComPar.speed = cmhUART_translateBD_RATE_to_UART_IO_SPEED( rate );
585
586 psaUART_SetParameters(device_entry->device, &newComPar);
587
588 return AT_EXCT;
589 }
590
591 /*
592 +------------------------------------------------------------------------------+
593 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
594 | STATE : code ROUTINE : cmhUART_SetCharacterFraming |
595 +------------------------------------------------------------------------------+
596
597 PURPOSE: set the UART character framing
598
599 */
600 GLOBAL T_ACI_RETURN cmhUART_SetCharacterFraming ( UBYTE srcId,
601 T_ACI_BS_FRM format,
602 T_ACI_BS_PAR parity )
603 {
604 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( srcId );
605 T_comPar comPar;
606
607 if ( device_entry EQ NULL )
608 {
609 TRACE_EVENT_P1("[ERR] cmhUART_SetCharacterFraming: device for source ID = %d not found", srcId);
610 return AT_FAIL;
611 }
612
613 cmhUART_SetComParToUnchanged( &comPar );
614
615 /*
616 * translate AT command parameter to UART parameter
617 */
618 if ( format NEQ BS_FRM_NotPresent )
619 {
620 if ( format & 4 )
621 {
622 device_entry->comPar.bpc = comPar.bpc = UART_IO_BPC_7;
623 format++;
624 }
625 else
626 {
627 device_entry->comPar.bpc = comPar.bpc = UART_IO_BPC_8;
628 }
629
630 device_entry->comPar.nsb = comPar.nsb = format & 2 ? UART_IO_SB_1 : UART_IO_SB_2;
631
632 if ( format & 1 )
633 {
634 device_entry->comPar.parity = comPar.parity = UART_IO_PA_NONE;
635 parity = BS_PAR_NotPresent;
636 }
637 else
638 {
639 if ( parity EQ BS_PAR_NotPresent )
640 {
641 if ( device_entry->comPar.parity NEQ UART_IO_PA_NONE )
642 {
643 if ( device_entry->comPar.parity EQ NOT_SUPPORTED_UART_IO_PA_MARK )
644 {
645 comPar.parity = UART_IO_PA_NONE;
646 comPar.nsb = UART_IO_SB_2;
647 }
648 else
649 {
650 comPar.parity = device_entry->comPar.parity;
651 }
652 }
653 else
654 {
655 /* the type of parity is not defined */
656 return AT_FAIL;
657 }
658 }
659 }
660 }
661
662 switch (parity)
663 {
664 case BS_PAR_NotPresent:
665 /* this case is handled by format translation */
666 break;
667 case BS_PAR_Odd:
668 device_entry->comPar.parity = comPar.parity = UART_IO_PA_ODD;
669 break;
670 case BS_PAR_Even:
671 device_entry->comPar.parity = comPar.parity = UART_IO_PA_EVEN;
672 break;
673 case BS_PAR_Mark:
674 /*
675 * parity mark is not supported by the UART SAP,
676 * but it is the same as no parity and 2 stop bit
677 */
678 device_entry->comPar.parity = NOT_SUPPORTED_UART_IO_PA_MARK;
679 comPar.parity = UART_IO_PA_NONE;
680 comPar.nsb = UART_IO_SB_2;
681 break;
682 case BS_PAR_Space:
683 device_entry->comPar.parity = comPar.parity = UART_IO_PA_SPACE;
684 break;
685 }
686
687 psaUART_SetParameters(device_entry->device, &comPar);
688
689 return AT_EXCT;
690 }
691
692 /*
693 +------------------------------------------------------------------------------+
694 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
695 | STATE : code ROUTINE : cmhUART_SetFlowControl |
696 +------------------------------------------------------------------------------+
697
698 PURPOSE: set the UART flow control
699
700 */
701 GLOBAL T_ACI_RETURN cmhUART_SetFlowControl(UBYTE srcId, T_ACI_RX_FLOW_CTRL DCE_by_DTE)
702 {
703 T_ACI_DEVICE_ENTRY *device_entry = cmhUART_GetDeviceParOverSrcID( srcId );
704 T_comPar comPar;
705
706 if ( device_entry EQ NULL )
707 {
708 TRACE_EVENT_P1("[ERR] cmhUART_SetFlowControl: device for source ID = %d not found", srcId);
709 return AT_FAIL;
710 }
711
712 cmhUART_SetComParToUnchanged( &comPar );
713
714 /*
715 * translate AT command parameter to UART parameter
716 */
717 switch ( DCE_by_DTE )
718 {
719 case RX_FLOW_NONE:
720 comPar.flow_rx = UART_IO_FC_RX_NONE;
721 comPar.flow_tx = UART_IO_FC_TX_NONE;
722 break;
723 case RX_FLOW_SOFTWARE:
724 comPar.flow_rx = UART_IO_FC_RX_XOFF;
725 comPar.flow_tx = UART_IO_FC_TX_XOFF;
726 break;
727 case RX_FLOW_HARDWARE:
728 comPar.flow_rx = UART_IO_FC_RX_RTS;
729 comPar.flow_tx = UART_IO_FC_TX_RTS;
730 break;
731 case RX_FLOW_NotPresent:
732 return AT_CMPL;
733 }
734
735 device_entry->comPar.flow_rx = comPar.flow_rx;
736 device_entry->comPar.flow_tx = comPar.flow_tx;
737
738 psaUART_SetParameters(device_entry->device, &comPar);
739
740 return AT_EXCT;
741 }
742
743 /*
744 +--------------------------------------------------------------------------------+
745 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
746 | STATE : code ROUTINE : cmhUART_GetFktInterfaceFormat |
747 +--------------------------------------------------------------------------------+
748
749 PURPOSE: translate the UART COM parameter to the AT command format parameter
750
751 ATTENTION: internal function, COM paramter is is not checking of validity
752
753 */
754 GLOBAL T_ACI_BS_FRM cmhUART_GetFktInterfaceFormat( T_ACI_UART_COM_PAR *comPar )
755 {
756 UBYTE format = 1; /* 8 Data 2 Stop */
757
758 if ( comPar->bpc EQ UART_IO_BPC_7 )
759 format += 3;
760
761 if ( comPar->nsb NEQ UART_IO_SB_2 )
762 format += 2;
763
764 if ( comPar->parity NEQ UART_IO_PA_NONE )
765 format -= 1;
766
767 return (T_ACI_BS_FRM) format;
768 }
769
770 /*
771 +--------------------------------------------------------------------------------+
772 | PROJECT : GSM-PS (6147) MODULE : CMH_UART |
773 | STATE : code ROUTINE : cmhUART_GetFktInterfaceParity |
774 +--------------------------------------------------------------------------------+
775
776 PURPOSE: translate the UART COM parameter to the AT command parity parameter
777
778 ATTENTION: internal function, COM paramter is is not checking of validity
779
780 */
781 GLOBAL T_ACI_BS_PAR cmhUART_GetFktInterfaceParity( T_ACI_UART_COM_PAR *comPar )
782 {
783 switch ( comPar->parity )
784 {
785 case UART_IO_PA_ODD:
786 return (T_ACI_BS_PAR) BS_PAR_Odd;
787 case UART_IO_PA_EVEN:
788 return (T_ACI_BS_PAR) BS_PAR_Even;
789 case NOT_SUPPORTED_UART_IO_PA_MARK:
790 return (T_ACI_BS_PAR) BS_PAR_Mark;
791 case UART_IO_PA_SPACE:
792 return (T_ACI_BS_PAR) BS_PAR_Space;
793 }
794 return BS_PAR_NotPresent;
795 }
796 #endif /* UART */