diff --git a/app/Makefile b/app/Makefile new file mode 100644 index 0000000..f56abc6 --- /dev/null +++ b/app/Makefile @@ -0,0 +1,15 @@ +#/********************************************* +# * Benjamin Krill +# *********************************************/ +CFLAGS= -c -I../libfpga + +CC = gcc + +SRCS = fifo_shift.c +OBJS = $(SRCS:%.c=%.o) + +fifo_shift: ${OBJS} + ${CC} $^ -o $@ -lfpga + +clean: + rm *.o *.so.* diff --git a/app/fifo_shift.c b/app/fifo_shift.c new file mode 100644 index 0000000..d53bd1d --- /dev/null +++ b/app/fifo_shift.c @@ -0,0 +1,46 @@ +/********************************************* + * Benjamin Krill + *********************************************/ +#include +#include +#include +#include +#include +#include +#include + +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; +} diff --git a/libfpga/Makefile b/libfpga/Makefile index 7515edc..6984733 100644 --- a/libfpga/Makefile +++ b/libfpga/Makefile @@ -1,4 +1,6 @@ - +#/********************************************* +# * Benjamin Krill +# *********************************************/ CFLAGS=-c -fPIC CC = gcc diff --git a/libfpga/libfpga.h b/libfpga/libfpga.h index 9fbbea0..1a81bb5 100644 --- a/libfpga/libfpga.h +++ b/libfpga/libfpga.h @@ -1,9 +1,9 @@ /********************************************* * Benjamin Krill *********************************************/ -int fpgafs_create_context(int fd, const char *name) -int fpgafs_send_data(const void *buf, size_t count); -int fpgafs_recv_data(void *buf, size_t count); +int fpgafs_create_context(int fd, const char *name); +int fpgafs_send_data(const void *buf, int count); +int fpgafs_recv_data(void *buf, int count); int fpgafs_send_cmd(unsigned int cmd); int fpgafs_get_stat(); int fpgafs_set_lldrv(const char* name);