📄 bbu_dd_mcbspadl.c
字号:
* *
* 返回值: Return a pointer to McBSP handle *
* 说明: *
*******************************************************************************/
CSLAPI MCBSP_Handle *MCBSP_open(Sint32 portNum)
{
Uint32 gie;
MCBSP_Handle *hMcbsp = MCBSP_HINV;
gie = IRQ_globalDisable();
if (mcbspPortHandle[portNum].allocated == FALSE)
{
hMcbsp = &(mcbspPortHandle[portNum]);
mcbspPortHandle[portNum].allocated = TRUE;
MCBSP_reset(hMcbsp);
}
IRQ_globalRestore(gie);
return hMcbsp;
}
/*----------------------------------------------------------------------------*/
/*******************************************************************************
* 函数名称: MCBSP_close *
* 函数描述: Close and reset a McBSP Device previously opened via MCBSP_open() *
* 相关文档: *
* 参数描述: *
* 参数名 类型 输入/输出 描述 *
* -------- ---- --------- ----------- *
* hMcbsp MCBSP_Handle* in Handle for Mcbsp Device *
* *
* 返回值: Return a pointer to McBSP handle *
* 说明: *
*******************************************************************************/
CSLAPI void MCBSP_close(MCBSP_Handle *hMcbsp)
{
Uint32 gie;
gie = IRQ_globalDisable();
if (hMcbsp != MCBSP_HINV)
{
MCBSP_reset(hMcbsp);
hMcbsp->allocated = FALSE;
}
IRQ_globalRestore(gie);
}
/*----------------------------------------------------------------------------*/
/*******************************************************************************
* 函数名称: MCBSP_init *
* 函数描述: McBSP Port Initialization *
* 相关文档: *
* 参数描述: *
* 参数名 类型 输入/输出 描述 *
* -------- ---- --------- ----------- *
* portNum Sint32 in McBSP Port Number *
* *
* 返回值: Return a pointer to McBSP handle *
* 说明: *
*******************************************************************************/
CSLAPI MCBSP_Handle *MCBSP_init(Sint32 portNum)
{
MCBSP_Handle *hMcbsp;
Uint32 delayNum;
switch (portNum)
{
/* Open EDMA and Link Channel for McBSP Port0 Transmitting and Receiving Data */
case MCBSP_PORT0: edmaMcbspXHandle[MCBSP_PORT0] = EDMA_open(EDMA_CHA_XEVT0);
edmaMcbspRHandle[MCBSP_PORT0] = EDMA_open(EDMA_CHA_REVT0);
edmaMcbspRLHandle1[MCBSP_PORT0] = EDMA_allocLink(EDMA_CHA_LINK2);
edmaMcbspRLHandle2[MCBSP_PORT0] = EDMA_allocLink(EDMA_CHA_LINK3);
break;
/* Open EDMA and Link Channel for McBSP Port1 Transmitting and Receiving Data */
case MCBSP_PORT1: edmaMcbspXHandle[MCBSP_PORT1] = EDMA_open(EDMA_CHA_XEVT1);
edmaMcbspRHandle[MCBSP_PORT1] = EDMA_open(EDMA_CHA_REVT1);
edmaMcbspRLHandle1[MCBSP_PORT1] = EDMA_allocLink(EDMA_CHA_LINK4);
edmaMcbspRLHandle2[MCBSP_PORT1] = EDMA_allocLink(EDMA_CHA_LINK5);
break;
/* Open EDMA and Link Channel for McBSP Port2 Transmitting and Receiving Data */
case MCBSP_PORT2: edmaMcbspXHandle[MCBSP_PORT2] = EDMA_open(EDMA_CHA_XEVT2);
edmaMcbspRHandle[MCBSP_PORT2] = EDMA_open(EDMA_CHA_REVT2);
edmaMcbspRLHandle1[MCBSP_PORT2] = EDMA_allocLink(EDMA_CHA_LINK6);
edmaMcbspRLHandle2[MCBSP_PORT2] = EDMA_allocLink(EDMA_CHA_LINK7);
break;
}
hMcbsp = (MCBSP_Handle *)MCBSP_open(portNum);
if (hMcbsp == MCBSP_HINV)
{
return hMcbsp;
}
MCBSP_config(hMcbsp, &mcbspConfig[portNum]);
delayNum = 0x100;
while(delayNum != 0) {--delayNum;} /* Wait for proper internal synchronization */
MCBSP_enableSrgr(hMcbsp); /* start sample rate generator */
delayNum = 0x100;
while(delayNum != 0) {--delayNum;} /* Wait for synchronization */
MCBSP_enableXmt(hMcbsp); /* Clear any potential XSYNCERR */
delayNum = 0x100;
while(delayNum != 0) {--delayNum;}
MCBSP_disableXmt(hMcbsp);
return hMcbsp;
}
/*----------------------------------------------------------------------------*/
/*******************************************************************************
* 函数名称: MCBSP_startEdmaX *
* 函数描述: McBSP Port Starting the Specfic EDMA Channel to Send Data *
* 相关文档: *
* 参数描述: *
* 参数名 类型 输入/输出 描述 *
* -------- ---- --------- ----------- *
* hEdma EDMA_Handle in EDMA Handle for McBSP Port *
* config EDMA_McbspXConfig* in Pointer to McBSP's EDMA Config Para*
* *
* 返回值: EDMA_OK *
* 说明: *
*******************************************************************************/
CSLAPI void MCBSP_startEdmaX(EDMA_Handle hEdma,EDMA_McbspXConfig *config)
{
EDMA_ParaConfig edmaMcbspXPara;
Uint32 tccNum;
Uint32 frameCount;
/* Get the Transfer Complete Code of the EDMA Channel */
tccNum = (hEdma & 0x00FF0000)>>16;
/* Disable the EDMA Channel Interrupt and Clear out the Interrupt Flag */
EDMA_intDisable(tccNum);
EDMA_intClear(tccNum);
/* Disable the EDMA Channel and Clear out the Event */
EDMA_disableChannel(hEdma);
EDMA_clearChannel(hEdma);
/* Setting the Frame Counts of the EDMA Transfer */
frameCount = 0;
if ((config->frameCount) != 0)
{
frameCount = (config->frameCount) - 1;
}
/* Constructing the Structure of EDMA Parameters */
edmaMcbspXPara.opt = 0x01000000;
edmaMcbspXPara.src = (Uint32)(config->sourAdd);
edmaMcbspXPara.cnt = (frameCount << 16) | ((config->eleCount) & 0x0000FFFF);
edmaMcbspXPara.dst = (Uint32)(config->destAdd);
edmaMcbspXPara.idx = 0x00000000;
edmaMcbspXPara.rld = ((config->eleCount) & 0x0000FFFF) << 16;
/* Config the EDMA Channel */
EDMA_config(hEdma, &edmaMcbspXPara);
/* Setting the Priority of the EDMA Transfer */
EDMA_FSETH(hEdma,OPT,PRI,config->priority);
/* Setting the Transfer Complete Code of the EDMA Channel */
EDMA_FSETH(hEdma,OPT,TCCM,(tccNum & 0x30) >> 4);
EDMA_FSETH(hEdma,OPT,TCC,tccNum & 0x0F);
/* Enable the Transfer Complete Code Generating EDMA Interrupt */
EDMA_FSETH(hEdma,OPT,TCINT,EDMA_OPT_TCINT_YES);
EDMA_intEnable(tccNum);
/* Enable the EDMA Channel */
EDMA_enableChannel(hEdma);
}
/*----------------------------------------------------------------------------*/
/*******************************************************************************
* 函数名称: MCBSP_startEdmaR *
* 函数描述: McBSP Port Starting the Specfic EDMA Channel to Receive Data *
* 相关文档: *
* 参数描述: *
* 参数名 类型 输入/输出 描述 *
* -------- ---- --------- ----------- *
* hEdma EDMA_Handle in EDMA Handle for McBSP Port *
* config EDMA_McbspRConfig* in Pointer to McBSP's EDMA Config Para*
* *
* 返回值: EDMA_OK *
* 说明: *
*******************************************************************************/
CSLAPI void MCBSP_startEdmaR(EDMA_Handle hEdma,EDMA_McbspRConfig *config)
{
EDMA_ParaConfig edmaMcbspRPara,edmaLinkPara1,edmaLinkPara2;
Uint32 tccNum;
Uint32 frameCount;
/* Get the Transfer Complete Code of the EDMA Channel */
tccNum = (hEdma & 0x00FF0000)>>16;
/* Disable the EDMA Channel Interrupt and Clear out the Interrupt Flag */
EDMA_intDisable(tccNum);
EDMA_intClear(tccNum);
/* Disable the EDMA Channel and Clear out the Event */
EDMA_disableChannel(hEdma);
EDMA_clearChannel(hEdma);
/* Setting the Frame Counts of the EDMA Transfer */
frameCount = 0;
if ((config->frameCount) != 0)
{
frameCount = (config->frameCount) - 1;
}
/* Constructing the Structure of EDMA Parameters */
edmaMcbspRPara.opt = 0x00200002;
edmaMcbspRPara.src = (Uint32)(config->sourAdd);
edmaMcbspRPara.cnt = (frameCount << 16) | ((config->eleCount) & 0x0000FFFF);
edmaMcbspRPara.dst = (Uint32)(config->pingAdd);
edmaMcbspRPara.idx = 0x00000000;
edmaMcbspRPara.rld = ((config->eleCount) & 0x0000FFFF) << 16;
/* Constructing the Structure of Link1 Channel Parameters */
edmaLinkPara1.opt = edmaMcbspRPara.opt;
edmaLinkPara1.src = edmaMcbspRPara.src;
edmaLinkPara1.cnt = edmaMcbspRPara.cnt;
edmaLinkPara1.dst = (Uint32)(config->pongAdd);
edmaLinkPara1.idx = edmaMcbspRPara.idx;
edmaLinkPara1.rld = edmaMcbspRPara.rld;
/* Constructing the Structure of Link1 Channel Parameters */
edmaLinkPara2.opt = edmaMcbspRPara.opt;
edmaLinkPara2.src = edmaMcbspRPara.src;
edmaLinkPara2.cnt = edmaMcbspRPara.cnt;
edmaLinkPara2.dst = (Uint32)(config->pingAdd);
edmaLinkPara2.idx = edmaMcbspRPara.idx;
edmaLinkPara2.rld = edmaMcbspRPara.rld;
/* Config the EDMA Channel */
EDMA_config(hEdma,&edmaMcbspRPara);
EDMA_FSETH(hEdma,OPT,PRI,config->priority);
EDMA_FSETH(hEdma,OPT,TCCM,(tccNum & 0x30) >> 4);
EDMA_FSETH(hEdma,OPT,TCC,tccNum & 0x0F);
EDMA_FSETH(hEdma,OPT,TCINT,EDMA_OPT_TCINT_YES);
/* Config the Link1 Channel */
EDMA_config(config->hLEdma1,&edmaLinkPara1);
EDMA_FSETH(config->hLEdma1,OPT,PRI,config->priority);
EDMA_FSETH(config->hLEdma1,OPT,TCCM,(tccNum & 0x30) >> 4);
EDMA_FSETH(config->hLEdma1,OPT,TCC,tccNum & 0x0F);
EDMA_FSETH(config->hLEdma1,OPT,TCINT,EDMA_OPT_TCINT_YES);
/* Config the Link2 Channel */
EDMA_config(config->hLEdma2,&edmaLinkPara2);
EDMA_FSETH(config->hLEdma2,OPT,PRI,config->priority);
EDMA_FSETH(config->hLEdma2,OPT,TCCM,(tccNum & 0x30) >> 4);
EDMA_FSETH(config->hLEdma2,OPT,TCC,tccNum & 0x0F);
EDMA_FSETH(config->hLEdma2,OPT,TCINT,EDMA_OPT_TCINT_YES);
/* Forming the PingPong Buffer */
EDMA_link(hEdma,config->hLEdma1);
EDMA_link(config->hLEdma1,config->hLEdma2);
EDMA_link(config->hLEdma2,config->hLEdma1);
/* Enable the Transfer Complete Code Generating EDMA Interrupt */
EDMA_intEnable(tccNum);
/* Enable the EDMA Channel */
EDMA_enableChannel(hEdma);
}
/*----------------------------------------------------------------------------*/
/******************************************************************************\
* End of BBU_DD_McbspAdl.c
\******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -