?? seeddm642codec.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. */
/* */
/********************************************************************/
#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 */
0x00000000, /* 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*/
0x00000000, /* XINTCTL - No interrupts */
0x00000000 /* XCLKCHK - Not used */
};
MCASP_ConfigSrctl mcaspCfgDataSrctl = {
0x00000005, /* SRCTL0 - Receive, active high */
0x00000006, /* SRCTL1 - Transmit, active high*/
0x00000005, /* SRCTL2 - Receive, active high */
0x00000006, /* SRCTL3 - Transmit, active high */
0x00000005, /* SRCTL4 - Receive, active high */
0x00000006, /* SRCTL5 - Transmit, active high*/
0x00000005, /* SRCTL6 - Receive, active high */
0x00000006 /* 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;
}
/*
* ======== EVMDM642_AIC23_closeCodec ========
* Close the codec
*/
void SEEDDM642_AIC23_closeCodec(MCASP_Handle hMcASP)
{
/* Close the codec */
MCASP_close(hMcASP);
/* Turn the codec off */
// EVMDM642_AIC23_rset(hCodec, EVMDM642_AIC23_POWERDOWN, 0xff);
}
/*
* ======== EVMDM642_AIC23_write ========
* Write a 32-bit value to the codec
*/
Int16 SEEDDM642_AIC23_write(MCASP_Handle hMcASP,
Uint32 AIc23num,
Uint32 val)
{
// unsigned long *McASP_SRCTL0 = 0x01b4c180;
Uint32 regv = 0;
// *((unsigned long *)0x1b3f018) = 0x10c0010c;
/* If McBSP not ready for new data, return false */
regv = *((unsigned long *)(0x01b4c180 + AIc23num ));
if ((regv & 0x10) == 0)
{
return (FALSE);
}
*((unsigned long *)(0x01b4c200 + AIc23num )) =val;
/* Write data value */
// MCASP_RSETH(hMcASP, (XBUF0 + AIc23num), val);
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
return(TRUE);
}
/*
* ======== EVMDM642_AIC23_read ========
* Read a 32-bit value from the codec
*/
Int16 SEEDDM642_AIC23_read(MCASP_Handle hMcASP,
Uint32 AIc23num,
Uint32 *val)
{
Uint32 regv = 0;
// *((unsigned long *)0x1b3f018) = 0x10c0010c;
/* If McASP doesn't have new data available, return false */
regv = *((unsigned long *)(0x01b4c180 + AIc23num ));
if ((regv & 0x20) == 0)
{
return (FALSE);
}
/* Read the data */
*val = *((unsigned long *)(0x01b4c280 + AIc23num ));
return (TRUE);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -