# MI_NDmaCopy*

## Syntax

  `#include <twl/mi.h>`
  `void MI_NDmaCopy( u32 ndmaNo,`
`const void* src, void* dest, u32 size );`

  `void MI_NDmaCopy_SetUp( u32 ndmaNo,`
`const void* src, void* dest, u32 size );`

  `void MI_NDmaCopyAsync( u32 dmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaCallback callback, void* arg );`

  `void MI_NDmaCopyAsync_SetUp( u32 dmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaCallback callback, void* arg );`

  `void MI_NDmaCopyEx( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaConfig *config );`

  `void MI_NDmaCopyEx_SetUp( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaConfig *config );`

  `void MI_NDmaCopyExAsync( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaCallback callback, void* arg,`
  `MINDmaConfig *config``);`

  `void MI_NDmaCopyExAsync_SetUp( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaCallback callback, void* arg,`
  `MINDmaConfig *config``);`

  `void MI_NDmaCopy_Dev( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaDevice dev );`

  `void MI_NDmaCopy_Dev_SetUp( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaDevice dev );`

  `void MI_NDmaCopyAsync_Dev( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaCallback callback, void* arg,`
`MINDmaDevice dev );`

  `void MI_NDmaCopyAsync_Dev_SetUp( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaCallback callback, void* arg,`
`MINDmaDevice dev );`

  `void MI_NDmaCopyEx_Dev( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaConfig *config,`
`MINDmaDevice dev );`

  `void MI_NDmaCopyEx_Dev_SetUp( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaConfig *config,`
`MINDmaDevice dev );`

  `void MI_NDmaCopyExAsync_Dev( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaCallback callback, void* arg,`
  `MINDmaConfig *config,`
`MINDmaDevice dev );`

  `void MI_NDmaCopyExAsync_Dev_SetUp( u32 ndmaNo,`
`const void* src, void* dest, u32 size,`
`MINDmaCallback callback, void* arg,`
  `MINDmaConfig *config,`
`MINDmaDevice dev );`

## Arguments

ndmaNo | DMA channel to use (0-3 within the new DMA).
src | Transfer source address.
dest | Transfer destination address.
size | Transfer size.
callback | DMA completion callback.
arg | DMA completion callback argument.
config | DMA setting.
dev | Device (if starting a device).

## Return Values

None.

## Description

Uses the new DMA to copy.
(The `*_SetUp` functions configure the DMA settings but do not transfer data.)

`MI_NDmaCopy*` uses the TWL's new DMA to perform copies in word (4-byte) units. Both the transfer source address (src) and the transfer destination address (dest) must be 4-byte aligned. The transfer size (size) needs to be a multiple of 4.

Specify the new DMA to use as a number between 0 and 3, in ndmaNo.

The `MI_NDmaCopy*` functions include functions for the separate operations given below.

-Whether to wait for DMA shutdown inside the function
-Whether to use defaults for detailed DMA settings or user specifications
-Whether to start DMA immediately, or start it based on an interrupt from a peripheral device

In addition, the `*_SetUp` functions only configure the given settings without starting DMA. To start DMA, call the `MI_NDmaRestart` function.

Functions | Wait for DMA Completion in the Function | Detailed DMA Settings | Start DMA
--- | --- | --- | ---
`MI_NDmaCopy` | Yes | Default | Immediately
`MI_NDmaCopyAsync` | No (Async) | Default | Immediately
`MI_NDmaCopyEx` | Yes | User-defined | Immediately
`MI_NDmaCopyExAsync` | No (Async) | User-defined | Immediately
`MI_NDmaCopy_Dev` | Yes | Default | Interrupt from peripheral device
`MI_NDmaCopyAsync_Dev` | No (Async) | Default | Interrupt from peripheral device
`MI_NDmaCopyEx_Dev` | Yes | User-defined | Interrupt from peripheral device
`MI_NDmaCopyExAsync_Dev` | No (Async) | User-defined | Interrupt from peripheral device

The `Async-type functions` calls the callback specified in callback upon DMA completion. The callback is of type `MINDmaCallback` (a `void`-type function that takes one of the `void*` arguments). The callback argument is called from the system DMA interrupt handler and therefore is called even if interrupts are prohibited.

To achieve maximum functionality, it is necessary to understand how to use Async-type functions.
For more information, see the `MI_DmaCopy` function.

The config argument is a pointer to the structure that determines the details of the DMA behavior.

The dev argument indicates the device when performing DMA upon startup of a peripheral device. For the values that can be set, see "DMA Start Timing" in New DMA: Overview

## Internal Operation

Uses the new I/O DMA registers.

## See Also

`MI_NDmaFill*`
`MI_NDmaClear*`
`MI_DmaCopy*`
`MI_CpuCopy*`
`MI_NDmaRestart`
New NDMA: Overview

## Revision History

2008/11/19 Added the link for `MINDmaDevice`.
2007/10/31 Added `_SetUp`.
2007/09/06 Initial version.

CONFIDENTIAL