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