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

📄 codec.c

📁 使用ti6713芯片
💻 C
字号:
/********************************************************************************\
\*DEC6713_AIC23_CODEC.C	V1.00
* Copyright	2003 by SEED Electronic Technology Ltd.
* All rights reserved. Property of SEED Electronic Technology Ltd.			                
* Designed by:	Hongshuai.Li								                                
*********************************************************************************/ 
/*DEC6713_AIC23_CEDEC.C	-CODEC appled functions.*/
#include <csl.h>
#include <csl_i2c.h>
#include <csl_mcasp.h>
#include <DEC6713.h>
#include <codec.h>

//MCASP_Handle DEC6713_AIC23_DATAHANDLE;
/********************************************************************************/
	/* Configure MCASP. */
	MCASP_ConfigGbl MyMCASPcfgGbl = {
		0x00000000, /* PFUNC -     All pins as McASP */
    	0x00000080, /* PDIR  -     XMT DATA output, rest are inputs */
    	0x00000000, /* DITCTL -    DIT mode disable */
    	0x00000000, /* DLBCTL -    Loopback disabled */
    	0x00000000  /* AMUTE  -    Never drive AMUTE */
	};
	
	//Set receive registers.
	MCASP_ConfigRcv MyMCASPcfgRcv = {
		/* RMASK */
		0xffffffff, /* RMASK -     Use all 32 bits */
    	0x000180f8, /* RFMT -      MSB first, 32-bit slots, CPU bus, 0 bit delay */
    	0x00000000, /* AFSRCTL -   burst, single bit frame sync, ext FS */
    	0x00000080, /* ACLKRCTL -  Sample on rising CLK, divide by 1, ext CLK */
    	0x00000000, /* AHCLKRCTL - External HCLK */
    	0x00000001, /* RTDM -      Slots 0-31 are active */
    	0x00000000, /* RINTCTL -   No interrupts */
    	0x00000000  /* RCLKCHK -   Not used */ 
	};
	//Set serial control.
	MCASP_ConfigSrctl MyMCASPcfgSrctl = {
		0x00000000, /* SRCTL0 -    Inactive */
    	0x00000000, /* SRCTL1 -    Inactive */
    	0x00000000, /* SRCTL2 -    Inactive */
    	0x00000000, /* SRCTL3 -    Inactive */
    	0x00000000, /* SRCTL4 -    Inactive */
    	0x00000000, /* SRCTL5 -    Inactive */
    	0x0000000E, /* SRCTL6 -    Receive, active high */
    	0x0000000D  /* SRCTL7 -    Transmit, active high */
	};
	
	//Set transmit registers.
	MCASP_ConfigXmt MyMCASPcfgXmt = {
		/* XMASK */
		0xffffffff, /* XMASK -     Use all 32 bits */
    	0x000180f8, /* XFMT -      MSB first, 32-bit slots, CPU bus, 0 bit delay */
    	0x00000000, /* AFSXCTL -   burst, single bit frame sync, ext FS */
    	0x000000c0, /* ACLKXCTL -  Sample on falling CLK, divide by 1, ext CLK */
    	0x00000000, /* AHCLKXCTL - External HCLK */
    	0x00000001, /* XTDM -      Slots 0-31 are active */
    	0x00000000, /* XINTCTL -   No interrupts */
    	0x00000000  /* XCLKCHK -   Not used */
	};
	MCASP_Config MyMCASPConfig = {
		&MyMCASPcfgGbl,
		&MyMCASPcfgRcv,
		&MyMCASPcfgXmt,
		&MyMCASPcfgSrctl,
	};
/********************************************************************************\
\*DEC6713_AIC23_OpenCodec()	-Open the codec AIC23.
\*							Configure AXR1[7] as transmit port and AXR1[6] as 
\*							receive port.
\*Parameters:
\*
\*
\*Return:
\********************************************************************************/
MCASP_Handle DEC6713_AIC23_OpenCodec()
{
	MCASP_Handle DEC6713_AIC23_DATAHANDLE;
	Uint32 gblctl;
//	Uint32 RegAddr;
		
	DEC6713_AIC23_DATAHANDLE = MCASP_open(MCASP_DEV1,MCASP_OPEN_RESET);
	
	/* Reset MCASP to default values by setting GBLCTL = 0.*/
	MCASP_reset(DEC6713_AIC23_DATAHANDLE);
	
	
	MCASP_config(DEC6713_AIC23_DATAHANDLE,&MyMCASPConfig);
	
	/* Clear transmit and receive status ,清除发送与接收状态*/
	MCASP_RSETH(DEC6713_AIC23_DATAHANDLE,XSTAT,0xFFFF);
	MCASP_RSETH(DEC6713_AIC23_DATAHANDLE,RSTAT,0xFFFF);
	
	gblctl = 0;
    MCASP_RSETH(DEC6713_AIC23_DATAHANDLE, GBLCTL, gblctl);
    gblctl = 0x404;
    /*使能发送与接收的串行寄存器*/    
    MCASP_RSETH(DEC6713_AIC23_DATAHANDLE, GBLCTL, 0x404);
            
	
	/* Enable transmit/receive state machines */
    MCASP_RSETH(DEC6713_AIC23_DATAHANDLE, XBUF7, 0);
    MCASP_RSETH(DEC6713_AIC23_DATAHANDLE, RBUF6, 0);
    gblctl = 0x0c0c;
    MCASP_RSETH(DEC6713_AIC23_DATAHANDLE, GBLCTL, gblctl);
	

	return(DEC6713_AIC23_DATAHANDLE);
}

/********************************************************************************/
/********************************************************************************\
\*DEC6713_AIC23_CloseCodec()
\*Parameters:
\*Return:
\********************************************************************************/
void DEC6713_AIC23_CloseCodec(MCASP_Handle HMcASP)
{
	MCASP_close(HMcASP);
}

/********************************************************************************/
/* End of CODEC.C */
/********************************************************************************/



⌨️ 快捷键说明

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