Page 1 of 1

How to use the DMA engine

PostPosted: Wed Nov 11, 2015 2:34 pm
by Richardye
Hi Guys,

Here I got quite confused about the DMA control in the epiphany side. Hope someone could help me ...

typedef struct
unsigned config;
unsigned inner_stride;
unsigned count;
unsigned outer_stride;
void *src_addr;
void *dst_addr;
} e_dma_desc_t;

Above is the declaration for the e_dma_desc_t.

The questions are ,

1. What does the inner & outer stride, count stands for ? If I would like to copy a char array of size 1024, how whould I set these values ?

2. How can I start the DMA transfer ? Using int e_dma_start(e_dma_desc_t *descriptor, e_dma_id_t chan) or e_dma_copy(void *dst, void *src, size_t bytes) ?

Hope some one could help me, this really bothers me !!!!


Re: How to use the DMA engine

PostPosted: Thu Nov 12, 2015 3:43 pm
by jar
I can point you to a couple examples of different complexity. The simplest case should solve your problem: ... pi_tfunc.c

If you're just copying a linear array in memory like you described, you only need to use e_dma_copy(). You give it the address if your destination and sources, and how many bytes.
Code: Select all
char dst[1024];
char *src; // Pointer to data
e_dma_copy((void*)dst, (void*)src, 1024);

Everything else you mentioned is only required if you want to do something more complicated. For example, if you want to copy a 2D block from a 2D array of data, you may find an example here: ... pi_tfunc.c

You must use the e_dma_set_desc(), e_dma_start(), and e_dma_wait() routines.

Re: How to use the DMA engine

PostPosted: Sun Nov 15, 2015 9:51 pm
by Richardye
Hi Jar,

Thank you very much! Now the DMA thing is much clearer. Thank you :D