⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ac48drhi.c

📁 this for the ac founction in voip.
💻 C
📖 第 1 页 / 共 5 页
字号:
/*                  Address of Pointer to the AC48 'Built In Test'      */
/*                  software to be downloaded.                          */
/*              int Stage:                                              */
/*                  This parameter is relevant only when WaitMode equal */
/*                  to "DONT_WAIT_PACKET_EMPTY". This parameter	helps   */
/*                  the watch-dog mechanism to let the AC48	complete    */
/*                  the Memory Test.                                    */
/*              TWaitMode WaitMode:                                     */
/*                  Wait / don't wait to "packet-empty".                */
/* Output  :    int:                                                    */
/*                  (LAST_STAGE_COMPLETED) - for successful operation   */
/*                  (AC_ERROR) - BITProgram Download failed             */
/*                  (CHECKSUM_ERROR) - Memory Test failed               */
/*                  (-1) -  the 'BIT' Program Download proccess did not */
/*                          complete, yet. In edition, the pointer to   */
/*                          the 'BIT' Program Download Blocks, updated. */
/*                  (>FIRST_STAGE) - Memory Test proccess did not       */
/*                                    complete, yet.                    */
/*======================================================================*/
int Ac48xxBIT(int DeviceIndex, const char *KernelDownload, int KernelSize,
			    const char **BITDownload, int Stage, TWaitMode WaitMode)
{
	int Status;
	switch(Stage)
		{
		case FIRST_STAGE: /* 10 == Stage */
		case (-1):
						/* boot AC4804 and download the Bit program */
			Status = Ac48xxBoot(DeviceIndex, KernelDownload,
								KernelSize, BITDownload, Stage, WaitMode);
			if(Status == (-1))
				return -1;
			if(Status == AC_ERROR)
				return AC_ERROR;
						/* Wait DSP complete Memory Test */
						/* 1) set HPIA <= (AC48_BOOT_STATUS_REGISTER)  */
			Ac48xxHostWrite((char)AC48_HOST_TRANSMIT_STATUS_REGISTER,
											DeviceIndex, HPIA, First);
			Ac48xxHostWrite((char)(AC48_HOST_TRANSMIT_STATUS_REGISTER>>8),
											DeviceIndex, HPIA, Second);
						/* 2) ignore first reading HPID  */
			Ac48xxHostRead(DeviceIndex, HPIDL, First);
			Ac48xxHostRead(DeviceIndex, HPIDL, Second);
		case 11:
			Stage=11;
		do				/* 3) read until DSP complete Memory Test */
			{
			Status = Ac48xxHostRead(DeviceIndex, HPIDL, First); /* LSB */
			Ac48xxHostRead(DeviceIndex, HPIDL, Second);         /* MSB */
			}
		while((WaitMode == WAIT_PACKET_EMPTY) && (Status == PACKET_FULL));
		}
	if(Status == PACKET_FULL)	/* "DONT_WAIT_PACKET_EMPTY" mode */
		return Stage;
	if(Status == PACKET_EMPTY)
		return LAST_STAGE_COMPLETED;
	return CHECKSUM_ERROR;			
}

/*======================================================================*/
int Ac48xxBITForDebugging(int DeviceIndex, const char *KernelDownload, 
                          int KernelSize, const char **BITDownload, 
                          const char *BITDownloadStructure,
                          int Stage, TWaitMode WaitMode, 
                          FILE *BlockStructureFile)
{
	int Status;
	switch(Stage)
		{
		case FIRST_STAGE: /* 10 == Stage */
		case (-1):
						/* boot AC4804 and download the Bit program */
			Status = Ac48xxBootForDebugging(DeviceIndex, KernelDownload,
								KernelSize, BITDownload, BITDownloadStructure, 
                                Stage, WaitMode, BlockStructureFile);
			if(Status == (-1))
				return -1;
			if(Status == AC_ERROR)
				return AC_ERROR;
						/* Wait DSP complete Memory Test */
						/* 1) set HPIA <= (AC48_BOOT_STATUS_REGISTER)  */
			Ac48xxHostWrite((char)AC48_HOST_TRANSMIT_STATUS_REGISTER,
											DeviceIndex, HPIA, First);
			Ac48xxHostWrite((char)(AC48_HOST_TRANSMIT_STATUS_REGISTER>>8),
											DeviceIndex, HPIA, Second);
						/* 2) ignore first reading HPID  */
			Ac48xxHostRead(DeviceIndex, HPIDL, First);
			Ac48xxHostRead(DeviceIndex, HPIDL, Second);
		case 11:
			Stage=11;
		do				/* 3) read until DSP complete Memory Test */
			{
			Status = Ac48xxHostRead(DeviceIndex, HPIDL, First); /* LSB */
			Ac48xxHostRead(DeviceIndex, HPIDL, Second);         /* MSB */
			}
		while((WaitMode == WAIT_PACKET_EMPTY) && (Status == PACKET_FULL));
		}
	if(Status == PACKET_FULL)	/* "DONT_WAIT_PACKET_EMPTY" mode */
		return Stage;
	if(Status == PACKET_EMPTY)
		return LAST_STAGE_COMPLETED;
	return CHECKSUM_ERROR;			
}


/*======================================================================*/
/* Name    :        Ac48xxSetupDevice                                   */
/*======================================================================*/
/* Purpose :    Place Device from init to run mode idle state, by       */
/*              sending PCM, DEBUG, MSIG, RUN and Tone-Pairs commands   */
/*              to the device, using the parameters included in         */
/*              'SetupDevice' structure.                                */
/*              If AC481XX_DEVICE enabled, then, Tone-Pairs command have*/
/*              not execute. Instead of this, IBS, User Defined Tones,  */
/*              and Call Progress commands will be executed.             */
/*              All the commands sent concatenately, in                 */
/*              DONT_WAIT_PACKET_EMPTY mode, use a special method,      */
/*              explained in the documentation.                         */
/*                                                                      */
/* Inputs  :    int Stage	                                            */
/*                  To be used according to the method, explained in    */
/*                  the documentation.                                  */
/*              int DeviceIndex 	                                    */
/*                  An integer, performing the device index.            */
/*              TSetupDevice *SetupDevice 	                            */
/*                  Parameter structure for setup.                      */
/* Output  :    int:                                                    */
/*                  (LAST_STAGE_COMPLETED) - for successful operation   */
/*                  (ERROR) - if one of the command calls failed        */
/*                  (>=FIRST_STAGE) -  the stage number, the function   */
/*                                     has not yet completed.           */
/*======================================================================*/
int Ac48xxSetupDevice(int Stage, int DeviceIndex, TSetupDevice SetupDevice)
{
    int CheckError=0;

    switch(Stage)
    {
        case FIRST_STAGE:	/* 10 == Stage */
            Ac48xxSetHPIByteOrder(DeviceIndex, LSB_FIRST); /*SetupDevice.Order*/
            Stage++;

        case(FIRST_STAGE+1):
            CheckError = Ac48xxMSigCommand(DeviceIndex, SetupDevice.MSig,
            								DONT_WAIT_PACKET_EMPTY);
            if(CheckError)
                break;
            Stage++;

        case(FIRST_STAGE+2):	
            CheckError = Ac48xxDebugCommand(DeviceIndex, 
            								SetupDevice.DebugingData, 
            								DONT_WAIT_PACKET_EMPTY);
            if(CheckError)
                break;
            Stage++;

        case(FIRST_STAGE+3):	
            CheckError = Ac48xxPcmCommand(DeviceIndex, 
            							    &SetupDevice.PcmAttributes, 
            							    DONT_WAIT_PACKET_EMPTY
            							    );
            if(CheckError)
                break;
#if AC48_DEVICE == AC481XX_DEVICE || AC48_DEVICE == AC4830X_DEVICE
            Stage++;

        case(FIRST_STAGE+4):
            CheckError = Ac48xxDecoderDelayCommand(DeviceIndex,
            							SetupDevice.DecoderDelay,
            							DONT_WAIT_PACKET_EMPTY
            							);
            if(CheckError)
                break;
#else
            Stage++;
#endif /* AC48_DEVICE */ 

#if AC48_SIGNALING_MODE == AC48_BASIC_SIGNALING_MODE
            Stage++;

        case(FIRST_STAGE+5):
            CheckError = Ac48xxRunCommand(DeviceIndex, 
            							    DONT_WAIT_PACKET_EMPTY);
            if(CheckError)
                break;
            Stage++;

        case(FIRST_STAGE+6):
            CheckError = Ac48xxTonePairsCommand(DeviceIndex,
            							&SetupDevice.TonePair[0],
            							SetupDevice.PairQuantity,
            							SetupDevice.DebugingData,
            							DONT_WAIT_PACKET_EMPTY
            							);
            if(CheckError)
                break;
#elif AC48_SIGNALING_MODE == AC48_EXTENDED_SIGNALING_MODE
            Stage++;

        case(FIRST_STAGE+5):
#if AC48_DEVICE != AC4830X_DEVICE
            CheckError = Ac48xxExtendedSignalingCommand(DeviceIndex, 
                                        EXTENDED_SIGNALING,
            							DONT_WAIT_PACKET_EMPTY);
            if(CheckError)
                break;
#endif /* AC48_DEVICE */ 
            Stage++;

        case(FIRST_STAGE+6):
            CheckError = Ac48xxCallProgressCommand(DeviceIndex, 
                                        SetupDevice.CallProgress, 
            							DONT_WAIT_PACKET_EMPTY);
            if(CheckError)
                break;
            Stage++;

        case(FIRST_STAGE+7):
            CheckError = Ac48xxUserDefinedTonesCommand(DeviceIndex, 
                                        SetupDevice.UserDefinedTones,
                                        DONT_WAIT_PACKET_EMPTY);
            if(CheckError)
                break;
            Stage++;

        case(FIRST_STAGE+8):
            CheckError = Ac48xxRunCommand(DeviceIndex, 
            							    DONT_WAIT_PACKET_EMPTY);
            if(CheckError)
                break;
#endif /* AC48_SIGNALING_MODE */ 

            return LAST_STAGE_COMPLETED; /* 0 */
    }

    if(CheckError == -1)	/* PACKET_FULL */
    {
        return Stage;
    }
    
    return AC_ERROR;			/* 1 */
}

/*======================================================================*/
/* Name    :        Ac48xxSetupDeviceCompletely                         */
/*======================================================================*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -