●函数 Uint32 DAT_open(
int chaNum,
int priority, 优先级
Uint32 flags
);
●参数 chaNum 指定分配那个DMA通道,必须是下面其中之一:
DAT_CHAANY
DAT_CHA0
DAT_CHA1
DAT_CHA2
DAT_CHA3
priority 指定DMA通道的优先级必须是下面其中之一
DAT_PRI_LOW
DAT_PRI_HIGH
flags 各种各样的打开标志
DAT_OPEN_2D
●返回值 success 如果失败返回0,如果成功返回非零值,失败的原因如下:
DAT模块已经打开,
需要的资源没有被分派。
●描述 这个函数打开DAT模块,而且必须在调用其它DAT API 函数之前被调用,ChaNum 参数指定了哪个DMA通道被DAT模块单独的打开,对于带有EDMA的设备,ChaNum 参数被忽略,原因是快速使用的DMA并不具有一个和它匹配的通道,对具有DMA的设备,ChaNum指定了将要使用哪个DMA通道, DAT_PRI_LOW设置DMA通道的CPU优先级 DAT_PRI_HIGH 设置DMA通道的DMA优先级,对具有EDMA的设备, ChaNum 被忽略,DAT_PRI_LOW设置 LOW priority ,DAT_PRI_HIGH 设置HIGH priority,一旦 DAT 模块被打开,任何被分配的资源,例如一个DMA通道,仍然被分配,你可以调用 DAT_close() 来释放这些资源,如果,准备通过DAT_copy2d 来进行2Dde传输, DAT_OPEN_2D 标志必须被指定,对具有DMA接口的设备指定这个标志, 将要导致一个全局重载计数寄存器和一个全局索引寄存器的分配这些全局寄存器在调用DAT_close()时将被释放,注意:对具有EDMA的设备,DAT模块使用EDMA寄存器来提交传输请求,而且将使用通道中断挂起寄存器(CIPR),中断并不被使能 ,但是CIPR中的中断标志要用到, DAT模块使用完成码的1到4来计算一个在CIPR 寄存器中的掩码0x00000001E ,在具有EDMA的设备上使用DAT模块的用户必须避免使用完成码1到4。
使用任何有效的DMA通道来打开DAT模块的例子,
DAT_open(DAT_CHAANY,DAT_PRI_LOW,0);
用高优先级模式使用DMA通道2打开DAT模块,使用:
DAT_open(DAT_CHA2,DAT_PRI_HIGH,0);
使用2D拷贝打开DAT模块,使用:
DAT_open (DAT_CHAANY, DAT_PRI_HIGH, DAT_OPEN_2D);
DAT_copy Copies a linear block of data from Src to Dst using DMA or
EDMA hardware
Uint32 DAT_copy(
void *src,
void *dst,
Uint16 byteCnt
);
Arguments
void *src 是一个源地址指针,
void *dst 是目的地址指针,
Uint16 byteCnt 是一个无符号16位数,用来计算你要copy的byte数,这个值是以字节计算的。Return Value xfrId Transfer ID
函数的返回值是一个传输通道的标号(xfrId Transfer ID),一般用作句柄
描述:
用CSL的DAT之前好像也得先设置好DMA或EDMA的参数,DAT可以自动选择DMA或EDMA的方式和通道,但是具体传输时还是要用到DMA和EDMA的参数,所以即使是用DAT来传输数据,也不能回避掉DMA/EDMA的设置。
The DAT module must be opened before calling this . See
DAT_open().
The return value is a transfer identifier that may be used later on to wait for
completion. See DAT_wait().
Example #define DATA_SIZE 256
Uint32 BuffA[DATA_SIZE/sizeof(Uint32)];
Uint32 BuffB[DATA_SIZE/sizeof(Uint32)];
…
DAT_open(DAT_CHAANY,DAT_PRI_LOW,0);
DAT_copy(BuffA,BuffB,DATA_SIZE);
…
DAT_copy2d Performs a 2-dimensional data copy using DMA or EDMA hardware.
Uint32 DAT_copy2d(
Uint32 type,
void *src,
void *dst,
Uint16 lineLen,
Uint16 lineCnt,
Uint16 linePitch
);
Arguments type Transfer type:
\u0001 DAT_1D2D
\u0001 DAT_2D1D
\u0001 DAT_2D2D
src Pointer to source data
dst Pointer to destination location
lineLen Number of bytes per line
lineCnt Number of lines
linePitch Number of bytes between start of one line to start of next line
Return Value xfrId Transfer ID
Deion
Performs a 2-dimensional data copy using DMA or EDMA hardware,
depending on the device. The arguments are checked for alignment and the
hardware configured accordingly. For best performance on devices other than
C64x devices, you should ensure that the source address and destination
address are aligned on a 4-byte boundary and that the lineLen and
linePitch are multiples of 4-bytes.
For C64x devices, the EDMA uses a 64-bit bus (8 bytes) to L2 SRAM. For best
efficiency, the source and destination addresses should be aligned on an
8-byte boundary with the transfer rate a multiple of eight.
If the channel is busy with previous requests, this will block (spin) and
wait until it frees up before submitting this request.
Note: The DAT module must be opened with the DAT_OPEN_2D flag before
calling this . See DAT_open().
There are three ways to submit a 2D transfer: 1D to 2D, 2D to 1D, and 2D to
2D. This is specified using the type argument. In all cases, the number of bytes
copied is lineLen × lineCnt. The 1D part of the transfer is just a linear block
of data. The 2D part is illustrated in Figure 6-1.
If a 2D to 2D transfer is specified, both the source and destination have the
same lineLen, lineCnt, and linePitch.
The return value is a transfer identifier that may be used later on to wait for
completion. See DAT_wait().
Example DAT_copy2d (DAT_1D2D, buffA, buffB, 16, 8, 32);
DAT_wait Waits for a previous transfer to complete
void DAT_wait(
Uint32 id
);
Arguments id Transfer identifier, returned by one of the DAT copy or DAT fill routines.
Two predefined transfer IDs may be used:
\u0001 DAT_XFRID_WAITALL
\u0001 DAT_XFRID_WAITNONE
Using DAT_XFRID_WAITALL means wait until all transfers have
completed. Using DAT_XFRID_WAITNONE means do not wait for any
transfers to complete. This can be useful as the first operation in a
pipelined copy sequence.
Return Value none
Deion
This waits for a previous transfer to complete, identified by the transfer
ID. If the transfer has already completed, this returns immediately.
Interrupts are not disabled during the wait.
Example Uint32 transferId;
…
DAT_open(DAT_CHAANY, DAT_PRI_LOW, 0);
…
transferId = DAT_copy(src,dst,len);
/* user DAT configuration */
DAT_wait(transferId);