📄 cst_exts.c
字号:
/*
+--------------------------------------------------------------------+
| PROJECT: GSM-F&D (8411) $Workfile:: CST_EXTS.C $|
| $Author: root $ CONDAT GmbH $Revision: 1.1.1.1 $|
| CREATED: 03.08.99 $Modtime:: 14.02.00 16:06 $|
| STATE : code |
+--------------------------------------------------------------------+
MODULE : CST_EXTS
PURPOSE : This Modul defines the custom specific AT commands
*/
#ifndef CST_EXTS_C
#define CST_EXTS_C
#endif
#include "swconfig.cfg"
#include "chipset.cfg"
#define ENTITY_CST
/*==== INCLUDES ===================================================*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "typedefs.h"
#include "m_sms.val"
#include "m_fac.h"
#include "p_mnsms.h"
#include "aci_cmh.h"
#include "vsi.h"
#include "gsm.h"
#include "p_cst.h"
#include "cst.h"
#include "custom.h"
#ifdef ALR
#include "sys_ver.h"
#endif
/* Robert.Chen added for extending AT command */
#include "ati_cmd.h"
#include "spi_drv.h"
#include "abb.h"
#include "general.h"
extern void getVolSetting(UINT8 * amp);
extern void getAudioHrdMode(UINT8 * mode);
typedef T_ACI_RETURN (*EXTF)(CHAR* cmd,
USHORT* cmdLen,
CHAR* out,
USHORT outLen
);
typedef T_ACI_RETURN (*EXTF_T)(CHAR* cmd,
USHORT* cmdLen,
CHAR* out,
USHORT outLen,
USHORT index
);
#define AT_EXT_AT_NAME 8
#define AT_EXT_NUM 5 /* number of MI extended AT commands */
typedef struct AT_EXT_TABLE
{
UBYTE len;
CHAR* name;
EXTF_T handle_t; /* test */
EXTF handle_q; /* query */
EXTF handle_s; /* set */
CHAR* test_out; /* test output */
} T_AT_EXT_TABLE;
#define EXT_AT_TR_EN 1 /* enable extended AT handler trace */
extern void MI_dbgPrintf(const char * const format,...);
#if (EXT_AT_TR_EN == 1)
#define EXT_AT_TRACE(msg) MI_dbgPrintf msg
#else
#define EXT_AT_TRACE(msg)
#endif
/* end add */
/*==== CONSTANTS ==================================================*/
#define EXT_ATD "EXT: D, I"
#define EXT_ATCFUN "EXT: +CFUN, I"
#define EXT_ATCOPS_START "EXT: +COPS, I"
#define EXT_ATCOPS_STOP "EXT: +COPS, O"
#define EXT_ENTER "EXT: I"
#define EXT_LEAVE "EXT: O"
#define EXT_UNEXPCTD "EXT: E"
#define EXT_DIAL_VOICE_PASS "DVCP"
#define EXT_MAX_BUF_LEN 41
#define EXT_VOICE_DELIMITER ';'
/*==== EXPORT =====================================================*/
/*==== TYPES ======================================================*/
#include "rv_general.h"
#include "audio_api.h"
void nothing(void *a)
{
}
#ifndef WIN32
extern USHORT IQ_GetBuild(void);
#ifndef ALR
extern USHORT IQ_GetPoleStarVersion(void);
#endif
extern USHORT IQ_GetJtagId(void);
extern USHORT IQ_GetRevision(void);
extern void l1dmacro_init_hw(void);
extern BOOL SER_WriteConfig (char *new_config,
BOOL write_to_flash);
extern BOOL SER_ImmediateSwitch (void);
#endif
LOCAL CHAR* percentCFG ( CHAR* cmd );
LOCAL CHAR* percentDBG ( CHAR* cmd );
LOCAL void ext_LeaveEXT ( BOOL final );
LOCAL void ext_CreatePString ( CHAR* buffer,
CHAR* text );
GLOBAL void ext_ContinueTest ( CHAR* id );
/* Robert.Chen added, MI's specific AT extension */
LOCAL T_ACI_RETURN rAT_EXT_MI(CHAR* cmd,
USHORT* cmdLen,
CHAR* out,
USHORT outLen
);
/* general extended */
LOCAL T_ACI_RETURN gen_exec_t(CHAR*, USHORT*, CHAR*, USHORT, USHORT);
/* audio interface configuration */
LOCAL T_ACI_RETURN saic_exec_q(CHAR*, USHORT*, CHAR*, USHORT);
LOCAL T_ACI_RETURN saic_exec_s(CHAR*, USHORT*, CHAR*, USHORT);
/* set sperker volume */
LOCAL T_ACI_RETURN snfv_exec_q(CHAR*, USHORT*, CHAR*, USHORT);
LOCAL T_ACI_RETURN snfv_exec_s(CHAR*, USHORT*, CHAR*, USHORT);
/* MUTE microphone functions */
LOCAL T_ACI_RETURN snfm_exec_q(CHAR*, USHORT*, CHAR*, USHORT);
LOCAL T_ACI_RETURN snfm_exec_s(CHAR*, USHORT*, CHAR*, USHORT);
/* audio hardware mode setting */
LOCAL T_ACI_RETURN snfs_exec_s(CHAR*, USHORT*, CHAR*, USHORT);
LOCAL T_ACI_RETURN snfs_exec_q(CHAR*, USHORT*, CHAR*, USHORT);
/*==== VARIABLES ==================================================*/
LOCAL CHAR* extCmd; /* remaining unparsed command string, */
/* will be needed in case of asynchronous */
/* command handling */
LOCAL USHORT extCmdLen; /* length of command string, will be */
/* needed in case of asynchronous */
/* command handling */
LOCAL CHAR extBuffer[EXT_MAX_BUF_LEN]; /* outbut buffer */
LOCAL CHAR extDialNum[MAX_PHB_NUM_LEN];
/* number to be dialled during testing */
GLOBAL SHORT extCallId = ACI_NumParmNotPresent;
/* identifier of the call which was */
/* set-up using AT extension mechansim */
GLOBAL T_ACI_AT_CMD currExtCmd = AT_CMD_NONE;
/* used for indicating asynchronous */
/* command handling */
LOCAL T_ACI_AT_CMD currAbrtCmd = AT_CMD_NONE;
/* used for indicating abort of */
/* Robert.Chen extended AT handler, 2004-06-07 */
LOCAL T_AT_EXT_TABLE at_exec_tb[AT_EXT_NUM] =
{
/* len * *name* *test handler* *query handler* *set handler* *test output */
{5, "^SAIC", gen_exec_t, saic_exec_q, saic_exec_s, "(1-2),(1-2),(1-3)"},
{5, "^SNFV", gen_exec_t, snfv_exec_q, snfv_exec_s, "(0-6)"},
{5, "^SNFM", gen_exec_t, snfm_exec_q, snfm_exec_s, "(0-1)"},
{5, "^SNFS", gen_exec_t, snfs_exec_q, snfs_exec_s, "(0-2)"},
{0, NULL, NULL, NULL, NULL, NULL} /* end of table */
};
/* asynchronous command handling */
/*==== FUNCTIONS ==================================================*/
USHORT * csf_return_adc (void);
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (8403) MODULE : TIL_CSF |
| STATE : code ROUTINE : cmh_show_version |
+--------------------------------------------------------------------+
PURPOSE : Trace Layer 1 DSP version numbers
*/
#ifndef WIN32
static void jtagid_to_chipset (USHORT jtagid, CHAR *chipset)
{
switch (jtagid) {
case 0xB268:
strcpy (chipset, "Hercules");
break;
case 0xB2B5:
strcpy (chipset, "Ulysse 1Mbits rev. B");
break;
case 0xB335:
strcpy (chipset, "Ulysse 1Mbits rev. A");
break;
case 0xB334:
strcpy (chipset, "Ulysse 2Mbits");
break;
case 0xB393:
strcpy (chipset, "Ulysse G1");
break;
case 0xB396:
strcpy (chipset, "Calypso rev. B");
break;
case 0xB2AC:
// Samson and Calypso rev. A share the same JTAG ID.
#if (CHIPSET != 7)
strcpy (chipset, "Samson");
#else
strcpy (chipset, "Calypso rev. A");
#endif
break;
case 0xB217:
strcpy (chipset, "Ulysse C035");
break;
case 0xB496:
strcpy (chipset, "Calypso C035");
break;
case 0xB4FB:
strcpy (chipset, "Calypso Lite C035");
break;
default:
strcpy (chipset, "Unknown");
break;
}
}
GLOBAL void cmh_show_version (
CHAR *command,
USHORT *len,
CHAR *output
)
{
#ifndef ALR
CHAR buf[80];
USHORT build, hw, rev;
#else
CHAR buf[160];
CHAR chipset[25];
#endif
USHORT jtag;
UCHAR size;
/*
* Retrieve hardware JTAG ID info
*/
jtag = IQ_GetJtagId();
#ifndef ALR
/*
* Retrieve others hardware info and build from library
*/
build = IQ_GetBuild();
hw = IQ_GetPoleStarVersion();
rev = IQ_GetRevision();
sprintf (buf, "Build %d, Silicon Revision %04X/%04X/%04X",
build, hw, jtag, rev);
#else
/*
* Retrieve CHIPSET name from JTAG ID
*/
jtagid_to_chipset (jtag, chipset);
sprintf (buf,
"Chipset Version:\n\r\t%s\n\rS/W Versions:\n\n\r\tLayer1\t%4X_%3X_%3X\n\r\tLayer2-3 %3X_s192\n\r\tSSA\t %3X_I24",
chipset,
SOFTWAREVERSION,
GPRSVERSION,
TESTMODEVERSION,
G23VERSION,
SYSTEMVERSION);
#endif
// Format output as a list of Pascal-like strings
size = strlen(buf);
output[0] = size;
strcpy(&(output[1]), buf);
output[size+1] = (CHAR) 0xFF; // terminate list of strings
}
#endif /* #ifndef WIN32 */
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (8403) MODULE : TIL_CSF |
| STATE : code ROUTINE : show_adc_conversion |
+--------------------------------------------------------------------+
PURPOSE : Trace Layer 1 AD conversions results
*/
GLOBAL void show_adc_conversion (CHAR *output)
{
USHORT * adc_conversion;
#ifdef ALR
CHAR buf[160];
#else
CHAR buf[80];
#endif
UCHAR size;
adc_conversion = csf_return_adc ();
#ifdef ALR
sprintf (buf, "ADC 0 = %x, ADC 1 = %x, ADC 2 = %x, ADC 3 = %x, ADC 4 = %x, ADC 5 = %x, ADC 6 = %x, ADC 7 = %x, ADC 8 = %x",
*adc_conversion++, *adc_conversion++, *adc_conversion++,
*adc_conversion++, *adc_conversion++, *adc_conversion++,
*adc_conversion++, *adc_conversion++, *adc_conversion);
#else
sprintf (buf, "ADC 0 = %x, ADC 1 = %x, ADC 2 = %x, ADC 3 = %x, ADC 4 = %x",
*adc_conversion++, *adc_conversion++, *adc_conversion++,
*adc_conversion++, *adc_conversion);
#endif
// Format output as a list of Pascal-like strings
size = strlen(buf);
output[0] = size;
strcpy(&(output[1]), buf);
output[size+1] = (CHAR) 0xFF; // terminate list of strings
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (8403) MODULE : CST_EXTS |
| STATE : code ROUTINE : AEC_Enable |
+--------------------------------------------------------------------+
PURPOSE : activate the Acoustic Echo Cancelation
*/
GLOBAL void AEC_Enable (CHAR *command, CHAR *output)
{
/* -------------------------------------------------------------------------- */
/* MMI_AEC_REQ : 0283 = Long AEC, 105 = SPENH, 187 = AEC+SPENH, 1 = STOP */
/* aec_control register bits | 0 0 Sa t2|t1 g3 g2 g1|g0 e2 e1 ak| */
/* bit 0 : ACK bit : set to 1 in order to warn DSP that a new command */
/* is present. */
/* bit 1 : enable AEC */
/* bit 2 : enable SPENH (= Speech Enhancement = noise reduction) */
/* bit 3 : additionnal AEC gain attenuation (lsb) */
/* bit 4 : additionnal AEC gain attenuation (msb) */
/* bit 5 : additionnal SPENH gain attenuation (lsb) */
/* bit 6 : additionnal SPENH gain attenuation (msb) */
/* bit 7 : reset trigger for AEC */
/* bit 8 : reset trigger for SPENH */
/* bit 9 : AEC selector 0 : short AEC, 1 : long AEC */
/* */
/* for Short AEC 0083 */
/* for long AEC 0283 */
/* for long AEC -6 dB 028B */
/* for long AEC -12 dB 0293 */
/* for long AEC -18 dB 029B */
/* for SPENH 0105 */
/* for SPENH -6 dB 0125 */
/* for SPENH -12 dB 0145 */
/* for SPENH -18 dB 0165 */
/* for BOTH 0187 */
/* for STOP ALL 0001 (all bits reset + ACK to 1 to warn the DSP) */
/* -------------------------------------------------------------------------- */
command++; /* increment command pointer to point on the hexa value of the command */
if (!strncmp(command, "0083", 4))
{
output[0] = strlen ("Short AEC is active");
memcpy (&output[1], "Short AEC is active", 19);
/* end of string list */
output [20] = (CHAR) 0xff;
csf_aec_enable(0x0083);
}
else if (!strncmp(command, "0283", 4))
{
output[0] = strlen ("Long AEC is active");
memcpy (&output[1], "Long AEC is active", 18);
/* end of string list */
output [19] = (CHAR) 0xff;
csf_aec_enable(0x0283);
}
else if (!strncmp(command, "028B", 4))
{
output[0] = strlen ("Long AEC -6 dB is active");
memcpy (&output[1], "Long AEC -6 dB is active", 24);
/* end of string list */
output [25] = (CHAR) 0xff;
csf_aec_enable(0x028B);
}
else if (!strncmp(command, "0293", 4))
{
output[0] = strlen ("Long AEC -12 dB is active");
memcpy (&output[1], "Long AEC -12 dB is active", 25);
/* end of string list */
output [26] = (CHAR) 0xff;
csf_aec_enable(0x0293);
}
else if (!strncmp(command, "029B", 4))
{
output[0] = strlen ("Long AEC -18 dB is active");
memcpy (&output[1], "Long AEC -18 dB is active", 25);
/* end of string list */
output [26] = (CHAR) 0xff;
csf_aec_enable(0x029B);
}
else if (!strncmp(command, "0105", 4))
{
output[0] = strlen ("Noise reduction is active");
memcpy (&output[1], "Noise reduction is active", 25);
/* end of string list */
output [26] = (CHAR) 0xff;
csf_aec_enable(0x0105);
}
else if (!strncmp(command, "0125", 4))
{
output[0] = strlen ("Noise reduction -6 dB is active");
memcpy (&output[1], "Noise reduction -6 dB is active", 31);
/* end of string list */
output [32] = (CHAR) 0xff;
csf_aec_enable(0x0125);
}
else if (!strncmp(command, "0145", 4))
{
output[0] = strlen ("Noise reduction -12 dB is active");
memcpy (&output[1], "Noise reduction -12 dB is active", 32);
/* end of string list */
output [33] = (CHAR) 0xff;
csf_aec_enable(0x0145);
}
else if (!strncmp(command, "0165", 4))
{
output[0] = strlen ("Noise reduction -18 dB is active");
memcpy (&output[1], "Noise reduction -18 dB is active", 32);
/* end of string list */
output [33] = (CHAR) 0xff;
csf_aec_enable(0x0165);
}
else if (!strncmp(command, "0187", 4))
{
output[0] = strlen ("Both AEC and Noise reduction are active");
memcpy (&output[1], "Both AEC and Noise reduction are active", 39);
/* end of string list */
output [40] = (CHAR) 0xff;
csf_aec_enable(0x0187);
}
else if (!strncmp(command, "0001", 4))
{
output[0] = strlen ("AEC and Noise reduction are unactivated");
memcpy (&output[1], "AEC and Noise reduction are unactivated", 39);
/* end of string list */
output [40] = (CHAR) 0xff;
csf_aec_enable(0x0001);
}
else
{
output[0] = strlen ("Bad AT command");
memcpy (&output[1], "Bad AT command", 14);
/* end of string list */
output [15] = (CHAR) 0xff;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : CST_EXTS |
| STATE : code ROUTINE : rAT_EXT |
+--------------------------------------------------------------------+
PURPOSE : This function is called by the interpreter part of the
ACI in case of the detection of an unknown command.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -