?? c6711_edma.c
字號:
/*****************************************************************************
* File name : C6711_EDMA.c
* Description:
******************************************************************************/
#ifndef MASTER_FILE
#define C6711_GLOBALS
#include "includes.h"
#endif
#include "EDM.H"
static unsigned short channel_used_flag=0x0000;
#define LINKED 0x12345
/******************************************************************************
* Function : edma_init()
* Description: This function initialize the selected event Parameters RAM
******************************************************************************/
void edma_init(
unsigned short chan,
unsigned int opt,
unsigned int src_addr,
unsigned int element_count,
unsigned int frame_count,
unsigned int dst_addr,
unsigned int element_index,
unsigned int frame_index,
unsigned int elecnt_reload
)
{
EDMA_OPT_WRITE(chan,opt);
EDMA_SRC_WRITE(chan,src_addr);
EDMA_DST_WRITE(chan,dst_addr);
EDMA_ELECNT_WRITE(chan,element_count);
EDMA_FRMCNT_WRITE(chan,frame_count);
EDMA_ELEIDX_WRITE(chan,element_index);
EDMA_FRMIDX_WRITE(chan,frame_index);
EDMA_ELERLD_WRITE(chan,elecnt_reload);
channel_used_flag|=(1 << chan); /* Set channel_used_flag */
}
/******************************************************************************
Function : edma_reset()
Description: This function reset the selected event Parameters to 0.
******************************************************************************/
void edma_reset(unsigned char chan)
{
EDMA_OPT_WRITE(chan,0);
EDMA_SRC_WRITE(chan,0);
EDMA_DST_WRITE(chan,0);
EDMA_ELECNT_WRITE(chan,0);
EDMA_FRMCNT_WRITE(chan,0);
EDMA_ELEIDX_WRITE(chan,0);
EDMA_FRMIDX_WRITE(chan,0);
EDMA_LINK_WRITE(chan,0);
EDMA_ELERLD_WRITE(chan,0);
channel_used_flag&=(~(1 << chan)); /* Clear channel_used_flag */
}
/******************************************************************************
* Function : edma_pri_set()
* Description: This function set channel Priority levels for EDMA events
* only level1 and level2 is available for EDMA.
* 001b Level1: high priority
* 010b Level2: low priority
*****************************************************************************/
void edma_pri_set(unsigned char chan)
{
if(edma_pqsr_query(1))
OPT_PRI_WRITE(chan,1);
else
OPT_PRI_WRITE(chan,2);
}
/******************************************************************************
Function : edma_link()
Description: If LINK=1, upon completion of a transfer, the function reloads
the current transfer parameters with the parameter pointed to
by the 16-bit link address.
the last transfer parameter entry should have its LINK=1 and
last entry should be linked to a NULL parameter set,so that
the linked transfer stops after the last transfer.
The link address must be aligned on a 24-byte boundary.
Parameters: chan------------the first channel needing parameter linking.
chan_link[16]---list of channel will be linked,its
corresponding flag is LINKED(0x12345).
null_para_addr--the address of NULL parameter set.
******************************************************************************/
BOOLEAN edma_link(unsigned char chan,
unsigned char chan_link[16],
unsigned int null_para_addr
)
{
unsigned int link_addr;
unsigned int i,j,link_num=0;
BOOLEAN link_finish;
j=chan;
for(i=0;i<16;i++)
{
while((chan_link[i]!=LINKED)&&(i<16)) i++;
link_num++; /**/
if(i=chan) /* autoinitialization to facilitate the use of */
{ /* circular buffering and repetitive transfers */
if(link_num==0)
{
link_addr = EDMA_EVENT_PARAMETER(chan);
link_finish=TRUE;
break;
}
else
{
link_finish=FALSE;
break;
}
}
else
{
link_addr = EDMA_EVENT_PARAMETER(i);
EDMA_LINK_WRITE(j,link_addr);
j=i;
EDMA_SYNC_DISABLE(i);
OPT_LINK_ENABLE(i);
}
}
if(link_num)
{
EDMA_LINK_WRITE(j,null_para_addr);
link_finish=TRUE;
}
return link_finish;
}
/******************************************************************************
Function : edma_chain()
Description: Enable an events that is driven by a peripheral or external
device to trigger an EDMA transfer through chain several EDMA
channels from one event.
Parameters: chan---the channel needing chaining.
event--Interrupt event to trigger a EDMA transfer.
******************************************************************************/
BOOLEAN edma_chain(unsigned char chan,unsigned char event)
{
BOOLEAN chain_finish;
if(!((1<<chan)&0x0f00)) /* Only channel 8,9,10,11 can be triggered */
chain_finish=FALSE;
else
{
/*Assign channel number to TCC of the event entry parameter */
OPT_TCC_WRITE(event,chan);
/*Enable the event's Corresponding Channel transfer complete interrupt */
OPT_TCINT_ENABLE(event);
/*Enable channel chain */
EDMA_CHAIN_ENABLE(chan);
chain_finish=TRUE;
}
return chain_finish;
}
/******************************************************************************
Function : edma_int_map()
Description:
******************************************************************************/
void edma_int_map(unsigned char intr_flag,
unsigned short intr_chan)
{
int i;
for(i=0;i<16;i++)
{
if(intr_chan&(1<<i))
{
OPT_TCC_WRITE(i,intr_flag);
OPT_TCINT_ENABLE(i);
}
}
EDMA_INT_ENABLE(intr_flag);
}
/******************************************************************************
Function : edma_intr_query()
Description: Query if there pending events corresponding to EDMA interrupt
******************************************************************************/
unsigned char edma_intr_query()
{
int i=0;
while((EDMA_INTFLAG_READ(i))&&(i<16)) i++; /*Find the interrupt event */
if((i>=0)&&(i<16))
{
EDMA_INTFLAG_CLR(i); /* Clear the event's interrupt flag */
return i; /* return the interrupt event number */
}
else
return 0xFF;
}
/* END OF FILE */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -