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

📄 dec643_codec.c

📁 c6000DSP中
💻 C
字号:
/********************************************************************/
/*  Copyright 2004 by SEED Incorporated.							*/
/*  All rights reserved. Property of SEED Incorporated.				*/
/*  Restricted rights to use, duplicate or disclose this code are	*/
/*  granted through contract.									    */
/*  															    */
/********************************************************************/
/*
	Designed by: Hongshai.Li
	Build:	06.22.2005
	Modify:
	Discription:The routine is for test audio codec aic23.
*/
/********************************************************************/
#include <csl.h>
#include <csl_mcasp.h>
#include <csl_i2c.h>
#include <csl_chip.h>
#include <DEC643.h>
#include <codec.h>
#include <IIC.h>

extern far void vectors();
Uint32 DataBuffer[1000] = {0};
Uint32 i;
Uint32 TempData=0;
Uint32 Reg=0;
/********************************************************************************/
I2C_Config DEC643IIC_Config = {
    0,  /* master mode,  i2coar;采用主模式   */
    0,  /* no interrupt, i2cimr;只写,不读,采用无中断方式*/
    (20-5), /* scl low time, i2cclkl;  */
    (20-5), /* scl high time,i2cclkh;  */
    1,  /* configure later, i2ccnt;*/
    0,  /* configure later, i2csar;*/
    0x4ea0, /* master tx mode,     */
            /* i2c runs free,      */
            /* 8-bit data + NACK   */
            /* no repeat mode      */
    (75-1), /* 4MHz clock, i2cpsc  */
};
/********************************************************************************/
CHIP_Config DEC643percfg = {
	CHIP_VP2+\
	CHIP_VP1+\
	CHIP_I2C+\
	CHIP_MCBSP0+\
	CHIP_MCASP0
};
/********************************************************************************/
void main()
 {
	MCASP_Handle hMcasp;
	I2C_Handle hI2C;

	/* Initialize CSL. */
	CSL_init();
	
	/* Initialize PERCFG, enable i2c */
	CHIP_config(&DEC643percfg);
	
	/* Initialize interrupt vectors. */
	IRQ_setVecs(vectors);     /* point to the IRQ vector table	*/
  	IRQ_globalEnable();       /* Globally enable interrupts       */ 
  	IRQ_nmiEnable();          /* Enable NMI interrupt */

	/* Initialize I2C0. */
		/* Open I2C0. */
		hI2C = I2C_open(I2C_PORT0,I2C_OPEN_RESET);
		
		I2C_config(hI2C,&DEC643IIC_Config);
		/* If i2c model clock frequency is lower, perhaps timer delay should be 
		   added between aic23 registers writting */
		/* Set all parts of AIC23 begin to work. */
		I2C_write16(hI2C,Left_Line_Input_Channel_Volume_Control,0x17);
		I2C_write16(hI2C,Right_Line_Input_Channel_Volume_Control,0x17);
		I2C_write16(hI2C,Left_Channel_Headphone_Volume_Control,0xF9);
		/* Set volume for line in. */
		I2C_write16(hI2C,Right_Channel_Headphone_Volume_Control,0xF9);
		I2C_write16(hI2C,Analog_Audio_Path_Control,0x11);		
		I2C_write16(hI2C,Digital_Audio_Path_Control,0x00);
		/* Set digital interface for AIC23. */

		/* Set analog channel for AIC23. */
		I2C_write16(hI2C,Power_Down_Control,0x00);
		I2C_write16(hI2C,Digital_Audio_Interface_Format,0x53);//0x52		/* Set digital channel for AIC23. */

		/* Set sample rate for AIC23. */
		I2C_write16(hI2C,Sample_Rate_Control,0x02);
		/* Set volume for headphone. */

		/* Start AIC23. */
		I2C_write16(hI2C,Digital_Interface_Activation,0x01);

		/* Replay the audio. */	
		hMcasp = DEC643_AIC23_OpenCodec();
		i=0;
	while(TRUE)
	{
		// The "for loop" is for testing AXRx[x], at that time ,AXRX is set
		//	as GPIO through seting PFUNC register.
		/*
		for(;;)
		{
			MCASP_setPins(hMcasp,0x01);
			DEC643_wait(0x1000);
			MCASP_clearPins(hMcasp,0x01);
			DEC643_wait(0x1000);
		
		}
		*/
		/*
		if(MCASP_FGETH(hMcasp,RSTAT,RDATA))
		{
			TempData = MCASP_RGETH(hMcasp,RBUF1);
			MCASP_RSETH(hMcasp,XBUF0,TempData);
		
		}
		*/
		if (MCASP_RGETH(hMcasp, SRCTL1) & 0x20) 
		{
        	TempData = MCASP_read32Cfg(hMcasp,MCASP_RBUF1);
        	//DataBuffer[i]=TempData;
        	//i++;
        	//if(i==1000)
        	//{
        	//	i=0;
        	//}
    	}
    
    	
    	if (MCASP_RGETH(hMcasp, SRCTL0) & 0x10) 
    	{
        	MCASP_write32Cfg(hMcasp,MCASP_XBUF0,TempData);
    	}
    	
	}
}
/********************************************************************************/
/* End of DEC643_AUDIO.C */
/********************************************************************************/

⌨️ 快捷键说明

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