comparison g23m/condat/ms/src/ati_ext/ati_ext_mech.c @ 0:509db1a7b7b8

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul : J:\g23m-aci\aci_ext\ati_ext_mech.c
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 is the implementation of the AT command extension mechanism. Customers
18 | can implement their own handling of extension AT comannds here.
19 +-----------------------------------------------------------------------------
20 */
21 #ifndef ATI_EXT_MECH_C
22 #define ATI_EXT_MECH_C
23
24 #include "aci_all.h"
25 #include "aci_cmh.h"
26 #include "ati_cmd.h"
27 #include "aci_cmd.h"
28 #include "aci_lst.h"
29 #include "ati_int.h"
30 #include "ati_ext_mech.h"
31
32 #ifdef FF_BAT
33 #include "aci_bat_ext.h"
34 #endif
35
36
37
38 /*==== CONSTANTS ==================================================*/
39
40 #define EXT_ATD "EXT: D, I"
41 #define EXT_ATCFUN "EXT: +CFUN, I"
42 #define EXT_ATCOPS_START "EXT: +COPS, I"
43 #define EXT_ATCOPS_STOP "EXT: +COPS, O"
44 #define EXT_ENTER "EXT: I"
45 #define EXT_LEAVE "EXT: O"
46 #define EXT_UNEXPCTD "EXT: E"
47
48 #define EXT_DIAL_VOICE_PASS "DVCP"
49
50 #define EXT_MAX_BUF_LEN 41
51
52 #define EXT_VOICE_DELIMITER ';'
53
54
55 /*==== EXTERNALS ======================================================*/
56
57 /*==== LOCALS =========================================================*/
58
59 /*==== EXPORT ======================================================*/
60 EXTERN UBYTE src_id_ext; /* this source runs currently an extension command */
61
62 /*==== TYPES ======================================================*/
63 /*
64 #ifndef WIN32
65 extern USHORT IQ_GetBuild(void);
66 #ifndef ALR
67 extern USHORT IQ_GetPoleStarVersion(void);
68 #endif
69 extern USHORT IQ_GetJtagId(void);
70 extern USHORT IQ_GetRevision(void);
71
72 #endif*/
73 /*==== VARIABLES ==================================================*/
74 LOCAL CHAR extDialNum[MAX_CC_ORIG_NUM_LEN];
75 /* number to be dialled during testing */
76 LOCAL T_ACI_AT_CMD currAbrtCmd = AT_CMD_NONE;
77 /* used for indicating abort of */
78 /* asynchronous command handling */
79 LOCAL T_ACI_AT_CMD currExtCmd_v2 = AT_CMD_NONE;
80 /* used for indicating asynchronous */
81 /* command handling */
82 LOCAL SHORT extCallId_v2 = ACI_NumParmNotPresent;
83 /* identifier of the call which was */
84
85 /*
86 +--------------------------------------------------------------------+
87 | PROJECT : GSM-PS (8403) MODULE : TIL_CSF |
88 | STATE : code ROUTINE : cmh_show_version |
89 +--------------------------------------------------------------------+
90
91 PURPOSE : Trace Layer 1 DSP version numbers
92
93 */
94 /*
95 #ifndef WIN32
96
97
98 static void jtagid_to_chipset (USHORT jtagid, CHAR *chipset)
99 {
100
101 switch (jtagid) {
102
103 case 0xB268:
104
105 strcpy (chipset, "Hercules");
106 break;
107
108 case 0xB2B5:
109
110 strcpy (chipset, "Ulysse 1Mbits rev. B");
111 break;
112
113 case 0xB335:
114
115 strcpy (chipset, "Ulysse 1Mbits rev. A");
116 break;
117
118 case 0xB334:
119
120 strcpy (chipset, "Ulysse 2Mbits");
121 break;
122
123 case 0xB393:
124
125 strcpy (chipset, "Ulysse G1");
126 break;
127
128
129 case 0xB396:
130
131 strcpy (chipset, "Calypso rev. B");
132 break;
133
134 case 0xB2AC:
135
136 // Samson and Calypso rev. A share the same JTAG ID.
137 #if (CHIPSET != 7)
138 strcpy (chipset, "Samson");
139 #else
140 strcpy (chipset, "Calypso rev. A");
141 #endif
142 break;
143
144 default:
145
146 strcpy (chipset, "Unknown");
147 break;
148 }
149 }
150
151 */
152
153 /*
154 GLOBAL void cmh_show_version (UBYTE src_id )
155 {
156 #ifndef ALR
157 CHAR buf[80];
158 USHORT build, hw, rev;
159 #else
160 CHAR buf[160];
161 CHAR chipset[25];
162 #endif
163 USHORT jtag;
164 UCHAR size;
165 CHAR *output;*/
166 /*
167 * Retrieve hardware JTAG ID info
168 */
169 /* jtag = IQ_GetJtagId();
170
171 #ifndef ALR
172
173 build = IQ_GetBuild();
174 hw = IQ_GetPoleStarVersion();
175 rev = IQ_GetRevision();
176
177 sprintf (buf, "Build %d, Silicon Revision %04X/%04X/%04X",
178 build, hw, jtag, rev);
179 #else
180
181
182 jtagid_to_chipset (jtag, chipset);
183
184 sprintf (buf,
185 "Chipset Version:\n\r\t%s\n\rS/W Versions:\n\n\r\tTI Layer1\t\t%4X\n\r\tCondat G.2-3\t\t %3X\n\r\tTI Ref. Design Release\t %3X",
186 chipset,
187 SOFTWAREVERSION,
188 G23VERSION,
189 SYSTEMVERSION);
190 #endif
191
192 // Format output as a list of Pascal-like strings
193 size = strlen(buf);
194 output[0] = size;
195 strcpy(&(output[1]), buf);
196 output[size+1] = (CHAR) 0xFF;
197 sEXT_Output (src_id, ATI_EXT_CMPL_LINE, output);
198 }
199
200 #endif
201 */
202
203
204
205 /*
206 +--------------------------------------------------------------------+
207 | PROJECT : GSM-PS (6147) MODULE : ATI_EXT_MECH |
208 | STATE : code ROUTINE : aci_to_ext_return_map |
209 +--------------------------------------------------------------------+
210
211 PURPOSE : This function is used to map the ACI return values to the EXT return values
212 */
213 LOCAL T_ATI_EXT_RETURN aci_to_ext_return_map (T_ACI_RETURN aci_return)
214 {
215 TRACE_FUNCTION ("aci_to_ext_return_map ()");
216 switch (aci_return)
217 {
218 case AT_FAIL: return ATI_EXT_FAIL;
219 case AT_CMPL: return ATI_EXT_CMPL;
220 case AT_EXCT: return ATI_EXT_EXCT;
221 case AT_BUSY: return ATI_EXT_BUSY;
222 default: return ATI_EXT_FAIL;
223 }
224 }
225
226 /*
227 +--------------------------------------------------------------------+
228 | PROJECT : GSM-PS (6147) MODULE : ATI_EXT_MECH |
229 | STATE : code ROUTINE : aci_to_ext_return_map |
230 +--------------------------------------------------------------------+
231
232 PURPOSE : This function is used to map the ATI return values to the EXT return values
233 */
234 LOCAL T_ATI_EXT_RETURN ati_to_ext_return_map (T_ATI_RSLT ati_return)
235 {
236 TRACE_FUNCTION ("ati_to_ext_return_map ()");
237 switch (ati_return)
238 {
239 case ATI_FAIL: return ATI_EXT_FAIL;
240 case ATI_CMPL: return ATI_EXT_CMPL;
241 case ATI_EXCT: return ATI_EXT_EXCT;
242 case ATI_BUSY: return ATI_EXT_BUSY;
243 default: return ATI_EXT_FAIL;
244 }
245 }
246
247 /*
248 +--------------------------------------------------------------------+
249 | PROJECT : GSM-PS (6147) MODULE : ATI_EXT_MECH |
250 | STATE : code ROUTINE : ext_LeaveEXT_v2 |
251 +--------------------------------------------------------------------+
252
253 PURPOSE : This function is called in case the extensin mechansim
254 should be left finally.
255 */
256 LOCAL void ext_LeaveEXT_v2 ( )
257 {
258 /*indicating that no extended AT command is still in progress*/
259 currExtCmd_v2 = AT_CMD_NONE;
260 /*indicate end of extended command handling to the AT interpreter*/
261 /* sEXT_Finit();*/
262 sEXT_Indication (src_id_ext, EXT_LEAVE );
263 }
264
265 /*
266 +--------------------------------------------------------------------+
267 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
268 | STATE : code ROUTINE : ext_ContinueTest_v2 |
269 +--------------------------------------------------------------------+
270
271 PURPOSE : This function is called in case the AT extension
272 procedure should be continued.
273
274 <id>: identifies the specific procedure to be continued
275
276 */
277 LOCAL void ext_ContinueTest_v2 ( CHAR* id )
278 {
279 T_ACI_RETURN rslt;
280
281 if ( strcmp ( id, EXT_DIAL_VOICE_PASS ) EQ 0 )
282 {
283 T_ACI_D_TOC callType = D_TOC_Data;
284
285 if ( extDialNum [strlen ( extDialNum ) - 1] EQ EXT_VOICE_DELIMITER )
286 callType = D_TOC_Voice;
287
288 extDialNum[strlen ( extDialNum ) - 1] = '\0';
289
290 rslt = sAT_Dn ( CMD_SRC_LCL,
291 extDialNum,
292 D_CLIR_OVRD_Default,
293 D_CUG_CTRL_NotPresent,
294 callType );
295
296 if ( rslt EQ AT_EXCT )
297 {
298 /*
299 * generate some output at the AT interface
300 */
301 sEXT_Indication (src_id_ext, EXT_ATD);
302
303 /*
304 * indicating that an extended AT command is still in progress
305 */
306 currExtCmd_v2 = AT_CMD_D;
307 }
308 else if (rslt EQ AT_CMPL)
309 {
310 sEXT_Confirm (src_id_ext);
311 ext_LeaveEXT_v2 ();
312 }
313 else
314 {
315 rCI_PlusCME ( AT_CMD_EXT, CME_ERR_Unknown );
316 ext_LeaveEXT_v2 ();
317 }
318 }
319 }
320
321
322 /*
323 +--------------------------------------------------------------------+
324 | PROJECT : GSM-PS (6147) MODULE : CMH_EXTS |
325 | STATE : code ROUTINE : ext_OK_v2 |
326 +--------------------------------------------------------------------+
327
328 PURPOSE : This function is called in case the positive
329 result of the asynchronous command handling is available.
330
331 <cmdId>: command identity
332
333 */
334 GLOBAL void ext_OK_v2 ( T_ACI_AT_CMD cmdId )
335 {
336 T_ACI_RETURN rslt;
337
338 if ( cmdId EQ AT_CMD_CFUN AND currAbrtCmd EQ AT_CMD_NONE )
339 {
340 rslt = sAT_PlusCOPS ( CMD_SRC_LCL,
341 COPS_MOD_Auto,
342 COPS_FRMT_NotPresent,
343 NULL );
344
345 if ( rslt EQ AT_EXCT )
346 {
347 /*
348 * generate some output at the AT interface
349 */
350 sEXT_Output (src_id_ext, ATI_EXT_CMPL_LINE, EXT_ATCOPS_START);
351
352 /*
353 * indicating that an extended AT command is still in progress
354 */
355 currExtCmd_v2 = AT_CMD_COPS;
356 }
357 else
358 {
359 ext_LeaveEXT_v2 ();
360 sEXT_Error ( AT_CMD_EXT, CME_ERR_Unknown);
361 }
362 }
363 else if ( cmdId EQ AT_CMD_COPS AND currAbrtCmd EQ AT_CMD_NONE )
364 {
365 currExtCmd_v2 = AT_CMD_NONE;
366
367 /*
368 * generate some output at the AT interface
369 */
370
371 sEXT_Indication (AT_CMD_EXT, EXT_ATCOPS_STOP );
372
373 #ifndef WIN32
374 ext_ContinueTest_v2 ( EXT_DIAL_VOICE_PASS );
375 #endif
376 }
377 else if ( cmdId EQ AT_CMD_D AND currAbrtCmd EQ AT_CMD_NONE )
378 {
379 extCallId_v2 = 1;
380
381 ext_LeaveEXT_v2 ();
382 sEXT_Confirm( AT_CMD_EXT );
383 }
384 else if ( currAbrtCmd NEQ AT_CMD_NONE )
385 {
386 currAbrtCmd = AT_CMD_NONE;
387
388 ext_LeaveEXT_v2 ();
389 sEXT_Confirm( AT_CMD_EXT );
390 }
391 else
392 {
393 /*generate some output at the AT interface*/
394 sEXT_Output(src_id_ext, ATI_EXT_CMPL_LINE, EXT_UNEXPCTD);
395 }
396 }
397
398
399 /*
400 +--------------------------------------------------------------------+
401 | PROJECT : GSM-PS (6147) MODULE : ATI_EXT_MECH |
402 | STATE : code ROUTINE : rEXT_Init |
403 +--------------------------------------------------------------------+
404
405 PURPOSE : This function is called in the ATI initialization process.
406 */
407 GLOBAL T_ATI_EXT_RETURN rEXT_Init ()
408 {
409 #ifdef _SIMULATION_
410 static CHAR *cmd_list[] = {"$A", "$B", "%TA", NULL};
411 #else /*_SIMULATION_*/
412 static CHAR *cmd_list[] = {NULL};
413 //static CHAR *cmd_list[] = {"$A", "$B", "%TA", NULL};
414 #endif /*_SIMULATION_*/
415 TRACE_FUNCTION ("rEXT_Init ()");
416 if (sEXT_Init (cmd_list) EQ ATI_CMPL)
417 return ATI_EXT_CMPL;
418 else
419 return ATI_EXT_FAIL;
420 }
421
422
423 /*
424 +--------------------------------------------------------------------+
425 | PROJECT : GSM-PS (6147) MODULE : ATI_EXT_MECH |
426 | STATE : code ROUTINE : rAT_EXT |
427 +--------------------------------------------------------------------+
428
429 PURPOSE : This function is called by ATI in case of the detection of an
430 unknown command.
431 <src_id> : source Id
432 <cmd> : remaining unparsed command string.
433 */
434
435 GLOBAL T_ATI_EXT_RETURN rEXT_Execute (UBYTE src_id, CHAR *cmd)
436 {
437
438 TRACE_FUNCTION ("rEXT_Execute ()");
439
440 /*example how to process the command AT$A*/
441 if (*cmd EQ '$')
442 {
443 cmd++;
444
445 switch (*cmd++)
446 {
447 T_ATI_RSLT output_rslt;
448 case 'A': /*print out string "Hello World"*/
449 output_rslt = ATI_FAIL;
450 if (*cmd EQ '\0')
451 output_rslt = sEXT_Output (src_id, ATI_EXT_CMPL_LINE, "Hello World!");
452
453 if (*cmd EQ '=' AND *(cmd+1) EQ '0')
454 output_rslt = sEXT_Output (src_id, ATI_EXT_CMPL_LINE, "AT$A is set to off.");
455
456 if (*cmd EQ '=' AND *(cmd+1) EQ '1')
457 output_rslt = sEXT_Output (src_id, ATI_EXT_CMPL_LINE, "AT$A is set to on.");
458
459 if (*cmd EQ '=' AND *(cmd+1) EQ '?')
460 output_rslt = sEXT_Output (src_id, ATI_EXT_CMPL_LINE, "$A: 0, 1");
461
462 return (ati_to_ext_return_map (output_rslt));
463
464 case 'B': /*print out a complete string part by part*/
465 sEXT_Output(src_id, ATI_EXT_PART_BEGIN, "This is ");
466 sEXT_Output(src_id, ATI_EXT_PART_LINE, "a complete ");
467 sEXT_Output(src_id, ATI_EXT_PART_LAST, "line. ");
468 return (ATI_EXT_CMPL);
469 }
470 }
471
472 /*
473 * example how to process the command AT% commands
474 */
475 if (*cmd EQ '%')
476 {
477 sEXT_Output (src_id, ATI_EXT_CMPL_LINE, EXT_ENTER);
478
479 cmd++;
480
481 switch (*cmd)
482 {
483 case 'T':
484 case 't':
485 /*Enables RTC or AUDIO tests */
486 cmd++;
487 if (!strncmp(cmd, "A", 1) || !strncmp(cmd, "a", 1))
488 {
489 sEXT_Output (src_id, ATI_EXT_CMPL_LINE, "Performing Audio Tests");
490 }
491 else
492 {
493 if (!strncmp(cmd, "R", 1) || !strncmp(cmd, "r", 1))
494 {
495 sEXT_Output (src_id, ATI_EXT_CMPL_LINE, "Performing RTC Tests");
496 }
497 else
498 return( AT_FAIL );
499 }
500 return( AT_CMPL );
501 default:
502 return ( AT_FAIL );
503 }
504 }
505
506 else if ( *cmd EQ 'D' )
507 {
508 T_ACI_RETURN rslt;
509 TRACE_EVENT ("ATD in extension mechanism.");
510 strncpy ( extDialNum, cmd + 1, MINIMUM ( MAX_CC_ORIG_NUM_LEN - 1, strlen (cmd) - 1 ) );
511 extDialNum[MINIMUM ( MAX_CC_ORIG_NUM_LEN - 1, strlen (cmd) - 1 )] = '\0';
512
513 rslt = sAT_PlusCFUN ( CMD_SRC_LCL, CFUN_FUN_Full, CFUN_RST_NotPresent );
514
515 if ( rslt EQ AT_EXCT )
516 {
517 /*generate some output at the AT interface*/
518 sEXT_Output (src_id, ATI_EXT_CMPL_LINE, EXT_ATCFUN);
519 /*indicating that an extended AT command is still in progress*/
520 currExtCmd_v2 = AT_CMD_CFUN;
521 }
522 if (rslt EQ AT_FAIL)
523 {
524 sEXT_Indication(src_id, EXT_LEAVE);
525 sEXT_Error (src_id, CME_ERR_Unknown);
526 return ATI_EXT_FAIL;
527 }
528 else if (rslt EQ AT_CMPL)
529 {
530 ext_LeaveEXT_v2 ();
531 return ATI_EXT_CMPL;
532 }
533 return ( aci_to_ext_return_map (rslt));
534 }
535 return ATI_EXT_FAIL;
536 }
537
538 /*
539 +--------------------------------------------------------------------+
540 | PROJECT : GSM-PS (6147) MODULE : ATI_EXT_MECH |
541 | STATE : code ROUTINE : rEXT_Abort |
542 +--------------------------------------------------------------------+
543
544 PURPOSE : This function is called by the ATI in case of aborting a pending
545 extension command.
546 */
547
548 GLOBAL T_ATI_EXT_RETURN rEXT_Abort (UBYTE src_id)
549 {
550 T_ACI_RETURN rslt = AT_CMPL;
551
552 TRACE_FUNCTION ("rEXT_Abort ()");
553 /* call the abort function if necessary */
554 if ( currExtCmd_v2 NEQ AT_CMD_NONE )
555 rslt = sAT_Abort (src_id, currExtCmd_v2 );
556
557 switch ( rslt )
558 {
559 case ( AT_CMPL ):
560 {
561 currExtCmd_v2 = AT_CMD_NONE;
562 sEXT_Indication(src_id, cmdAtError(atOk));
563 ext_LeaveEXT_v2();
564 }
565 break;
566
567 case ( AT_EXCT ):
568 {
569 currExtCmd_v2 = AT_CMD_ABRT;
570 }
571 break;
572
573 default:
574 {
575 /* do nothing */
576 }
577 break;
578 }
579 return aci_to_ext_return_map (rslt);
580 }
581
582
583 /*
584 +--------------------------------------------------------------------+
585 | PROJECT : GSM-PS (6147) MODULE : ATI_EXT_MECH |
586 | STATE : code ROUTINE : rEXT_Signal |
587 +--------------------------------------------------------------------+
588
589 PURPOSE : This function is called by the ATI when an extension signal is received.
590 */
591
592 GLOBAL T_ATI_EXT_RETURN rEXT_Signal (T_ACI_EXT_IND *aci_ext_ind)
593 {
594 TRACE_FUNCTION ("rEXT_Signal ()");
595 /*The handling of the extension signal can be done here.*/
596 sEXT_Output (CMD_SRC_ATI_5, ATI_EXT_CMPL_LINE, "This is an extension signal.");
597 return ATI_EXT_CMPL;
598 }
599
600 #ifdef FF_BAT
601 /*
602 +--------------------------------------------------------------------+
603 | PROJECT : GSM-PS (6147) MODULE : ATI_EXT_MECH |
604 | STATE : code ROUTINE : rEXT_Response_BAT |
605 +--------------------------------------------------------------------+
606
607 PURPOSE : This function is called by BAT Module when customer stuff
608 is asynchronously received.
609 */
610
611 GLOBAL T_ATI_EXT_RETURN rEXT_Response_BAT (UBYTE src_id, T_BAT_cmd_response *resp)
612 {
613 }
614 #endif
615
616
617
618 #endif /* ATI_EXT_MECH_C */
619
620