# CAMERA_DmaRecvAsync

## Syntax

  `#include <twl/camera.h>`
  `void CAMERA_DmaRecvAsync(u32 dmaNo, void *dest, u32 unit, u32 length, MINDmaCallback callback, void* arg);`

## Arguments

dmaNo | New DMA channel to use (0–3)
dest | The transfer destination address
unit | One-time transfer size (width * line count)
length | Total size to transfer (frame size)
callback | Callback when the new DMA ends
arg | Callback arguments when the new DMA ends

## Return Values

None.

## Description

Receives frame data asynchronously from the camera buffer.
This function internally uses a new DMA to receive data. See the `MI_NDmaCopy` function for more detailed descriptions of a new DMA.
The width and line count used when finding the one-time transfer size will indicate the number of bytes transferred for a single line and the number of lines transferred at once, respectively.
One pixel takes up two bytes, so multiply the width by 2 to calculate the number of bytes to transfer. The width is the same as the one set by the `CAMERA_SetTrimmingParams` function if it is called, and the `CAMERA_I2CSize*` functions otherwise. (It will be the width of the default camera resolution value if none of these functions have been called. See the Overview for more information on default values.)Calculate the number of lines using the line count set with the `CAMERA_SetTransferLines` function. The default line count is 1 if it has not been set by the `CAMERA_SetTransferLines` function. In addition, adjust the one-time transfer size that is ultimately specified to be 2 KB (1024 pixels) or less.
Some example code is shown below.

> Example:

>     #define WIDTH 256

>     #define HEIGHT 192

>     void CameraDmaRcvIntr(void* arg)
>     {
>         CAMERA_DmaRecvAsync(0, buffer, CAMERA_GetBytesAtOnce(WIDTH), CAMERA_GET_FRAME_BYTES(WIDTH, HEIGHT), CameraDmaRecvIntr, NULL);
>     }

>     CAMERA_SetTrimmingParamsCenter(WIDTH, HEIGHT, 320, 240);
>     CAMERA_SetTrimming(TRUE);
>     CAMERA_SetTransferLines(CAMERA_GET_MAX_LINES(WIDTH));    /* 256*4=1024 pixels */

>     .
>     .
>     .

>     CAMERA_DmaRecvAsync(0, buffer, CAMERA_GetBytesAtOnce(WIDTH), CAMERA_GET_FRAME_BYTES(WIDTH, HEIGHT), CameraDmaRecvIntr, NULL);

Note: This function is normally called from a camera's VSync interrupt callback, but depending on the camera settings (size and frame) and the application state, the new DMA interrupt called from this function and the VSync interrupt may occur at about the same time. In such cases, the camera interrupts will be be called consecutively, followed by the new DMA interrupt, even though the new DMA interrupt usually occurs between the two camera interrupts. Do not create applications that depend on new DMA interrupt callbacks.

## See Also

`CAMERA_DmaRecv, CAMERA_SetTransferLines, CAMERA_SetTrimmingParams?CAMERA_SetTrimming, CAMERA_I2CSize*, CAMERA_GetBytesAtOnce, CAMERA_GET_FRAME_BYTES, CAMERA_GET_MAX_LINES`

## Revision History

2008/09/11 Changed the sample code.
2008/03/06 Added an explanation for conflicts between the camera and new DMA interrupts.
2007/11/14 Revised the explanation for specifying the width.
2007/10/22 Added descriptions.
2007/10/02 Initial version.

CONFIDENTIAL