libnds
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
dma.h File Reference

Wrapper functions for direct memory access hardware. More...

#include "nds/ndstypes.h"

Functions

int dmaBusy (uint8 channel)
 determines if the specified channel is busy More...
 
void dmaCopy (const void *source, void *dest, uint32 size)
 copies from source to destination using channel 3 of DMA available channels in half words More...
 
void dmaCopyAsynch (const void *source, void *dest, uint32 size)
 copies from source to destination using channel 3 of DMA available channels in half words. This function returns immediately after starting the transfer. More...
 
void dmaCopyHalfWords (uint8 channel, const void *src, void *dest, uint32 size)
 copies from source to destination on one of the 4 available channels in half words More...
 
void dmaCopyHalfWordsAsynch (uint8 channel, const void *src, void *dest, uint32 size)
 copies from source to destination on one of the 4 available channels in half words. This function returns immediately after starting the transfer. More...
 
void dmaCopyWords (uint8 channel, const void *src, void *dest, uint32 size)
 copies from source to destination on one of the 4 available channels in words More...
 
void dmaCopyWordsAsynch (uint8 channel, const void *src, void *dest, uint32 size)
 copies from source to destination on one of the 4 available channels in half words. This function returns immediately after starting the transfer. More...
 
void dmaFillHalfWords (u16 value, void *dest, uint32 size)
 fills the source with the supplied value using DMA channel 3 More...
 
void dmaFillWords (u32 value, void *dest, uint32 size)
 fills the source with the supplied value using DMA channel 3 More...
 

Detailed Description

Wrapper functions for direct memory access hardware.

The DS has 4 hardware direct memory access devices per CPU which can be used to transfer or fill chunks of memeory without CPU intervention. Utilizing DMA is generaly faster than CPU copies (memcpy, swiCopy, for loops, etc..).
DMA has no access to data caches on the DS and as such will give unexpected results when DMAing data from main memory. The cache must be flushed as follows when using DMA to ensure proper opertion on the arm9:
DC_FlushRange(source, sizeof(dataToCopy));
dmaCopy(source, destination, sizeof(dataToCopy));

Function Documentation

static dmaBusy ( uint8  channel)
inline

determines if the specified channel is busy

Parameters
channelthe dma channel to check (0 - 3).
Returns
non zero if busy, 0 if channel is free
static void dmaCopy ( const void *  source,
void *  dest,
uint32  size 
)
inline

copies from source to destination using channel 3 of DMA available channels in half words

Parameters
sourcethe source to copy from
destthe destination to copy to
sizethe size in bytes of the data to copy. Will be truncated to the nearest half word (2 bytes)
static void dmaCopyAsynch ( const void *  src,
void *  dest,
uint32  size 
)
inline

copies from source to destination using channel 3 of DMA available channels in half words. This function returns immediately after starting the transfer.

Parameters
srcthe source to copy from
destthe destination to copy to
sizethe size in bytes of the data to copy. Will be truncated to the nearest half word (2 bytes)
static void dmaCopyHalfWords ( uint8  channel,
const void *  src,
void *  dest,
uint32  size 
)
inline

copies from source to destination on one of the 4 available channels in half words

Parameters
channelthe dma channel to use (0 - 3).
srcthe source to copy from
destthe destination to copy to
sizethe size in bytes of the data to copy. Will be truncated to the nearest half word (2 bytes)
static void dmaCopyHalfWordsAsynch ( uint8  channel,
const void *  src,
void *  dest,
uint32  size 
)
inline

copies from source to destination on one of the 4 available channels in half words. This function returns immediately after starting the transfer.

Parameters
channelthe dma channel to use (0 - 3).
srcthe source to copy from
destthe destination to copy to
sizethe size in bytes of the data to copy. Will be truncated to the nearest half word (2 bytes)
static void dmaCopyWords ( uint8  channel,
const void *  src,
void *  dest,
uint32  size 
)
inline

copies from source to destination on one of the 4 available channels in words

Parameters
channelthe dma channel to use (0 - 3).
srcthe source to copy from
destthe destination to copy to
sizethe size in bytes of the data to copy. Will be truncated to the nearest word (4 bytes)
static void dmaCopyWordsAsynch ( uint8  channel,
const void *  src,
void *  dest,
uint32  size 
)
inline

copies from source to destination on one of the 4 available channels in half words. This function returns immediately after starting the transfer.

Parameters
channelthe dma channel to use (0 - 3).
srcthe source to copy from
destthe destination to copy to
sizethe size in bytes of the data to copy. Will be truncated to the nearest word (4 bytes)
static void dmaFillHalfWords ( u16  value,
void *  dest,
uint32  size 
)
inline

fills the source with the supplied value using DMA channel 3

Parameters
valuethe 16 byte value to fill memory with
destthe destination to copy to
sizethe size in bytes of the area to fill. Will be truncated to the nearest half word (2 bytes)
static void dmaFillWords ( u32  value,
void *  dest,
uint32  size 
)
inline

fills the source with the supplied value using DMA channel 3

Parameters
valuethe 32 byte value to fill memory with
destthe destination to copy to
sizethe size in bytes of the area to fill. Will be truncated to the nearest word (4 bytes)