# CAMERA_DmaRecv

## Syntax

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

## 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)

## Return Values

None.

## Description

Receives frame data 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

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

>     .
>     .
>     .

>     CAMERA_DmaRecv(0, buffer, CAMERA_GetBytesAtOnce(WIDTH), CAMERA_GET_FRAME_BYTES(WIDTH, HEIGHT));

## See Also

`CAMERA_DmaRecvAsync, 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.
2007/11/14 Revised explanations for specifying the width.
2007/10/22 Added explanations.
2007/10/02 Initial version.

CONFIDENTIAL