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

📄 ac48drhi.c

📁 this for the ac founction in voip.
💻 C
📖 第 1 页 / 共 5 页
字号:
    strcat(Name, "-S");
    strcpy(Version.Name, Name);

    return Version;
}
/*======================================================================*/
/* Name    :        Ac48xxKernelVersion                                 */
/*======================================================================*/
/* Purpose :   return software version packed in a structure, and the   */
/*             name of the version, by 'Name' argument.                 */
/*                                                                      */
/*======================================================================*/
TVersion Ac48xxKernelVersion(const char *KernelDownloadBlock, char *Name)
{
    return Ac48xxVersion(KernelDownloadBlock+KERNEL_VERSION_INFO_OFFSET, Name);
}
/*======================================================================*/
/* Name    :        Ac48xxKernelDownload                                */
/*======================================================================*/
/* Purpose :                                                            */
/*                                                                      */
/* Inputs  :                                                            */
/*======================================================================*/
void Ac48xxKernelDownload(int DeviceIndex, const char *KernelDownloadBlock,
															int KernelSize)
{
    int i=0;
    if(!KernelDownloadBlock)
    { 
        printf("ERROR:KernelDownloadBlock=NULL\n");
        return;
    }
    
    Ac48xxResetAssert(DeviceIndex);

#if   AC48_DEVICE == AC4830X_DEVICE
    Ac48xxResponseDelay();
    Ac48xxResetRelease(DeviceIndex);
#endif /* AC48_DEVICE */

    /* Set DSP to read/write MSB first */
    Ac48xxSetHPIByteOrder(DeviceIndex, MSB_FIRST);

    /* HPIA = AC48_KERNEL_ADDRESS */
    Ac48xxHostWrite((char)((AC48_KERNEL_ADDRESS-1)>>8), DeviceIndex, HPIA, First);
    Ac48xxHostWrite((char)(AC48_KERNEL_ADDRESS-1), DeviceIndex, HPIA, Second);

    /* write kernel to AC48 */
    for( i=0; i<KernelSize; i+=2)
    {
        Ac48xxHostWrite(*KernelDownloadBlock++, DeviceIndex, HPID, First);
        Ac48xxHostWrite(*KernelDownloadBlock++, DeviceIndex, HPID, Second);
    }

    /* write "packet full": */
    /* HPIA <= AC48_BOOT_STATUS_REGISTER */
    Ac48xxHostWrite((char)(AC48_BOOT_STATUS_REGISTER>>8), 
    							  DeviceIndex, HPIA, First);
    Ac48xxHostWrite((char)AC48_BOOT_STATUS_REGISTER, 
    							  DeviceIndex, HPIA, Second);

    /* HPID <= PACKET_FULL */
    Ac48xxHostWrite((char)0          , DeviceIndex, HPIDL, First);
    Ac48xxHostWrite((char)PACKET_FULL, DeviceIndex, HPIDL, Second);

#if AC48_DEVICE == AC4830X_DEVICE
    /* HPIA <= AC48_PROGRAM_ENTRY_POINT */
    Ac48xxHostWrite((char)((AC48_PROGRAM_ENTRY_POINT)>>8), 
    								  DeviceIndex, HPIA, First);
    Ac48xxHostWrite((char)(AC48_PROGRAM_ENTRY_POINT), 
    								  DeviceIndex, HPIA, Second);

    /* HPID = AC48_KERNEL_ADDRESS */
    Ac48xxHostWrite((char)(AC48_KERNEL_ADDRESS>>8), DeviceIndex, 
    											HPIDL, First);
    Ac48xxHostWrite((char)AC48_KERNEL_ADDRESS, DeviceIndex, 
    											HPIDL, Second);
    	/* Set DSP to read/write back to LSB first */
    Ac48xxSetHPIByteOrder(DeviceIndex, LSB_FIRST);

#else /* AC48_DEVICE */
    /* Set DSP to read/write back to LSB first */
    Ac48xxSetHPIByteOrder(DeviceIndex, LSB_FIRST);
    Ac48xxResetRelease(DeviceIndex);
#endif /* AC48_DEVICE */

}
/*======================================================================*/
/* Name    :        Ac48xxProgramVersion                                */
/*======================================================================*/
/* Purpose :   return software version packed in a structure, and the   */
/*             name of the version, by 'Name' argument.                 */
/*                                                                      */
/*======================================================================*/
TVersion Ac48xxProgramVersion(const char *ProgramDownloadBlock, char *Name)
{
	return Ac48xxVersion(ProgramDownloadBlock+PROGRAM_VERSION_INFO_OFFSET, Name);
}
/*======================================================================*/
/* Name    :        Ac48xxProgramDownload                               */
/*======================================================================*/
/* Purpose :                                                            */
/*                                                                      */
/* Inputs  :                                                            */
/*                                                                      */
/* Output  :    int:                                                    */
/*                  (LAST_STAGE_COMPLETED)                              */
/*                  (-1) + update the pointer to the Program Download   */
/*                         Blocks                                       */
/*                  (ERROR)                                             */
/**/
/*  Note   :    The "ProgramDownloadBlocks" is an address of a pointer  */
/*              to the Program Download memory Block.                   */
/*              At the begining, it points to the head of the memory    */
/*              Block. This pointer's value changes, to point to actual */
/*              byte readed by "Ac48xxProgramDownload" program.         */
/*              After successfull completion of the Download,           */ 
/*              "ProgramDownloadBlocks" will point to the last byte.    */
/*======================================================================*/
int Ac48xxProgramDownload(int DeviceIndex, const char **ProgramDownloadBlocks)
{
    int i, BlockLength, Status;
    static char LastBlockFlag=0;
    const unsigned char *Download;

    if(!ProgramDownloadBlocks)
    {
        printf("ProgramDownloadBlocks=NULL\n");
        return AC_ERROR;      /* NULL pointer */
    }

    /* Set DSP to read/write MSB first */
    Ac48xxSetHPIByteOrder(DeviceIndex, MSB_FIRST);
    Download = (unsigned char*)*ProgramDownloadBlocks;
    
    while(1)
    {
        /* HPIA <= AC48_BOOT_STATUS_REGISTER */
        Ac48xxHostWrite((char)(AC48_BOOT_STATUS_REGISTER>>8), DeviceIndex, HPIA, First);
        Ac48xxHostWrite((char)AC48_BOOT_STATUS_REGISTER, DeviceIndex, HPIA, Second);
        
        /* ignore first reading HPID  */
        Ac48xxHostRead(DeviceIndex, HPIDL, First);
        Ac48xxHostRead(DeviceIndex, HPIDL, Second);

        Ac48xxHostRead(DeviceIndex, HPIDL, First);
        Status = Ac48xxHostRead(DeviceIndex, HPIDL, Second);

        if(Status == PACKET_FULL)
        {	
            /* Set DSP to read/write back to LSB first */
            Ac48xxSetHPIByteOrder(DeviceIndex, LSB_FIRST);
            *ProgramDownloadBlocks = (char *)Download;
            return (-1);
        }
        if(Status != PACKET_EMPTY)
        {
            printf("PD status=%d\n", Status);
            Ac48xxSetHPIByteOrder(DeviceIndex, LSB_FIRST);
            return AC_ERROR;
        }
        		
        if(LastBlockFlag)	
        {		
            /* Set DSP to read/write back to LSB first */
            Ac48xxSetHPIByteOrder(DeviceIndex, LSB_FIRST);
            LastBlockFlag=0;
            return LAST_STAGE_COMPLETED;
        }
        
        LastBlockFlag = (Download[0] & 0x80);
        BlockLength =  ((int)(Download[4])<<8) | (int)((unsigned char)Download[5]);
        BlockLength += 5;	/* as is */

        /* HPIA <= AC48_PROGRAM_ADDRESS-1 */
        Ac48xxHostWrite((char)((AC48_PROGRAM_ADDRESS-1)>>8), 
        						DeviceIndex, HPIA, First);
        Ac48xxHostWrite((char)(AC48_PROGRAM_ADDRESS-1), 
        						DeviceIndex, HPIA, Second);

        for(i=0; i<BlockLength; i++) /* copy block */ 
        {
            Ac48xxHostWrite(*Download++, DeviceIndex, HPID, First);
            Ac48xxHostWrite(*Download++, DeviceIndex, HPID, Second);
        }
        
        /* write "packet full" */
        /* HPIA <= BOOT_STATUS_REGISTER */
        Ac48xxHostWrite((char)(AC48_BOOT_STATUS_REGISTER>>8), 
        						DeviceIndex, HPIA, First);
        Ac48xxHostWrite((char)AC48_BOOT_STATUS_REGISTER, 
        						DeviceIndex, HPIA, Second);

        /* HPID <= PACKET_FULL */
        Ac48xxHostWrite((char)0          , DeviceIndex, HPIDL, First);
        Ac48xxHostWrite((char)PACKET_FULL, DeviceIndex, HPIDL, Second);

        /* send interupt to DSP */
        Ac48xxHostWrite((SET_DSPINT | CLEAR_HINT | MSB_FIRST), 
        						DeviceIndex, HPIC, First);
        Ac48xxHostWrite((SET_DSPINT | CLEAR_HINT | MSB_FIRST), 
        						DeviceIndex, HPIC, Second);
    }
}

/*======================================================================*/
int Ac48xxProgramDownloadForDebugging(int DeviceIndex,
									  const char **ProgramDownloadBlocks,
                                      const char *ProgramDownloadStructure,
                                      FILE *BlockStructureFile)
{
	int i, BlockLength, Status;
	static char LastBlockFlag=0;
	const unsigned char *Download;
	if(!ProgramDownloadBlocks)
        {
        fprintf(BlockStructureFile, "'ProgramDownloadBlocks' not Allocated in Memory"); 
        return AC_ERROR;      /* NULL pointer */
        }
				/* Set DSP to read/write MSB first */
	Ac48xxSetHPIByteOrder(DeviceIndex, MSB_FIRST);
	Download = (unsigned char*)*ProgramDownloadBlocks;
	while(1)
		{
				/* HPIA <= AC48_BOOT_STATUS_REGISTER */
		Ac48xxHostWrite((char)(AC48_BOOT_STATUS_REGISTER>>8), DeviceIndex,
															HPIA, First);
		Ac48xxHostWrite((char)AC48_BOOT_STATUS_REGISTER, DeviceIndex,
															HPIA, Second);
				/* ignore first reading HPID  */
		Ac48xxHostRead(DeviceIndex, HPIDL, First);
		Ac48xxHostRead(DeviceIndex, HPIDL, Second);
		Ac48xxHostRead(DeviceIndex, HPIDL, First);
		Status = Ac48xxHostRead(DeviceIndex, HPIDL, Second);
		if(Status == PACKET_FULL)
			{	/* Set DSP to read/write back to LSB first */
			Ac48xxSetHPIByteOrder(DeviceIndex, LSB_FIRST);
			*ProgramDownloadBlocks = (char *)Download;
			if(BlockStructureFile)    
                fprintf(BlockStructureFile, 
                "                                    Status == %X (PACKET_FULL (-1))\n", Status); 
            return (-1);
			}
		if(Status != PACKET_EMPTY)
			{
			Ac48xxSetHPIByteOrder(DeviceIndex, LSB_FIRST);
			if(BlockStructureFile)    

⌨️ 快捷键说明

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