📄 dec6713_codec.c
字号:
/******************************************************************************/
/* Copyright 2004 by SEED Electronic Technology LTD. */
/* All rights reserved. SEED Electronic Technology LTD. */
/* Restricted rights to use, duplicate or disclose this code are */
/* granted through contract. */
/******************************************************************************/
/********************************************************************************\
\*DEC6713_CODEC.c -Codec AIC23B test programme.
\*
\*
\*
\********************************************************************************/
#include <csl.h>
#include <csl_mcasp.h>
#include <csl_i2c.h>
#include <DEC6713.h>
#include <codec.h>
#include <IIC.h>
extern far void vectors();
Uint32 DataBuffer[1000] = {0};
Uint32 i;
Uint32 TempData=0;
Uint32 Reg=0;
/********************************************************************************/
/********************************************************************************/
void main()
{
MCASP_Handle hMcasp;
I2C_Handle hI2C;
for(i=0;i<1000;i++)
DataBuffer[i] = 0;
/* Initialize CSL. */
CSL_init();
/* Initialize DEC6713 board. */
DEC6713_init();
IRQ_setVecs(vectors); /* point to the IRQ vector table */
IRQ_globalEnable(); /* Globally enable interrupts */
IRQ_nmiEnable(); /* Enable NMI interrupt */
// IRQ_map(IRQ_EVT_VINT1, 11);
// IRQ_map(IRQ_EVT_VINT0, 12);
// IRQ_reset(IRQ_EVT_VINT1);
// IRQ_reset(IRQ_EVT_VINT1);
/****************************************************************************/
//TempReg = DEC6713_CTL_REG;
//DEC6713_cpld_rset(TempReg,0x40);
/****************************************************************************/
/* Initialize I2C0. */
/* Open I2C0. */
hI2C = I2C_open(I2C_DEV0,I2C_OPEN_RESET);
/* 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,Power_Down_Control,0x00);
//DEC6713_wait(100);
/* Set digital interface for AIC23. */
I2C_write16(hI2C,Digital_Audio_Interface_Format,0x53);//0x52
//DEC6713_wait(100);
/* Set analog channel for AIC23. */
I2C_write16(hI2C,Analog_Audio_Path_Control,0x10);
//DEC6713_wait(100);
/* Set digital channel for AIC23. */
I2C_write16(hI2C,Digital_Audio_Path_Control,0x01);
//DEC6713_wait(100);
/* Set sample rate for AIC23. */
I2C_write16(hI2C,Sample_Rate_Control,0x00);
//DEC6713_wait(100);
/* Set volume for headphone. */
I2C_write16(hI2C,Left_Channel_Headphone_Volume_Control,0xF9);
//DEC6713_wait(100);
/* Set volume for line in. */
I2C_write16(hI2C,Left_Line_Input_Channel_Volume_Control,0x17);
//DEC6713_wait(100);
I2C_write16(hI2C,Right_Line_Input_Channel_Volume_Control,0x17);
//DEC6713_wait(100);
/* Start AIC23. */
I2C_write16(hI2C,Digital_Interface_Activation,0x01);
DEC6713_wait(1000);
/* Replay the audio. */
hMcasp = DEC6713_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,0X80);
DEC6713_wait(0x1000);
MCASP_clearPins(hMcasp,0X80);
DEC6713_wait(0x1000);
}
*/
/*
if(MCASP_FGETH(hMcasp,RSTAT,RDATA))
{
TempData = MCASP_RGETH(hMcasp,RBUF6);
MCASP_RSETH(hMcasp,XBUF7,TempData);
}
*/
if (MCASP_RGETH(hMcasp, SRCTL6) & 0x20)
{
TempData = MCASP_read32Cfg(hMcasp,MCASP_RBUF6);
DataBuffer[i]=TempData;
i++;
if(i==1000)
{
i=0;
}
}
if (MCASP_RGETH(hMcasp, SRCTL7) & 0x10)
{
MCASP_write32Cfg(hMcasp,MCASP_XBUF7,TempData);
}
}
}
/********************************************************************************/
/* End of DEC6713_CODEC.C */
/********************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -