#include <nitro/mi.h>
void MI_DmaCopy32( u32 dmaNo, const void* src, void* dest, u32 size );
void MI_DmaCopy16( u32 dmaNo, const void* src, void* dest, u32 size );
void MI_DmaCopy32Async( u32 dmaNo, const void* src, void* dest, u32 size,
MIDmaCallback callback, void* arg );
void MI_DmaCopy16Async( u32 dmaNo, const void* src, void* dest, u32 size,
MIDmaCallback callback, void* arg );
This function uses DMA to copy.
MI_DmaCopy16() and MI_DmaCopy16Async() copy in zeros in 16-bit units. The transfer source and transfer destination addresses must be 2-byte aligned.
MI_DmaCopy32() and MI_DmaCopy32Async() copy in zeros in 32-bit units. The transfer source and transfer destination addresses must be 4-byte aligned.
MI_DmaCopy16() and MI_DmaCopy32() wait within the
function until DMA completes.
MI_DmaCopy16Async() and MI_DmaCopy32Async() call a callback function when DMA ends. The callback function is a MIDmaCallback type (a void type function with an argument removed from void*).
It is necessary to understand how to use Async-type APIs in order to obtain maximum functionality.
The following is an example of a function name Call_BackGroundJob_with_DMA() that is placed within TCM.
The following processes are performed:
TRUE is entered in isDmaFinished in callback().isDmaFinished is polled as an end flag and BackGroundJob() can be called continuously until DMA ends.However, the following must be considered to have this process proceed as intended:
isDmaFinished is not taken inside TCM, then stalling will occur during the while(!isDmaFinished) check.BackGroundJob() accesses the ARM bus.BackGroundJob() cannot be called continuously.
//--- sample code ( This code must be in ITCM )
void Call_BackGroundJob_with_DMA(void)
{
vu32 isDmaFinished = FALSE;
:
MI_DmaCopy32Async( dmaNo, srcArea, destArea, dataSize, callback, (void*)&isDmaFinished );
while( !isDmaFinished ){ BackGroundJob(); }
:
}
void callback( void* arg )
{
*(vu32*)arg = TRUE;
}
Uses the following IO registers: DMAn source register (0x40000B0 + 12n), DMAn destination register (0x40000B4 + 12n), and DMAn control register (0x40000B8 + 12n). (n is the DMA channel used.)
dmaNo |
DMA channel used |
src |
Transfer source address |
dest |
Transfer destination address |
size |
Transfer size |
callback |
Callback when DMA ends |
arg |
Callback argument when DMA ends |
None
MI_DmaFill*, MI_DmaClear*, MI_DmaSend*, MI_CpuCopy*
10/18/2004 Corrected punctuation in C Spec.
12/01/2003 Initial version.