1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows">
6<META http-equiv="Content-Style-Type" content="text/css">
7<TITLE>MI_DmaCopy</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">MI_DmaCopy* <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1>
12<H2>Syntax</H2>
13<DL>
14<DD><CODE>#include &lt;nitro/mi.h&gt;</CODE><BR> <BR> <CODE>void MI_DmaCopy32( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size );</CODE><BR> <BR> <CODE>void MI_DmaCopy32_SetUp( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size );</CODE><BR> <BR> <CODE>void MI_DmaCopy16( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size );</CODE><BR> <BR> <CODE>void MI_DmaCopy16_SetUp( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size );</CODE><BR> <BR> <CODE>void MI_DmaCopy32Async( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size,<BR> MIDmaCallback callback,<BR> void* arg );</CODE><BR> <BR> <CODE>void MI_DmaCopy32Async_SetUp( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size,<BR> MIDmaCallback callback,<BR> void* arg );</CODE><BR> <BR> <CODE>void MI_DmaCopy16Async( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size,<BR> MIDmaCallback callback,<BR> void* arg );</CODE><BR> <BR> <CODE>void MI_DmaCopy16Async_SetUp( u32 dmaNo,<BR> const void* src,<BR> void* dest,<BR> u32 size,<BR> MIDmaCallback callback,<BR> void* arg );</CODE><BR>
15</DL>
16<H2>Arguments</H2>
17<TABLE border="1" width="100%">
18  <TBODY>
19    <TR>
20<TD width="13%"><EM><STRONG>dmaNo</STRONG></EM></TD>
21<TD width="87%">DMA channel used.</TD>
22    </TR>
23    <TR>
24<TD width="13%"><EM><STRONG>src</STRONG></EM></TD>
25<TD width="87%">The transfer source address.</TD>
26    </TR>
27    <TR>
28<TD width="13%"><EM><STRONG>dest</STRONG></EM></TD>
29<TD width="87%">The transfer destination address.</TD>
30    </TR>
31    <TR>
32<TD><EM><STRONG>size</STRONG></EM></TD>
33<TD>Transfer size.</TD>
34    </TR>
35    <TR>
36<TD><EM><STRONG>callback</STRONG></EM></TD>
37<TD>Callback when DMA ends.</TD>
38    </TR>
39    <TR>
40<TD><EM><STRONG>arg</STRONG></EM></TD>
41<TD>Callback argument when DMA ends.</TD>
42    </TR>
43  </TBODY>
44</TABLE>
45<H2>Return Values</H2>
46<P>None.</P>
47<H2>Description</H2>
48<P>Uses DMA to copy.</P>
49<P>The <CODE>*_SetUp</CODE> functions only configure the given settings without actually performing DMA. To actually start DMA, call the <CODE><A href="MI_DmaRestart.html">MI_DmaRestart</A></CODE> function.</P>
50<P>The <CODE>MI_DmaCopy16*</CODE> functions copy in 16-bit units. Both the transfer source address and the transfer destination address must be 2-byte aligned.</P>
51<P>The <CODE>MI_DmaCopy32*</CODE> functions copy in 32-bit units. Both the transfer source address and the transfer destination address must be 4-byte aligned.</P>
52<P><code>MI_DmaCopy16()</code> and <code>MI_DmaCopy32()</code> wait within the function until DMA completes. The <code>MI_DmaCopy16Async*</code> and <code>MI_DmaCopy32Async*</code> functions call a callback function when DMA ends. The callback, <em><strong><code>callback</code></strong></em>, is a <code>MIDmaCallback</code> type (a <code>void</code> type function that takes one <code>void*</code> argument). <code>callback</code> is called from the system DMA interrupt handler and therefore is called while interrupts are prohibited.</P>
53<P>It is necessary to understand how to use Async-type APIs in order to obtain maximum functionality.</P>
54<P>The following is an example of a function name <code>Call_BackGroundJob_with_DMA()</code> that is placed within TCM.</P>
55<P>The following processes are performed:</P>
56<UL>
57<LI>Data transfer using DMA within the function begins.
58<LI>When the DMA ends, <code>isDmaFinished</code> will be set to <code>TRUE</code> within <code>callback()</code>.
59<LI>It is possible to poll <CODE>isDmaFinished</CODE> as a completion flag, and call the <CODE>BackGroundJob</CODE> function repeatedly until DMA completes.
60</UL>
61<P>However, the following must be considered to have this process proceed as intended:</P>
62<UL>
63<LI>If <code>isDmaFinished</code> is not in TCM, then stalling will occur during the <code>while(!isDmaFinished)</code> check.
64<LI>Stalling will occur if <code>BackGroundJob()</code> accesses the ARM bus.
65<LI>In many cases, the stack will also need to be allocated within TCM. (The stack is allocated within DTCM with the default SDK configuration.)
66<LI>If this function is located in main memory, stalling occurs when DMA starts. Therefore, the <code>BackGroundJob</code> function cannot be called continuously.
67</UL>
68<BLOCKQUOTE>
69<PRE><CODE>
70//--- sample code ( This code must be in ITCM )
71void Call_BackGroundJob_with_DMA(void)
72{
73  vu32 isDmaFinished = FALSE;
74    :
75  MI_DmaCopy32Async( dmaNo, srcArea, destArea, dataSize, callback, (void*)&amp;isDmaFinished );
76  while( !isDmaFinished ){ BackGroundJob(); }
77    :
78}
79
80void callback( void* arg )
81{
82   *(vu32*)arg = TRUE;
83}</CODE></PRE>
84</BLOCKQUOTE>
85<H2>Internal Operation</H2>
86<P>Uses the following IO registers: DMA<i>n</i> source register (0x40000B0 + 12<i>n</i>), DMA<i>n</i> destination register (0x40000B4 + 12<i>n</i>), and DMA<i>n</i> control register (0x40000B8 + 12<i>n</i>). (<i>n</i> is the DMA channel used.))</P>
87<H2>See Also</H2>
88<P><CODE><A href="../memory/MI_CpuCopy.html">MI_CpuCopy*</A><BR> <A href="MI_DmaClear.html">MI_DmaClear*</A><BR> <A href="MI_DmaFill.html">MI_DmaFill*</A><BR> <A href="MI_DmaRestart.html">MI_DmaRestart</A><BR> <A href="MI_DmaSend.html">MI_DmaSend*</A></CODE></P>
89<H2>Revision History</H2>
90<P>2007/10/31 Added the <CODE>_SetUp</CODE> functions.<BR>2005/03/08 Standardized the Japanese term for &quot;interrupt.&quot;<CODE> 2004/12/22 Added a description regarding <em><strong><code>callback</code></strong></em>. </CODE> 2003/12/01 Initial version.</P>
91<hr><p>CONFIDENTIAL</p></body>
92</HTML>