comparison src/g23m-aci/ati_ext/ati_ext_mech.c @ 163:2948924c8299

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