Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
#include "altera_dma_cmd.h"
#include "altera_dma_regs.h"
#define BUFFER_LENGTH 40
unsigned int* pDmaUser;
int main (int argc ,char** argv) {
int i;
int rc= 0;
int on_chip_size = ( DMASIZE * 4 )*ALTERA_DMA_DESCRIPTOR_NUM ;
ssize_t f;
f = open ("/dev/pcie40_0_altdma", O_RDWR);
if (f == -1) {
printf ("Couldn't open the device.\n");
return 0;
} else {
printf ("Opened the device: file handle #%lu!\n", (long unsigned int)f);
}
pDmaUser= (unsigned int *) mmap( NULL ,
on_chip_size ,
PROT_READ|PROT_WRITE ,
MAP_SHARED ,
f ,
0x000);
rc = ioctl(f, ALTERA_IOCX_START);
if (( pDmaUser!= NULL)&(rc >0) ) {
for (i= 0 ;i < DMASIZE;i++) printf("0X%08x\n",pDmaUser[i]);
} else {
printf (" No data available :\n");
if (rc == -1) printf( "DMA too longs\n ");
if (rc == -2) printf( "FIFO is empty \n ");
}
close (f);
return 0 ;
}