47 lines
1.1 KiB
C
47 lines
1.1 KiB
C
|
/*********************************************
|
||
|
* Benjamin Krill <ben@codiert.org>
|
||
|
*********************************************/
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <sys/types.h>
|
||
|
#include <sys/stat.h>
|
||
|
#include <fcntl.h>
|
||
|
#include <errno.h>
|
||
|
#include <libfpga.h>
|
||
|
|
||
|
int
|
||
|
main(int argv, char **argc)
|
||
|
{
|
||
|
int fd, sta, rnd, i;
|
||
|
char *c, buf[4];
|
||
|
|
||
|
if ((fd = open("tdat", O_RDONLY, 0)) == -1 ) {
|
||
|
printf("ERROR-1: %s\n", strerror(errno));
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
if (fpgafs_create_context(fd, "dbg") == -1) {
|
||
|
printf("ERROR-2: Cannot create fpgafs context\n");
|
||
|
close(fd);
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
// while (fpgafs_get_stat() < 0x10) {
|
||
|
for(i=0; i < 10; i++) {
|
||
|
rnd = rand();
|
||
|
c = (char *)&rnd;
|
||
|
printf("write data: %x\n",c[0], c[1], c[2], c[3]);
|
||
|
if ((sta=fpgafs_send_data(&c[0], 4)) != 4) {
|
||
|
printf("ERROR-3: Cannot send specified length (%d)\n", sta);
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
if ((sta=fpgafs_recv_data(&c[0], 4)) != 4) {
|
||
|
printf("ERROR-3: Cannot send specified length (%d)\n", sta);
|
||
|
return -1;
|
||
|
}
|
||
|
printf("read data: %x\n",buf[0], buf[1], buf[2], buf[3]);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|