加了的,但是那个头文件里没有这个函数,我把全部代码贴上来,版主您帮忙看看问题到底出在哪,万分感谢。困扰了一周了,实在找不出问题出在哪
主程序:
#include <csl.h>
#include <std.h>
#include <csl_emifa.h>
#include <csl_i2c.h>
#include <csl_gpio.h>
#include <csl_irq.h>
#include <csl_chip.h>
#include <csl_timer.h> //定时中断采集
#include <csl_edma.h> //采用EDMA存取数据
#include <csl_mcasp.h>
#include "iic.h"
#include "seeddm642_aic23.h"
/*SEEDDM642的emifa的设置结构*/
EMIFA_Config Seeddm642ConfigA ={
0x00052078,/*gblctl EMIFA(B)global control register value */
/*将CLK6、4、1使能;将MRMODE置1;使能EK2EN,EK2RATE*/
0xffffffd3,/*cectl0 CE0 space control register value*/
/*将CE0空间设为SDRAM*/
0x73a28e01,/*cectl1 CE1 space control register value*/
/*Read hold: 1 clock;
MTYPE : 0000,选择8位的异步接口
Read strobe :001110;14个clock宽度
TA:2 clock; Read setup 2 clock;
Write hold :2 clock; Write strobe: 14 clock
Write setup :7 clock
-- ---------------
\ 14c /1c
\----------------/ */
0x22a28a22, /*cectl2 CE2 space control register value*/
0x22a28a42, /*cectl3 CE3 space control register value*/
0x57115000, /*sdctl SDRAM control register value*/
0x0000081b, /*sdtim SDRAM timing register value*/
0x001faf4d, /*sdext SDRAM extension register value*/
0x00000002, /*cesec0 CE0 space secondary control register value*/
0x00000002, /*cesec1 CE1 space secondary control register value*/
0x00000002, /*cesec2 CE2 space secondary control register value*/
0x00000073 /*cesec3 CE3 space secondary control register value*/
};
/********************************************************************/
/*SEEDDM642的IIC的设置结构*/
I2C_Config SEEDDM642IIC_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 */
};
/********************************************************************/
/*SEEDDM642的edma的设置结构*/
CHIP_Config SEEDDM642percfg = {
CHIP_VP2+\
CHIP_VP1+\
CHIP_VP0+\
CHIP_I2C+\
CHIP_MCASP0
};
I2C_Handle hSeeddm642i2c;
/*设置需打开的音频的句柄*/
SEEDDM642_AIC23_Handle dm642aic23handle0,dm642aic23handle1;
SEEDDM642_AIC23_Handle dm642aic23handle2,dm642aic23handle3;
/* Internal codec state used to simulate read/write functionality */
SEEDDM642_AIC23_Config codecstate = SEEDDM642_AIC23_DEFAULTCONFIG;
MCASP_Handle SEEDdm642codec;
extern far void vectors();
/*此程序可将四个采集口的数据经过Video Port0送出*/
void main()
{
// Uint32 codecdata;
/*-------------------------------------------------------*/
/* perform all initializations */
/*----------------------------------------------------------*/
/*Initialise CSL,初始化CSL库*/
CSL_init();
CHIP_config(&SEEDDM642percfg);
/*----------------------------------------------------------*/
/*EMIFA的初始化,将CE0设为SDRAM空间,CE1设为异步空间
注,DM642支持的是EMIFA,而非EMIF*/
EMIFA_config(&Seeddm642ConfigA);
//SEEDDM642_AIC23_openCodec();/*加上此句不能正常发声*/
/*----------------------------------------------------------*/
/*中断向量表的初始化*/
//Point to the IRQ vector table
//IRQ_EVT_RINT0= MCASP_getXmtEventId(SEEDDM642_AIC23_hMcASP);
IRQ_setVecs(vectors);
IRQ_nmiEnable();
IRQ_globalEnable();
IRQ_map(IRQ_EVT_XINT0, 11); //EMU实时数据交换(RTDX)映射到11 MUXH[9:5]=0x0a
IRQ_reset(IRQ_EVT_XINT0);
IRQ_enable(IRQ_EVT_XINT0);
/*IRQ_map(IRQ_EVT_VINT0,11); //EMU RTDX 发送 映射到12 MUXH[14:10]=0x0b
IRQ_reset(IRQ_EVT_VINT0);
IRQ_enable(IRQ_EVT_VINT0);
IRQ_map(IRQ_EVT_VINT1,12); //EMU RTDX 发送 映射到12 MUXH[14:10]=0x0b
IRQ_reset(IRQ_EVT_VINT1);
IRQ_enable(IRQ_EVT_VINT1); */
/*----------------------------------------------------------*/
/*AIC23B的初始化*/
hSeeddm642i2c = I2C_open(I2C_PORT0,I2C_OPEN_RESET);
I2C_config(hSeeddm642i2c,&SEEDDM642IIC_Config);
/*配置第一路到第四路音频输入*/
/*第一通路AIC23工作在主模式*/
//codecstate.regs[SEEDDM642_AIC23_DIGIF] = 0x13;
dm642aic23handle0 = EVMDM642_AIC23_open(hSeeddm642i2c,0,&codecstate);
/*其它三路工作在从模式*/
/* codecstate.regs[SEEDDM642_AIC23_DIGIF] = 0x13;
dm642aic23handle1 = EVMDM642_AIC23_open(hSeeddm642i2c,1,&codecstate);
dm642aic23handle2 = EVMDM642_AIC23_open(hSeeddm642i2c,2,&codecstate);
dm642aic23handle3 = EVMDM642_AIC23_open(hSeeddm642i2c,3,&codecstate);*/
/*----------------------------------------------------------*/
/*MCASP的初始化*/
SEEDdm642codec = SEEDDM642_AIC23_openCodec();
/*----------------------------------------------------------*/
/*音频的采集与回放*/
for(;;)
{
Uint32 codecdata;
if(MCASP_FGETH(SEEDdm642codec,RSTAT,RDATA))
{
codecdata= MCASP_RGETH(SEEDdm642codec,RBUF1);
MCASP_RSETH(SEEDdm642codec,XBUF0,codecdata);
}
}
}
/McASP初始化代码*********************************************************/
#include <csl.h>
#include <csl_i2c.h>
#include <csl_mcasp.h>
#include <seeddm642_aic23.h>
MCASP_ConfigGbl mcaspCfgDataGbl = {
0x00000000, /* PFUNC - All pins as McASP ,所有的管脚均为McAPS功能*/
0x00000055, /* PDIR - 0,2,4,6为input,1,3,5,7为XMT DATA output, 其它的为输入 */
0x00000000, /* DITCTL - DIT mode disable */
0x00000000, /* DLBCTL - Loopback disabled */
0x00000000 /* AMUTE - Never drive AMUTE */
};
MCASP_ConfigRcv mcaspCfgDataRcv = {
0xffffffff, /* RMASK - Use all 32 bits,左声道与右声道各16位 */
0x000180f8, /* RFMT - MSB first, 32-bit slots,0-pad,CPU bus, 0 bit delay,数据格式 */
0x00000200, /* AFSRCTL - burst, single bit frame sync, ext FS 帧同步的格式*/
0x00000080, /* ACLKRCTL - Sample on rising CLK, divide by 1, ext CLK */
0x00000000, /* AHCLKRCTL - External HCLK */
0x0000000f, /* RTDM - Slots 1,3,5,7 are active */
0x0000000DB0, /* RINTCTL - No interrupts */
0x00000000 /* RCLKCHK - Not used */
};
MCASP_ConfigXmt mcaspCfgDataXmt = {
0xffffffff, /* XMASK - Use all 32 bits */
0x000180f8, /* XFMT - MSB first, 32-bit slots, CPU bus, 0 bit delay */
0x00000200, /* AFSXCTL - burst, single bit frame sync, ext FS */
0x00000080, /* ACLKXCTL - Sample on falling CLK, divide by 1, ext CLK ,发送与接收同步*/
0x00000000, /* AHCLKXCTL - External HCLK */
0x00000005, /* XTDM - 0,2,4,6 enable*/
0x00000020, /* XINTCTL - No interrupts */
0x00000000 /* XCLKCHK - Not used */
};
MCASP_ConfigSrctl mcaspCfgDataSrctl = {
0x00000005, /* SRCTL0 - Receive, active high */
0x00000006, /* SRCTL1 - Transmit, active high*/
0x00000000, /* SRCTL2 - Receive, active high */
0x00000000, /* SRCTL3 - Transmit, active high */
0x00000000, /* SRCTL4 - Receive, active high */
0x00000000, /* SRCTL5 - Transmit, active high*/
0x00000000, /* SRCTL6 - Receive, active high */
0x00000000 /* SRCTL7 - Transmit, active high */
};
MCASP_Config mcaspCfgData = {
&mcaspCfgDataGbl,
&mcaspCfgDataRcv,
&mcaspCfgDataXmt,
&mcaspCfgDataSrctl
};
/***************************************************************************/
/* ======== EVMDM642_AIC23_openCodec ======== */
/* Open the codec and return a codec handle */
/***************************************************************************/
MCASP_Handle SEEDDM642_AIC23_openCodec()
{
Uint32 gblctl;
/* AIC23 handles,定义McASP的句柄*/
MCASP_Handle SEEDDM642_AIC23_hMcASP;
/* Open and configure the McASP*/
SEEDDM642_AIC23_hMcASP = MCASP_open(MCASP_DEV0, MCASP_OPEN_RESET);
/*配制McASP */
MCASP_config(SEEDDM642_AIC23_hMcASP, &mcaspCfgData);
/* Clear transmit and receive status ,清除发送与接收状态*/
MCASP_RSETH(SEEDDM642_AIC23_hMcASP, RSTAT, 0xffff);
MCASP_RSETH(SEEDDM642_AIC23_hMcASP, XSTAT, 0xffff);
/* Clear GBLCTL,将所有的单元复位 */
gblctl = 0;
MCASP_RSETH(SEEDDM642_AIC23_hMcASP, GBLCTL, gblctl);
gblctl = 0x404;
/*使能发送与接收的串行寄存器*/
MCASP_RSETH(SEEDDM642_AIC23_hMcASP, GBLCTL, 0x404);
/* Enable transmit/receive state machines */
MCASP_RSETH(SEEDDM642_AIC23_hMcASP, XBUF0, 0);
/* MCASP_RSETH(SEEDDM642_AIC23_hMcASP, XBUF2, 0);
MCASP_RSETH(SEEDDM642_AIC23_hMcASP, XBUF4, 0);
MCASP_RSETH(SEEDDM642_AIC23_hMcASP, XBUF6, 0);*/
gblctl = 0x0c0c;
MCASP_RSETH(SEEDDM642_AIC23_hMcASP, GBLCTL, gblctl);
return SEEDDM642_AIC23_hMcASP;
} |